Skip to main content

Eval

Trait Eval 

Source
pub trait Eval {
    type State<'a>: Copy + GetSpan;
    type MutState;

Show 13 methods // Required methods fn get_config( state: Self::State<'_>, mut_state: &mut Self::MutState, ) -> Arc<Config> ⓘ; fn eval_var( state: Self::State<'_>, mut_state: &mut Self::MutState, var_id: VarId, span: Span, ) -> Result<Value, ShellError>; fn eval_call<D: DebugContext>( state: Self::State<'_>, mut_state: &mut Self::MutState, call: &Call, span: Span, ) -> Result<Value, ShellError>; fn eval_external_call( state: Self::State<'_>, mut_state: &mut Self::MutState, head: &Expression, args: &[ExternalArgument], span: Span, ) -> Result<Value, ShellError>; fn eval_collect<D: DebugContext>( state: Self::State<'_>, mut_state: &mut Self::MutState, var_id: VarId, expr: &Expression, ) -> Result<Value, ShellError>; fn eval_subexpression<D: DebugContext>( state: Self::State<'_>, mut_state: &mut Self::MutState, block_id: BlockId, span: Span, ) -> Result<Value, ShellError>; fn regex_match( state: Self::State<'_>, op_span: Span, lhs: &Value, rhs: &Value, invert: bool, expr_span: Span, ) -> Result<Value, ShellError>; fn check_point_in_time( state: Self::State<'_>, rhs: &Value, expr_span: Span, ) -> Result<(), ShellError>; fn eval_assignment<D: DebugContext>( state: Self::State<'_>, mut_state: &mut Self::MutState, lhs: &Expression, rhs: &Expression, assignment: Assignment, op_span: Span, expr_span: Span, ) -> Result<Value, ShellError>; fn eval_row_condition_or_closure( state: Self::State<'_>, mut_state: &mut Self::MutState, block_id: BlockId, span: Span, ) -> Result<Value, ShellError>; fn eval_overlay( state: Self::State<'_>, span: Span, ) -> Result<Value, ShellError>; fn unreachable( state: Self::State<'_>, expr: &Expression, ) -> Result<Value, ShellError>; // Provided method fn eval<D: DebugContext>( state: Self::State<'_>, mut_state: &mut Self::MutState, expr: &Expression, ) -> Result<Value, ShellError> { ... }
}
Expand description

To share implementations for regular eval and const eval

Required Associated Types§

Source

type State<'a>: Copy + GetSpan

State that doesn’t need to be mutated. EngineState for regular eval and StateWorkingSet for const eval

Source

type MutState

State that needs to be mutated. This is the stack for regular eval, and unused by const eval

Required Methods§

Source

fn get_config( state: Self::State<'_>, mut_state: &mut Self::MutState, ) -> Arc<Config> ⓘ

Source

fn eval_var( state: Self::State<'_>, mut_state: &mut Self::MutState, var_id: VarId, span: Span, ) -> Result<Value, ShellError>

Source

fn eval_call<D: DebugContext>( state: Self::State<'_>, mut_state: &mut Self::MutState, call: &Call, span: Span, ) -> Result<Value, ShellError>

Source

fn eval_external_call( state: Self::State<'_>, mut_state: &mut Self::MutState, head: &Expression, args: &[ExternalArgument], span: Span, ) -> Result<Value, ShellError>

Source

fn eval_collect<D: DebugContext>( state: Self::State<'_>, mut_state: &mut Self::MutState, var_id: VarId, expr: &Expression, ) -> Result<Value, ShellError>

Source

fn eval_subexpression<D: DebugContext>( state: Self::State<'_>, mut_state: &mut Self::MutState, block_id: BlockId, span: Span, ) -> Result<Value, ShellError>

Source

fn regex_match( state: Self::State<'_>, op_span: Span, lhs: &Value, rhs: &Value, invert: bool, expr_span: Span, ) -> Result<Value, ShellError>

Source

fn check_point_in_time( state: Self::State<'_>, rhs: &Value, expr_span: Span, ) -> Result<(), ShellError>

Checks that this evaluator can compare against rhs with older-than or newer-than.

A duration on the right is counted back from the current time. Const evaluation runs while the script is parsed, so it can’t read the clock and refuses a duration.

§Arguments
  • rhs - The evaluated right operand
  • expr_span - Span of the whole comparison, used in errors
§Errors

Returns ShellError::NotAConstant when const evaluation meets a duration.

Source

fn eval_assignment<D: DebugContext>( state: Self::State<'_>, mut_state: &mut Self::MutState, lhs: &Expression, rhs: &Expression, assignment: Assignment, op_span: Span, expr_span: Span, ) -> Result<Value, ShellError>

Source

fn eval_row_condition_or_closure( state: Self::State<'_>, mut_state: &mut Self::MutState, block_id: BlockId, span: Span, ) -> Result<Value, ShellError>

Source

fn eval_overlay(state: Self::State<'_>, span: Span) -> Result<Value, ShellError>

Source

fn unreachable( state: Self::State<'_>, expr: &Expression, ) -> Result<Value, ShellError>

For expressions that should never actually be evaluated

Provided Methods§

Source

fn eval<D: DebugContext>( state: Self::State<'_>, mut_state: &mut Self::MutState, expr: &Expression, ) -> Result<Value, ShellError>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§