load
Execute Do bytecode and register runtime import handlers.
Functions
run bytecode
Executes compiled Do bytecode.
Parameters:
| Name | Type | Description |
|---|---|---|
bytecode |
bin |
Compiled Do bytecode |
Returns: The result of executing the bytecode.
Errors:
- Raises a type error if
bytecodeis notbin - Propagates bytecode verification and execution errors
import compile
import load
let result = load.run $ (compile.compile "example.dol" "(1 + 1)").bytecode
assert_eq $result 2
import_handler callback
Registers a module import handler.
Handlers are tried after native modules and cached Do modules. The first handler that returns successfully supplies the imported value.
To decline a module name, raise
ImportError. Any other error aborts the import.
Parameters:
| Name | Type | Description |
|---|---|---|
callback |
func |
Called with the requested module name |
Returns: ImportHandler