Evaluator

Struct Evaluator 

Source
pub struct Evaluator { /* private fields */ }
Expand description

Evaluator for Aether programs

Implementations§

Source§

impl Evaluator

Source

pub fn reset_step_counter(&mut self)

Reset execution step counter (host-facing).

This is intended to be called at the start of a top-level evaluation.

Source

pub fn step_count(&self) -> usize

Return the current execution step count.

Note: this counts evaluated statements (one increment per statement).

Source

pub fn set_source_file(&mut self, file: String)

Set the current source file (for debugger)

Source

pub fn get_source_file(&self) -> Option<&str>

Get the current source file (for debugger)

Source

pub fn set_current_line(&self, line: usize)

Set the current line number (for debugger)

Source

pub fn get_current_line(&self) -> usize

Get the current line number (for debugger)

Source

pub fn get_call_stack(&self) -> &[CallFrame]

Get the call stack (for debugger)

Source

pub fn get_call_stack_depth(&self) -> usize

Get call stack depth (for debugger)

Source

pub fn set_limits(&mut self, limits: ExecutionLimits)

Set execution limits (public API)

Source

pub fn limits(&self) -> &ExecutionLimits

Get execution limits (public API)

Source

pub fn new() -> Self

Create a new evaluator (默认禁用IO)

Source

pub fn with_permissions(permissions: IOPermissions) -> Self

Create a new evaluator with custom IO permissions

Source

pub fn with_permissions_and_trace_buffer( permissions: IOPermissions, trace_buffer_size: usize, ) -> Self

Create a new evaluator with custom IO permissions and trace buffer size

Source

pub fn with_env(env: Rc<RefCell<Environment>>) -> Self

Create evaluator with custom environment

Source

pub fn clear_call_stack(&mut self)

Clear the call stack (used by top-level entry points like Aether::eval).

Source

pub fn set_module_resolver(&mut self, resolver: Box<dyn ModuleResolver>)

Configure the module resolver used for Import/Export.

Source

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.

Source

pub fn pop_import_base(&mut self)

Pop the most recent base directory context.

Source

pub fn trace_push(&mut self, msg: String)

Append a trace entry (host-readable; no IO side effects).

Source

pub fn take_trace(&mut self) -> Vec<String>

Drain the trace buffer.

Source

pub fn trace_records(&self) -> Vec<TraceEntry>

Get all structured trace entries

Source

pub fn trace_by_level(&self, level: TraceLevel) -> Vec<TraceEntry>

Filter trace entries by level

Source

pub fn trace_by_category(&self, category: &str) -> Vec<TraceEntry>

Filter trace entries by category

Source

pub fn trace_by_label(&self, label: &str) -> Vec<TraceEntry>

Filter trace entries by label

Source

pub fn trace_since(&self, since: Instant) -> Vec<TraceEntry>

Filter trace entries by time range (since)

Source

pub fn trace_filter(&self, filter: &TraceFilter) -> Vec<TraceEntry>

Apply complex filter to trace entries

Source

pub fn trace_stats(&self) -> TraceStats

Get trace statistics

Source

pub fn clear_trace(&mut self)

Clear the trace buffer.

Source

pub fn set_trace_buffer_size(&mut self, size: usize)

Set the maximum number of trace entries to keep in buffer

If the new size is smaller than the current number of entries, excess entries will be removed from the front of the buffer.

Source

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.

Source

pub fn set_global(&mut self, name: impl Into<String>, value: Value)

Set a global variable from the host (without requiring eval).

Source

pub fn get_global(&self, name: &str) -> Option<Value>

Get a global variable value from the environment

Source

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().

Source

pub fn restore_env(&mut self, prev: Rc<RefCell<Environment>>)

Restore a previously saved environment handle (typically from enter_child_scope()).

Source

pub fn eval_program(&mut self, program: &Program) -> EvalResult

Evaluate a program

Source

pub fn eval_statement(&mut self, stmt: &Stmt) -> EvalResult

Evaluate a statement

Source

pub fn eval_expression(&mut self, expr: &Expr) -> EvalResult

Evaluate an expression

Trait Implementations§

Source§

impl Default for Evaluator

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.