GeneralInterpreter

Trait GeneralInterpreter 

Source
pub trait GeneralInterpreter {
    type Value: Clone + ValueTrait + Debug;

    // Required methods
    fn interpret_expr(
        &mut self,
        ctx: &mut Context<Self::Value>,
        expr: ExprNodeId,
    ) -> Self::Value;
    fn get_empty_val(&self) -> Self::Value;

    // Provided methods
    fn deref_store(&self, val: &Self::Value) -> Self::Value { ... }
    fn wrap_store(&self, val: Self::Value) -> Self::Value { ... }
    fn eval_in_new_env(
        &mut self,
        binds: &[(Symbol, Self::Value)],
        ctx: &mut Context<Self::Value>,
        e: ExprNodeId,
    ) -> Self::Value { ... }
    fn eval_with_closure_env(
        &mut self,
        binds: &[(Symbol, (Self::Value, TypeNodeId))],
        ctx: Context<Self::Value>,
        e: ExprNodeId,
    ) -> Self::Value { ... }
    fn eval(
        &mut self,
        ctx: &mut Context<Self::Value>,
        expr: ExprNodeId,
    ) -> Self::Value { ... }
}
Expand description

Trait for defining general reduction rules of Lambda calculus, independent of the primitive types, even if it is untyped.

Required Associated Types§

Required Methods§

Source

fn interpret_expr( &mut self, ctx: &mut Context<Self::Value>, expr: ExprNodeId, ) -> Self::Value

Source

fn get_empty_val(&self) -> Self::Value

Provided Methods§

Source

fn deref_store(&self, val: &Self::Value) -> Self::Value

Helper method to dereference Store values. Override this for types that support Store.

Source

fn wrap_store(&self, val: Self::Value) -> Self::Value

Helper method to wrap values in Store. Override this for types that support Store.

Source

fn eval_in_new_env( &mut self, binds: &[(Symbol, Self::Value)], ctx: &mut Context<Self::Value>, e: ExprNodeId, ) -> Self::Value

Source

fn eval_with_closure_env( &mut self, binds: &[(Symbol, (Self::Value, TypeNodeId))], ctx: Context<Self::Value>, e: ExprNodeId, ) -> Self::Value

Source

fn eval( &mut self, ctx: &mut Context<Self::Value>, expr: ExprNodeId, ) -> Self::Value

Implementors§