summaryrefslogtreecommitdiffhomepage
path: root/vm.c
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-07-05 15:55:50 +0200
committerJo-Philipp Wich <jo@mein.io>2021-07-11 15:49:14 +0200
commit900b2a3f05fb1ec3844cc6bde9cd2fc03d168078 (patch)
treeac776286f871bcc88917f4109e1567319ec0d72a /vm.c
parent01795764e95983e416f5db14dd5599206b9ea41b (diff)
vm: add getter and setter for vm globals scope
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'vm.c')
-rw-r--r--vm.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/vm.c b/vm.c
index f990628..82d25c4 100644
--- a/vm.c
+++ b/vm.c
@@ -2285,8 +2285,7 @@ uc_vm_execute(uc_vm *vm, uc_function_t *fn, uc_value_t *globals, uc_value_t *mod
uc_stringbuf_t *buf;
uc_vm_status_t rv;
- vm->globals = globals;
- ucv_get(globals);
+ uc_vm_scope_set(vm, ucv_get(globals));
uc_vector_grow(&vm->callframes);
@@ -2317,8 +2316,7 @@ uc_vm_execute(uc_vm *vm, uc_function_t *fn, uc_value_t *globals, uc_value_t *mod
else
rv = uc_vm_execute_chunk(vm);
- ucv_put(vm->globals);
- vm->globals = NULL;
+ uc_vm_scope_set(vm, NULL);
return rv;
}
@@ -2336,3 +2334,16 @@ uc_vm_call(uc_vm *vm, bool mcall, size_t nargs)
return vm->exception.type;
}
+
+uc_value_t *
+uc_vm_scope_get(uc_vm *vm)
+{
+ return vm->globals;
+}
+
+void
+uc_vm_scope_set(uc_vm *vm, uc_value_t *ctx)
+{
+ ucv_put(vm->globals);
+ vm->globals = ctx;
+}