diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-07-20 10:28:47 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-07-30 00:41:56 +0200 |
commit | d85bc716df9b97ac6093afa0bdf77c1b6b0cf6aa (patch) | |
tree | ce95cee08ece2a1d3e9a3cef57c0941dd26b921f /include | |
parent | 365782e002255c67b81cf96471fe41cfa6f6b714 (diff) |
vm: introduce import and export opcodes
Introduce new opcodes to realize module imports and exports. The export
operation will capture a local variable as upvalue and store it in VM
wide module export registry while the import operation will connect an
upvalue from the module export registry with a preallocated upvalue in
the running function scope.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'include')
-rw-r--r-- | include/ucode/types.h | 2 | ||||
-rw-r--r-- | include/ucode/vm.h | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/include/ucode/types.h b/include/ucode/types.h index 14f2a43..b810744 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -254,6 +254,7 @@ 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; @@ -270,6 +271,7 @@ struct uc_vm { uc_source_t *sources; uc_weakref_t values; uc_resource_types_t restypes; + uc_modexports_t exports; union { uint32_t u32; int32_t s32; diff --git a/include/ucode/vm.h b/include/ucode/vm.h index 8377446..cc57fdb 100644 --- a/include/ucode/vm.h +++ b/include/ucode/vm.h @@ -95,7 +95,9 @@ __insn(QMCALL) \ __insn(PRINT) \ __insn(NEXTK) \ __insn(NEXTKV) \ -__insn(DELETE) +__insn(DELETE) \ +__insn(IMPORT) \ +__insn(EXPORT) #undef __insn |