summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-07-05 16:29:48 +0200
committerJo-Philipp Wich <jo@mein.io>2021-07-11 15:49:14 +0200
commit111645aa965717adb40604e53d0bab07e25c1b27 (patch)
tree2bfac3df75bf0f24d610b9f57b883c6c5dde092b
parent38ff6dedec5fea8e896a0fc821a0e5db62d029ba (diff)
vm: remove module preloading logic
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--main.c2
-rw-r--r--vm.c46
-rw-r--r--vm.h2
3 files changed, 4 insertions, 46 deletions
diff --git a/main.c b/main.c
index e466360..88a53f5 100644
--- a/main.c
+++ b/main.c
@@ -125,7 +125,7 @@ parse(uc_parse_config *config, uc_source *src,
register_variable(globals, ucv_string_get(name), mod);
}
- rc = uc_vm_execute(&vm, entry, NULL);
+ rc = uc_vm_execute(&vm, entry);
if (rc) {
rc = 1;
diff --git a/vm.c b/vm.c
index b05fbb7..277854c 100644
--- a/vm.c
+++ b/vm.c
@@ -2279,47 +2279,12 @@ uc_vm_execute_chunk(uc_vm *vm)
return STATUS_OK;
}
-static uc_vm_status_t
-uc_vm_preload(uc_vm *vm, uc_value_t *modules)
-{
- uc_value_t *requirefn, *module, *name;
- uc_exception_type_t ex;
- size_t i;
-
- if (ucv_type(modules) != UC_ARRAY)
- return STATUS_OK;
-
- requirefn = ucv_property_get(vm->globals, "require");
-
- if (ucv_type(requirefn) != UC_CFUNCTION)
- return STATUS_OK;
-
- for (i = 0; i < ucv_array_length(modules); i++) {
- name = ucv_array_get(modules, i);
-
- uc_vm_stack_push(vm, ucv_get(requirefn));
- uc_vm_stack_push(vm, ucv_get(name));
-
- ex = uc_vm_call(vm, false, 1);
-
- if (ex)
- return ERROR_RUNTIME;
-
- module = uc_vm_stack_pop(vm);
-
- ucv_put(uc_setval(vm, vm->globals, name, module));
- }
-
- return STATUS_OK;
-}
-
uc_vm_status_t
-uc_vm_execute(uc_vm *vm, uc_function_t *fn, uc_value_t *modules)
+uc_vm_execute(uc_vm *vm, uc_function_t *fn)
{
uc_closure_t *closure = (uc_closure_t *)ucv_closure_new(vm, fn, false);
uc_callframe *frame;
uc_stringbuf_t *buf;
- uc_vm_status_t rv;
uc_vector_grow(&vm->callframes);
@@ -2343,14 +2308,7 @@ uc_vm_execute(uc_vm *vm, uc_function_t *fn, uc_value_t *modules)
//uc_vm_stack_push(vm, closure->header.jso);
uc_vm_stack_push(vm, NULL);
- rv = uc_vm_preload(vm, modules);
-
- if (rv != STATUS_OK)
- uc_vm_output_exception(vm);
- else
- rv = uc_vm_execute_chunk(vm);
-
- return rv;
+ return uc_vm_execute_chunk(vm);
}
uc_exception_type_t
diff --git a/vm.h b/vm.h
index 5065ec6..cd0a886 100644
--- a/vm.h
+++ b/vm.h
@@ -124,7 +124,7 @@ uc_exception_type_t uc_vm_call(uc_vm *vm, bool mcall, size_t nargs);
void __attribute__((format(printf, 3, 0)))
uc_vm_raise_exception(uc_vm *vm, uc_exception_type_t type, const char *fmt, ...);
-uc_vm_status_t uc_vm_execute(uc_vm *vm, uc_function_t *fn, uc_value_t *modules);
+uc_vm_status_t uc_vm_execute(uc_vm *vm, uc_function_t *fn);
uc_value_t *uc_vm_invoke(uc_vm *vm, const char *fname, size_t nargs, ...);
#endif /* __VM_H_ */