summaryrefslogtreecommitdiff
path: root/uscript/vm.h
diff options
context:
space:
mode:
Diffstat (limited to 'uscript/vm.h')
-rw-r--r--uscript/vm.h13
1 files changed, 12 insertions, 1 deletions
diff --git a/uscript/vm.h b/uscript/vm.h
index 15c21a0..2911d01 100644
--- a/uscript/vm.h
+++ b/uscript/vm.h
@@ -11,6 +11,8 @@
#define vm_peek() (vm.stacktop[-1])
#define vm_push(v) (*vm.stacktop++ = (v))
+#define set_global(idx, v) (vm.gstack[idx].val = (v))
+
enum bytecode {
#define BC(name) BC_##name,
#include "xbytecode.h"
@@ -22,16 +24,23 @@ struct call_frame {
struct us_val *stackbot;
};
+struct global {
+ struct us_str *name;
+ struct us_val val;
+};
+
struct vm {
struct us_val *objs;
struct call_frame cf_stack[MAX_CALL_FRAMES];
struct call_frame *cf;
- struct us_val *global_stack; // dyn_arr
struct us_val stack[STACK_SIZE];
struct us_val *stacktop;
+ struct global *gstack; // dynarr
+ struct global *gstacktop;
+
struct us_upval *open_upvals;
};
@@ -41,4 +50,6 @@ void init_vm(void);
void deinit_vm(void);
void print_func(struct us_proto *proto);
+int declare_global(struct us_str *name);
+
#endif // __USCRIPT_VM_H__