Struct runestick::Context[][src]

pub struct Context { /* fields omitted */ }

Static run context visible to the virtual machine.

This contains:

  • Declared functions.
  • Declared instance functions.
  • Type definitions.

Implementations

impl Context[src]

pub fn new() -> Self[src]

Construct a new empty collection of functions.

pub fn with_config(stdio: bool) -> Result<Self, ContextError>[src]

Construct a default set of modules with the given configuration.

  • stdio determines if we include I/O functions that interact with stdout and stderr by default, like dbg, print, and println.

pub fn runtime(&self) -> RuntimeContext[src]

Construct a runtime context used when executing the virtual machine.

use runestick::{Context, Vm, Unit};
use std::sync::Arc;

let context = Context::with_default_modules()?;

let runtime = Arc::new(context.runtime());
let unit = Arc::new(Unit::default());

let vm = Vm::new(runtime, unit);

pub fn type_check_for(&self, item: &Item) -> Option<TypeCheck>[src]

Use the specified type check.

pub fn with_default_modules() -> Result<Self, ContextError>[src]

Construct a new collection of functions with default packages installed.

pub fn contains_crate(&self, name: &str) -> bool[src]

Check if context contains the given crate.

pub fn has_default_modules(&self) -> bool[src]

Test if the context has the default modules installed.

This determines among other things whether a prelude should be used or not.

pub fn iter_components<'a, I: 'a>(
    &'a self,
    iter: I
) -> impl Iterator<Item = ComponentRef<'a>> + 'a where
    I: IntoIterator,
    I::Item: IntoComponent
[src]

Iterate over known child components of the given name.

pub fn unit_type(&self) -> Option<Hash>[src]

Access the currently known unit type.

pub fn contains_name(&self, item: &Item) -> bool[src]

Check if unit contains the given name.

pub fn contains_prefix(&self, item: &Item) -> bool[src]

Check if unit contains the given name by prefix.

pub fn lookup(
    &self,
    hash: Hash
) -> Option<&Arc<dyn Fn(&mut Stack, usize) -> Result<(), VmError> + Send + Sync>>
[src]

Lookup the given native function handler in the context.

pub fn lookup_macro(
    &self,
    hash: Hash
) -> Option<&Arc<dyn Fn(&dyn Any) -> Result<Box<dyn Any>, Error> + Send + Sync>>
[src]

Lookup the given macro handler.

pub fn lookup_meta(&self, name: &Item) -> Option<CompileMeta>[src]

Access the meta for the given language item.

pub fn iter_functions(&self) -> impl Iterator<Item = (Hash, &ContextSignature)>[src]

Iterate over all available functions

pub fn iter_types(&self) -> impl Iterator<Item = (Hash, &ContextTypeInfo)>[src]

Iterate over all available types.

pub fn install(&mut self, module: &Module) -> Result<(), ContextError>[src]

Install the specified module.

Trait Implementations

impl Debug for Context[src]

impl Default for Context[src]

Auto Trait Implementations

impl !RefUnwindSafe for Context

impl Send for Context

impl Sync for Context

impl Unpin for Context

impl !UnwindSafe for Context

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.