Evaluator

Struct Evaluator 

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

Evaluator for Aether programs

Implementations§

Source§

impl Evaluator

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_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 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.