diff options
author | Jo-Philipp Wich <jo@mein.io> | 2022-08-06 14:23:44 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2022-08-06 23:25:11 +0200 |
commit | fcc49e6944ab29ab48e8363d2d72e9ca10d3fb76 (patch) | |
tree | 1ccab2a62017db277b5de73e0ce6a4ed93aa751a /tests | |
parent | c9442f12ee056fd50f314408052917cc5f359bb4 (diff) |
compiler: add import statement support for dynamic extensions
Utilize the new I_DYNLINK vm opcode to support import statements referring
to dynamic extension modules.
During compilation, the compiler will try to infer the type of the imported
module from the resolved file path; if it ends with `.so`, the module is
assumed to by a dynamic extension and loading/binding of the module is
deferred to runtime using I_DYNLINK opcodes.
Additionally, the `-c` cli option gained support for a new compiler flag
`dynlink=...` which allows forcing a particular module name expression
to be treated as dynamic extension. This is useful to e.g. force resolving
`import { x } from "foo"` to a dynamic extension `foo.so` loaded at runtime
even if a plain `foo.uc` exists in the search path during compilation or if
no such module is available at build time.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/cram/test_basic.t | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/cram/test_basic.t b/tests/cram/test_basic.t index 7308002..5911ac9 100644 --- a/tests/cram/test_basic.t +++ b/tests/cram/test_basic.t @@ -61,7 +61,8 @@ check that ucode provides exepected help: -c[flag,flag,...] Compile the given source file(s) to bytecode instead of executing them. Supported flags: no-interp (omit interpreter line), interp=... (over- - ride interpreter line with ...) + ride interpreter line with ...), dynlink=... (force import from ... to + be treated as shared extensions loaded at runtime). -o path Output file path when compiling. If omitted, the compiled byte code |