From d64d5d685d86b38dda8a314b7d1404633e26b346 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 30 Sep 2022 10:23:16 +0200 Subject: vm: maintain export symbol tables per program Instead of having one global export table per VM instance maintain one table per program instance. This is required to avoid clobbering the export list in case `import` using code is loaded at runtime through `require()`, `loadfile()` etc. Signed-off-by: Jo-Philipp Wich --- include/ucode/types.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/ucode/types.h b/include/ucode/types.h index 6041b22..bae2dd5 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -208,12 +208,14 @@ uc_declare_vector(uc_resource_types_t, uc_resource_type_t *); /* Program structure definitions */ uc_declare_vector(uc_sources_t, uc_source_t *); +uc_declare_vector(uc_modexports_t, uc_upvalref_t *); typedef struct uc_program { uc_value_t header; uc_value_list_t constants; uc_weakref_t functions; uc_sources_t sources; + uc_modexports_t exports; } uc_program_t; @@ -277,7 +279,6 @@ typedef struct { uc_declare_vector(uc_callframes_t, uc_callframe_t); uc_declare_vector(uc_stack_t, uc_value_t *); -uc_declare_vector(uc_modexports_t, uc_upvalref_t *); typedef struct printbuf uc_stringbuf_t; @@ -294,7 +295,7 @@ struct uc_vm { uc_source_t *sources; uc_weakref_t values; uc_resource_types_t restypes; - uc_modexports_t exports; + char _reserved[sizeof(uc_modexports_t)]; union { uint32_t u32; int32_t s32; -- cgit v1.2.3