Skip to main content

ClosureCaller

Trait ClosureCaller 

Source
pub trait ClosureCaller {
    // Required method
    fn call_closure(
        &mut self,
        closure: Value,
        args: Vec<Value>,
    ) -> Result<Value, String>;
}
Expand description

Trait the parser interpreter uses to invoke captured closures during the recursive walk. The Vm implements it via Vm::invoke_closure_value, but the interpreter is generic over the implementation so lex-bytecode doesn’t need to depend on any higher-level runtime concepts.

Required Methods§

Source

fn call_closure( &mut self, closure: Value, args: Vec<Value>, ) -> Result<Value, String>

Implementors§

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.