pub struct GlobalRuntimeState {
    pub lib: StaticVec<Shared<Module>>,
    pub source: Option<ImmutableString>,
    pub num_operations: u64,
    pub num_modules_loaded: usize,
    pub level: usize,
    pub scope_level: usize,
    pub always_search_scope: bool,
    pub embedded_module_resolver: Option<Shared<StaticModuleResolver>>,
    pub constants: Option<Shared<Locked<BTreeMap<ImmutableString, Dynamic>>>>,
    pub tag: Dynamic,
    /* private fields */
}
Expand description

(internals) Global runtime states. Exported under the internals feature only.

Fields§

§lib: StaticVec<Shared<Module>>

The current stack of loaded modules containing script-defined functions.

§source: Option<ImmutableString>

Source of the current context.

No source if the string is empty.

§num_operations: u64

Number of operations performed.

§num_modules_loaded: usize

Number of modules loaded.

§level: usize

The current nesting level of function calls.

§scope_level: usize

Level of the current scope.

The global (root) level is zero, a new block (or function call) is one level higher, and so on.

§always_search_scope: bool

Force a Scope search by name.

Normally, access to variables are parsed with a relative offset into the Scope to avoid a lookup.

In some situation, e.g. after running an eval statement, or after a custom syntax statement, subsequent offsets may become mis-aligned.

When that happens, this flag is turned on.

§embedded_module_resolver: Option<Shared<StaticModuleResolver>>

Embedded module resolver.

§constants: Option<Shared<Locked<BTreeMap<ImmutableString, Dynamic>>>>

Cache of globally-defined constants.

Interior mutability is needed because it is shared in order to aid in cloning.

§tag: Dynamic

Custom state that can be used by the external host.

Implementations§

source§

impl GlobalRuntimeState

source

pub fn new(engine: &Engine) -> Self

Create a new GlobalRuntimeState based on an Engine.

source

pub fn num_imports(&self) -> usize

Get the length of the stack of globally-imported modules.

Not available under no_module.

source

pub fn get_shared_import(&self, index: usize) -> Option<Shared<Module>>

Get the globally-imported module at a particular index.

Not available under no_module.

source

pub fn find_import(&self, name: &str) -> Option<usize>

Get the index of a globally-imported module by name.

Not available under no_module.

source

pub fn push_import( &mut self, name: impl Into<ImmutableString>, module: impl Into<Shared<Module>> )

Push an imported module onto the stack.

Not available under no_module.

source

pub fn truncate_imports(&mut self, size: usize)

Truncate the stack of globally-imported modules to a particular length.

Not available under no_module.

source

pub fn iter_imports(&self) -> impl Iterator<Item = (&str, &Module)>

Get an iterator to the stack of globally-imported modules in reverse order.

Not available under no_module.

source

pub fn scan_imports_raw( &self ) -> impl Iterator<Item = (&ImmutableString, &Shared<Module>)>

Get an iterator to the stack of globally-imported modules in forward order.

Not available under no_module.

source

pub fn contains_qualified_fn(&self, hash: u64) -> bool

Does the specified function hash key exist in the stack of globally-imported modules?

Not available under no_module.

source

pub fn get_qualified_fn( &self, hash: u64, global_namespace_only: bool ) -> Option<(&CallableFunction, Option<&ImmutableString>)>

Get the specified function via its hash key from the stack of globally-imported modules.

Not available under no_module.

source

pub fn contains_iter(&self, id: TypeId) -> bool

Does the specified TypeId iterator exist in the stack of globally-imported modules?

Not available under no_module.

source

pub fn get_iter( &self, id: TypeId ) -> Option<&dyn Fn(Dynamic) -> Box<dyn Iterator<Item = Result<Dynamic, Box<EvalAltResult>>>>>

Get the specified TypeId iterator from the stack of globally-imported modules.

Not available under no_module.

source

pub fn source(&self) -> Option<&str>

Get the current source.

source

pub fn debugger(&self) -> &Debugger

Return a reference to the debugging interface.

Panics

Panics if the debugging interface is not set.

source

pub fn debugger_mut(&mut self) -> &mut Debugger

Return a mutable reference to the debugging interface.

Panics

Panics if the debugging interface is not set.

Trait Implementations§

source§

impl Clone for GlobalRuntimeState

source§

fn clone(&self) -> GlobalRuntimeState

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for GlobalRuntimeState

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<K: Into<ImmutableString>, M: Into<Shared<Module>>> Extend<(K, M)> for GlobalRuntimeState

source§

fn extend<T: IntoIterator<Item = (K, M)>>(&mut self, iter: T)

Extends a collection with the contents of an iterator. Read more
source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Variant for Twhere T: Any + Clone + SendSync,

source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert this Variant trait object to &dyn Any.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert this Variant trait object to &mut dyn Any.
source§

fn as_boxed_any(self: Box<T, Global>) -> Box<dyn Any + 'static, Global>

Convert this Variant trait object to Box<dyn Any>.
source§

fn type_name(&self) -> &'static str

Get the name of this type.
source§

fn clone_object(&self) -> Box<dyn Variant + 'static, Global>

Clone this Variant trait object.