pub(crate) fn eval_script_expr_in_place(
        &self,
        scope: &mut Scope,
        global: &mut GlobalRuntimeState,
        caches: &mut Caches,
        lib: &[&Module],
        script: &str,
        _pos: Position,
        level: usize,
    ) -> RhaiResult {
        #[cfg(not(feature = "unchecked"))]
        self.inc_operations(&mut global.num_operations, _pos)?;

        let script = script.trim();

        if script.is_empty() {
            return Ok(Dynamic::UNIT);
        }

        // Compile the script text
        // No optimizations because we only run it once
        let ast = self.compile_with_scope_and_optimization_level(
            &Scope::new(),
            &[script],
            #[cfg(not(feature = "no_optimize"))]
            OptimizationLevel::None,
            #[cfg(feature = "no_optimize")]
            OptimizationLevel::default(),
        )?;

        // If new functions are defined within the eval string, it is an error
        #[cfg(not(feature = "no_function"))]
        if !ast.shared_lib().is_empty() {
            return Err(crate::PERR::WrongFnDefinition.into());
        }

        let statements = ast.statements();
        if statements.is_empty() {
            return Ok(Dynamic::UNIT);
        }

        // Evaluate the AST
        self.eval_global_statements(scope, global, caches, statements, lib, level)
    }
/// Evaluate a text script in place - used primarily for 'eval'.
Evaluate a text script in place - used primarily for 'eval'.
Evaluate a text script in place - used primarily for ' eval ' .
pub(crate) fn eval_script_expr_in_place(
        &self,
        scope: &mut Scope,
        global: &mut GlobalRuntimeState,
        caches: &mut Caches,
        lib: &[&Module],
        script: &str,
        _pos: Position,
        level: usize,
    ) -> RhaiResult {
        #[cfg(not(feature = "unchecked"))]
        self.inc_operations(&mut global.num_operations, _pos)?;
        let script = script.trim();
        if script.is_empty() {
            return Ok(Dynamic::UNIT);
        }
        // Compile the script text
        // No optimizations because we only run it once
        let ast = self.compile_with_scope_and_optimization_level(
            &Scope::new(),
            &[script],
            #[cfg(not(feature = "no_optimize"))]
            OptimizationLevel::None,
            #[cfg(feature = "no_optimize")]
            OptimizationLevel::default(),
        )?;
        // If new functions are defined within the eval string, it is an error
        #[cfg(not(feature = "no_function"))]
        if !ast.shared_lib().is_empty() {
            return Err(crate::PERR::WrongFnDefinition.into());
        }
        let statements = ast.statements();
        if statements.is_empty() {
            return Ok(Dynamic::UNIT);
        }
        // Evaluate the AST
        self.eval_global_statements(scope, global, caches, statements, lib, level)
    }
pub ( crate ) fn eval_script_expr_in_place ( & self , scope : & mut Scope , global : & mut GlobalRuntimeState , caches : & mut Caches , lib : & [ & Module ] , script : & str , _pos : Position , level : usize , ) -> RhaiResult { # [ cfg ( not ( feature " " ) ) ] self . inc_operations ( & mut global . num_operations , _pos ) ? ; let script = script . trim ( ) ; if script . is_empty ( ) { return Ok ( Dynamic :: UNIT ) ; } // Compile the script text // No optimizations because we only run it once let ast = self . compile_with_scope_and_optimization_level ( & Scope :: new ( ) , & [ script ] , # [ cfg ( not ( feature " " ) ) ] OptimizationLevel :: None , # [ cfg ( feature " " ) ] OptimizationLevel :: default ( ) , ) ? ; // If new functions are defined within the eval string, it is an error # [ cfg ( not ( feature " " ) ) ] if ! ast . shared_lib ( ) . is_empty ( ) { return Err ( crate :: PERR :: WrongFnDefinition . into ( ) ) ; } let statements = ast . statements ( ) ; if statements . is_empty ( ) { return Ok ( Dynamic :: UNIT ) ; } // Evaluate the AST self . eval_global_statements ( scope , global , caches , statements , lib , level ) }
Evaluate a text script in place - used primarily for 'eval'.
Evaluate a text script in place - used primarily for ' eval ' .
&self
scope
&mut Scope
global
&mut GlobalRuntimeState
caches
&mut Caches
lib
&[&Module]
script
&str
_pos
Position
level
usize