Evaluator

Struct Evaluator 

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

Evaluator for Aether programs

Implementations§

Source§

impl Evaluator

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