nu_engine/
eval_helpers.rsuse crate::{
eval_block, eval_block_with_early_return, eval_expression, eval_expression_with_input,
eval_ir_block, eval_subexpression,
};
use nu_protocol::{
ast::{Block, Expression},
debugger::{WithDebug, WithoutDebug},
engine::{EngineState, Stack},
PipelineData, ShellError, Value,
};
pub type EvalBlockFn =
fn(&EngineState, &mut Stack, &Block, PipelineData) -> Result<PipelineData, ShellError>;
pub type EvalIrBlockFn =
fn(&EngineState, &mut Stack, &Block, PipelineData) -> Result<PipelineData, ShellError>;
pub type EvalBlockWithEarlyReturnFn =
fn(&EngineState, &mut Stack, &Block, PipelineData) -> Result<PipelineData, ShellError>;
pub type EvalExpressionFn = fn(&EngineState, &mut Stack, &Expression) -> Result<Value, ShellError>;
pub type EvalExpressionWithInputFn =
fn(&EngineState, &mut Stack, &Expression, PipelineData) -> Result<PipelineData, ShellError>;
pub type EvalSubexpressionFn =
fn(&EngineState, &mut Stack, &Block, PipelineData) -> Result<PipelineData, ShellError>;
pub fn get_eval_block(engine_state: &EngineState) -> EvalBlockFn {
if engine_state.is_debugging() {
eval_block::<WithDebug>
} else {
eval_block::<WithoutDebug>
}
}
pub fn get_eval_ir_block(engine_state: &EngineState) -> EvalIrBlockFn {
if engine_state.is_debugging() {
eval_ir_block::<WithDebug>
} else {
eval_ir_block::<WithoutDebug>
}
}
pub fn get_eval_block_with_early_return(engine_state: &EngineState) -> EvalBlockWithEarlyReturnFn {
if engine_state.is_debugging() {
eval_block_with_early_return::<WithDebug>
} else {
eval_block_with_early_return::<WithoutDebug>
}
}
pub fn get_eval_expression(engine_state: &EngineState) -> EvalExpressionFn {
if engine_state.is_debugging() {
eval_expression::<WithDebug>
} else {
eval_expression::<WithoutDebug>
}
}
pub fn get_eval_expression_with_input(engine_state: &EngineState) -> EvalExpressionWithInputFn {
if engine_state.is_debugging() {
eval_expression_with_input::<WithDebug>
} else {
eval_expression_with_input::<WithoutDebug>
}
}
pub fn get_eval_subexpression(engine_state: &EngineState) -> EvalSubexpressionFn {
if engine_state.is_debugging() {
eval_subexpression::<WithDebug>
} else {
eval_subexpression::<WithoutDebug>
}
}