pub struct Evaluator { /* private fields */ }Expand description
Evaluator for Aether programs
Implementations§
Source§impl Evaluator
impl Evaluator
Sourcepub fn with_permissions(permissions: IOPermissions) -> Self
pub fn with_permissions(permissions: IOPermissions) -> Self
Create a new evaluator with custom IO permissions
Sourcepub fn with_env(env: Rc<RefCell<Environment>>) -> Self
pub fn with_env(env: Rc<RefCell<Environment>>) -> Self
Create evaluator with custom environment
Sourcepub fn set_module_resolver(&mut self, resolver: Box<dyn ModuleResolver>)
pub fn set_module_resolver(&mut self, resolver: Box<dyn ModuleResolver>)
Configure the module resolver used for Import/Export.
Sourcepub fn push_import_base(&mut self, module_id: String, base_dir: Option<PathBuf>)
pub fn push_import_base(&mut self, module_id: String, base_dir: Option<PathBuf>)
Push a base directory context for resolving relative imports.
This is typically used by CLI eval_file() wrappers.
Sourcepub fn pop_import_base(&mut self)
pub fn pop_import_base(&mut self)
Pop the most recent base directory context.
Sourcepub fn trace_push(&mut self, msg: String)
pub fn trace_push(&mut self, msg: String)
Append a trace entry (host-readable; no IO side effects).
Sourcepub fn take_trace(&mut self) -> Vec<String>
pub fn take_trace(&mut self) -> Vec<String>
Drain the trace buffer.
Sourcepub fn clear_trace(&mut self)
pub fn clear_trace(&mut self)
Clear the trace buffer.
Sourcepub fn reset_env(&mut self)
pub fn reset_env(&mut self)
Reset the environment (clear all variables and re-register built-ins)
This is useful for engine pooling and global singleton patterns where you want to reuse an engine instance but ensure isolation.
Sourcepub fn set_global(&mut self, name: impl Into<String>, value: Value)
pub fn set_global(&mut self, name: impl Into<String>, value: Value)
Set a global variable from the host (without requiring eval).
Sourcepub fn enter_child_scope(&mut self) -> Rc<RefCell<Environment>>
pub fn enter_child_scope(&mut self) -> Rc<RefCell<Environment>>
Enter a child scope (new environment whose parent is the current env).
Returns the previous environment handle; pass it back to restore_env().
Sourcepub fn restore_env(&mut self, prev: Rc<RefCell<Environment>>)
pub fn restore_env(&mut self, prev: Rc<RefCell<Environment>>)
Restore a previously saved environment handle (typically from enter_child_scope()).
Sourcepub fn eval_program(&mut self, program: &Program) -> EvalResult
pub fn eval_program(&mut self, program: &Program) -> EvalResult
Evaluate a program
Sourcepub fn eval_statement(&mut self, stmt: &Stmt) -> EvalResult
pub fn eval_statement(&mut self, stmt: &Stmt) -> EvalResult
Evaluate a statement
Sourcepub fn eval_expression(&mut self, expr: &Expr) -> EvalResult
pub fn eval_expression(&mut self, expr: &Expr) -> EvalResult
Evaluate an expression