EvalContext

Many functions in advanced API’s contain a parameter of type EvalContext in order to allow the current evaluation state to be accessed and/or modified.

EvalContext encapsulates the current evaluation context and exposes the following methods.

MethodReturn typeDescription
scope()&Scopereference to the current Scope
scope_mut()&mut &mut Scopemutable reference to the current Scope; variables can be added to/removed from it
engine()&Enginereference to the current Engine
source()Option<&str>reference to the current source, if any
tag()&Dynamicreference to the custom state that is persistent during the current run
tag_mut()&mut Dynamicmutable reference to the custom state that is persistent during the current run
iter_imports()impl Iterator<Item = (&str,&Module)>iterator of the current stack of modules imported via import statements, in reverse order (i.e. later modules come first); not available under no_module
global_runtime_state()&GlobalRuntimeStatereference to the current global runtime state (including the stack of modules imported via import statements)
global_runtime_state_mut()&mut &mut GlobalRuntimeStatemutable reference to the current global runtime state; use this to access the debugger field in order to set/clear break-points
iter_namespaces()impl Iterator<Item =&Module>iterator of the namespaces (as modules) containing all script-defined functions, in reverse order (i.e. later modules come first)
namespaces()&[&Module]reference to the namespaces (as modules) containing all script-defined functions
this_ptr()Option<&Dynamic>reference to the current bound this pointer, if any
this_ptr_mut()&mut Option<&mut Dynamic>mutable reference to the current bound this pointer, if any
call_level()usizethe current nesting level of function calls