Module ketos::exec
[−]
[src]
Implements a virtual machine which interprets bytecode functions.
The virtual machine consists of:
- A value stack, containing values stored or passed into functions
- A single value register into which values can be loaded from the stack and from which values can be pushed onto the stack.
- A call stack, containing for each successive function:
- an index into the bytecode ("instruction pointer")
- an index into the value stack ("stack pointer")
- any constant values referenced by bytecode instructions
- any enclosed values referenced by bytecode instructions
Bytecode instructions may modify or consume the value register, push values onto the stack, modify the instruction pointer, add a function call to the call stack, or return from the function currently being executed.
When a bytecode function is added to the stack, its stack pointer will be set to the position of the first argument which is passed to the function. It may load or modify these values. When the function returns, all values after the stack pointer will be automatically removed from the stack before returning control to the previous function execution. Every function returns a value, which is available to the calling function through the value register.
Structs
Context |
Represents an execution context |
Enums
ExecError |
Represents an error generated while executing bytecode. |
Functions
call_function |
Calls a function or lambda in the given scope with the given arguments. |
execute |
Executes a code object and returns the value. |
execute_function |
Executes a |
execute_lambda |
Executes a |
panic |
Returns a |
panic_none |
Returns a |