VM

Struct VM 

Source
pub struct VM { /* private fields */ }

Implementations§

Source§

impl VM

Source

pub fn new() -> Self

Source

pub fn with_config(config: &LustConfig) -> Self

Source

pub fn with_current<F, R>(f: F) -> Result<R, String>
where F: FnOnce(&mut VM) -> Result<R, String>,

Source

pub fn load_functions(&mut self, functions: Vec<Function>)

Source

pub fn register_structs(&mut self, defs: &HashMap<String, StructDef>)

Source

pub fn instantiate_struct( &self, struct_name: &str, fields: Vec<(Rc<String>, Value)>, ) -> Result<Value>

Source

pub fn register_trait_impl(&mut self, type_name: String, trait_name: String)

Source

pub fn register_native(&mut self, name: impl Into<String>, value: Value)

Source

pub fn register_exported_native<F>(&mut self, export: NativeExport, func: F)
where F: Fn(&[Value]) -> Result<NativeCallResult, String> + 'static,

Source

pub fn exported_natives(&self) -> &[NativeExport]

Source

pub fn take_exported_natives(&mut self) -> Vec<NativeExport>

Source

pub fn clear_native_functions(&mut self)

Source

pub fn get_global(&self, name: &str) -> Option<Value>

Source

pub fn set_global(&mut self, name: impl Into<String>, value: Value)

Source

pub fn call(&mut self, function_name: &str, args: Vec<Value>) -> Result<Value>

Source§

impl VM

Source

pub fn value_to_string_for_concat( &mut self, value: &Value, ) -> Result<Rc<String>>

Source

pub fn call_value(&mut self, func: &Value, args: Vec<Value>) -> Result<Value>

Trait Implementations§

Source§

impl Default for VM

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for VM

§

impl !RefUnwindSafe for VM

§

impl !Send for VM

§

impl !Sync for VM

§

impl Unpin for VM

§

impl !UnwindSafe for VM

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where 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 T
where 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.