Struct lovm2_core::vm::Vm [−][src]
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]
&mut self,
key: T,
co: CallableRef
) -> Lovm2Result<()>
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]
T: Into<Module>,
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]
&mut self,
name: &str,
relative_to: Option<String>,
namespaced: bool
) -> Lovm2Result<()>
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]
T: Into<Module>,
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]
&mut self,
co: &CodeObject,
offset: usize
) -> Lovm2Result<()>
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]
T: Fn(Option<&str>, &str) -> Lovm2Result<Option<String>> + 'static,
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]
T: Fn(&LoadRequest) -> Lovm2Result<Option<Module>> + Sized + 'static,
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]
T: Fn(&mut Vm) -> Lovm2Result<()> + Sized + 'static,
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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,