2017-02-09 20:02:59 +00:00
|
|
|
#ifndef VM_H_C4OZU8CQ
|
|
|
|
#define VM_H_C4OZU8CQ
|
|
|
|
|
|
|
|
#include "datatypes.h"
|
2017-02-22 23:19:46 +00:00
|
|
|
#include "value.h"
|
2017-02-09 20:02:59 +00:00
|
|
|
|
|
|
|
/* Initialize the VM */
|
2017-02-16 02:02:00 +00:00
|
|
|
void gst_init(Gst * vm);
|
2017-02-09 20:02:59 +00:00
|
|
|
|
|
|
|
/* Deinitialize the VM */
|
2017-02-16 02:02:00 +00:00
|
|
|
void gst_deinit(Gst * vm);
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2017-03-08 15:54:50 +00:00
|
|
|
/* Start running the VM with a given entry point */
|
|
|
|
int gst_start(Gst * vm, GstValue func);
|
2017-02-09 20:02:59 +00:00
|
|
|
|
|
|
|
/* Run garbage collection */
|
2017-02-16 02:02:00 +00:00
|
|
|
void gst_collect(Gst * vm);
|
2017-02-09 20:02:59 +00:00
|
|
|
|
|
|
|
/* Collect garbage if enough memory has been allocated since
|
|
|
|
* the previous collection */
|
2017-02-16 02:02:00 +00:00
|
|
|
void gst_maybe_collect(Gst * vm);
|
2017-02-09 20:02:59 +00:00
|
|
|
|
2017-02-09 23:50:47 +00:00
|
|
|
/* Allocate memory */
|
2017-02-16 02:02:00 +00:00
|
|
|
void * gst_alloc(Gst * vm, uint32_t amount);
|
2017-02-09 23:50:47 +00:00
|
|
|
|
|
|
|
/* Allocate zeroed memory */
|
2017-02-16 02:02:00 +00:00
|
|
|
void * gst_zalloc(Gst * vm, uint32_t amount);
|
2017-02-09 23:50:47 +00:00
|
|
|
|
2017-02-10 04:28:11 +00:00
|
|
|
/* Get an argument from the stack */
|
2017-02-16 02:02:00 +00:00
|
|
|
GstValue gst_arg(Gst * vm, uint16_t index);
|
2017-02-10 04:28:11 +00:00
|
|
|
|
|
|
|
/* Put a value on the stack */
|
2017-02-16 02:02:00 +00:00
|
|
|
void gst_set_arg(Gst * vm, uint16_t index, GstValue x);
|
2017-02-10 04:28:11 +00:00
|
|
|
|
2017-02-11 19:01:06 +00:00
|
|
|
/* Get the number of arguments on the stack */
|
2017-02-16 02:02:00 +00:00
|
|
|
uint16_t gst_count_args(Gst * vm);
|
2017-02-11 19:01:06 +00:00
|
|
|
|
2017-02-09 20:02:59 +00:00
|
|
|
#endif /* end of include guard: VM_H_C4OZU8CQ */
|