Struct lovm2_core::vm::Vm[][src]

pub struct Vm {
    pub load_paths: Vec<String>,
    // some fields omitted
}

VM structure containing hooks and loaded modules

Fields

load_paths: Vec<String>

List of directories for module lookup.

Implementations

impl Vm[src]

pub fn new() -> Self[src]

Create a new instance.

pub fn add_load_path(&mut self, path: String)[src]

Add a directory for module lookup.

pub fn call(&mut self, name: &str, args: &[Value]) -> Lovm2Result<Value>[src]

Call a function by name with given arguments.

pub fn context_mut(&mut self) -> &mut Context[src]

Get a mutable reference to the current Context

pub fn add_function<T: Into<Variable>>(
    &mut self,
    key: T,
    co: CallableRef
) -> Lovm2Result<()>
[src]

Add a new function by name to the virtual machine.

pub fn add_module<T>(&mut self, module: T, namespaced: bool) -> Lovm2Result<()> where
    T: Into<Module>, 
[src]

Add the module and all of its slots to scope.

pub fn add_module_by_name(
    &mut self,
    name: &str,
    relative_to: Option<String>,
    namespaced: bool
) -> Lovm2Result<()>
[src]

Lookup a module name in load_paths and add it to the context. relative_to is expected to be an absolute path to the imported module.

pub fn add_main_module<T>(&mut self, module: T) -> Lovm2Result<()> where
    T: Into<Module>, 
[src]

Add the module and all of its slots to scope.

pub fn run_object(&mut self, co: &dyn CallProtocol) -> Lovm2Result<Value>[src]

A wrapper for run_bytecode that handles pushing and popping stack frames.

pub fn run(&mut self) -> Lovm2Result<Value>[src]

Start the execution at ENTRY_POINT.

pub fn run_bytecode(
    &mut self,
    co: &CodeObject,
    offset: usize
) -> Lovm2Result<()>
[src]

implementation of lovm2 bytecode behavior

Note: This function does not push a stack frame and could therefore mess up local variables if not handled correctly. See Vm::run_object.

pub fn set_import_hook<T>(&mut self, hook: T) where
    T: Fn(Option<&str>, &str) -> Lovm2Result<Option<String>> + 'static, 
[src]

Register a new callback function that is used for patching function names.

pub fn set_load_hook<T>(&mut self, hook: T) where
    T: Fn(&LoadRequest) -> Lovm2Result<Option<Module>> + Sized + 'static, 
[src]

Register a new callback function that is used for resolving dependencies at runtime.

pub fn set_interrupt<T>(&mut self, n: u16, func: T) -> Lovm2Result<()> where
    T: Fn(&mut Vm) -> Lovm2Result<()> + Sized + 'static, 
[src]

Gegister a new callback function on interrupt n.

Auto Trait Implementations

impl !RefUnwindSafe for Vm[src]

impl !Send for Vm[src]

impl !Sync for Vm[src]

impl Unpin for Vm[src]

impl !UnwindSafe for Vm[src]

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.