pub struct Vm<'a> {
pub step_limit: u64,
pub steps: u64,
pub pure_memo_hits: u64,
pub pure_memo_misses: u64,
/* private fields */
}Fields§
§step_limit: u64Soft cap to avoid runaway computations in tests.
steps: u64§pure_memo_hits: u64Diagnostic counters for --trace observability (#229).
pure_memo_misses: u64Implementations§
Source§impl<'a> Vm<'a>
impl<'a> Vm<'a>
pub fn new(program: &'a Program) -> Self
pub fn with_handler( program: &'a Program, handler: Box<dyn EffectHandler + 'a>, ) -> Self
pub fn set_tracer(&mut self, tracer: Box<dyn Tracer + 'a>)
Sourcepub fn set_step_limit(&mut self, limit: u64)
pub fn set_step_limit(&mut self, limit: u64)
Cap the number of opcode dispatches before the VM aborts with
step limit exceeded. Useful as a runtime DoS guard against
untrusted code (e.g. the agent-tool sandbox, where an LLM
could emit list.fold(list.range(0, 1_000_000_000), …) to hang
the host). Default is 10_000_000.
pub fn call(&mut self, name: &str, args: Vec<Value>) -> Result<Value, VmError>
Sourcepub fn invoke_closure_value(
&mut self,
closure: Value,
args: Vec<Value>,
) -> Result<Value, VmError>
pub fn invoke_closure_value( &mut self, closure: Value, args: Vec<Value>, ) -> Result<Value, VmError>
Invoke a Value::Closure by combining its captures with the
supplied call args and dispatching to the underlying function.
Used by the parser interpreter (#221) to call user-supplied
f arguments inside parser.map / parser.and_then nodes.
pub fn invoke(&mut self, fn_id: u32, args: Vec<Value>) -> Result<Value, VmError>
Trait Implementations§
Source§impl<'a> ClosureCaller for Vm<'a>
Vm exposes itself as a ClosureCaller so the parser interpreter
can invoke user-supplied closures during a parser.run walk
(#221). The Vm is reentrant for closure invocation: pushing a new
frame onto an active call stack is supported, and the handler
stays in place so any effects the closure body fires dispatch
normally.
impl<'a> ClosureCaller for Vm<'a>
Vm exposes itself as a ClosureCaller so the parser interpreter
can invoke user-supplied closures during a parser.run walk
(#221). The Vm is reentrant for closure invocation: pushing a new
frame onto an active call stack is supported, and the handler
stays in place so any effects the closure body fires dispatch
normally.