pub struct VM { /* private fields */ }Implementations§
Source§impl VM
impl VM
pub fn new() -> Self
pub fn with_capacity(compile_cap: usize, path_cap: usize) -> Self
Sourcepub fn with_registry(registry: Arc<MethodRegistry>) -> Self
pub fn with_registry(registry: Arc<MethodRegistry>) -> Self
Build a VM that shares an existing method registry.
Sourcepub fn register_arc(&mut self, name: &str, method: Arc<dyn Method>)
pub fn register_arc(&mut self, name: &str, method: Arc<dyn Method>)
Register a method already wrapped in Arc.
Sourcepub fn set_pass_config(&mut self, config: PassConfig)
pub fn set_pass_config(&mut self, config: PassConfig)
Replace the pass configuration. The compile cache is not purged, but future lookups key off the new config hash so old entries are effectively invalidated for the new regime.
pub fn pass_config(&self) -> PassConfig
Sourcepub fn register(
&mut self,
name: impl Into<String>,
method: impl Method + 'static,
)
pub fn register( &mut self, name: impl Into<String>, method: impl Method + 'static, )
Register a custom method (callable via .method_name(...) in expressions).
Sourcepub fn run_str(&mut self, expr: &str, doc: &Value) -> Result<Value, EvalError>
pub fn run_str(&mut self, expr: &str, doc: &Value) -> Result<Value, EvalError>
Parse, compile (cached), and execute expr against doc.
Sourcepub fn execute(
&mut self,
program: &Program,
doc: &Value,
) -> Result<Value, EvalError>
pub fn execute( &mut self, program: &Program, doc: &Value, ) -> Result<Value, EvalError>
Execute a pre-compiled Program against doc.
Sourcepub fn execute_with_schema(
&mut self,
program: &Program,
doc: &Value,
shape: &Shape,
) -> Result<Value, EvalError>
pub fn execute_with_schema( &mut self, program: &Program, doc: &Value, shape: &Shape, ) -> Result<Value, EvalError>
Execute a compiled program against a document, first specialising
against the given shape (turns OptField → GetField where safe,
folds KindCheck where type is known, etc.).
Sourcepub fn execute_with_inferred_schema(
&mut self,
program: &Program,
doc: &Value,
) -> Result<Value, EvalError>
pub fn execute_with_inferred_schema( &mut self, program: &Program, doc: &Value, ) -> Result<Value, EvalError>
Execute a program; infer the shape from the document itself. Costs an O(doc) shape walk before execution; useful when the same compiled program is reused across many docs with similar shapes.
Sourcepub fn get_or_compile(&mut self, expr: &str) -> Result<Arc<Program>, EvalError>
pub fn get_or_compile(&mut self, expr: &str) -> Result<Arc<Program>, EvalError>
Get or compile an expression string (compile cache). Cache key is (pass_config_hash, expr) so that different pass configurations yield different compiled programs.
Sourcepub fn cache_stats(&self) -> (usize, usize)
pub fn cache_stats(&self) -> (usize, usize)
Cache statistics: (compile_entries, path_entries).