Expand description
Bytecode runtime
Create a VirtualMachine
and attach compiled functions to it. Begin execution
with run
, or use initialize_with_values
and execution_loop
for more fine grained
control.
Example:
let trisum_source_code = r"function trisum(a, b, c) return a + b + c end";
let (_, trisum_fn_decl) = parser::declaration::function_decl(trisum_source_code).unwrap();
let trisum_procedure = compiler::compile_function(&trisum_fn_decl);
let mut vm = VirtualMachine::new();
vm.initialize_with_values(Rc::new(trisum_procedure), [10.into(), 20.into(), 30.into()]);
vm.execution_loop(InstructionCount::Unlimited);
assert_eq!(vm.get_result(), Value::Integer(60));
Structs
Bytecode evaluation engine