Struct lucia_lang::lvm::Lvm

source ·
pub struct Lvm {
    pub global_variables: HashMap<String, Value>,
    pub builtin_variables: HashMap<String, Value>,
    pub libs: HashMap<String, Value>,
    pub current_frame: Option<NonNull<Frame>>,
    /* private fields */
}
Expand description

The Lucia virtual machine.

Fields§

§global_variables: HashMap<String, Value>§builtin_variables: HashMap<String, Value>§libs: HashMap<String, Value>§current_frame: Option<NonNull<Frame>>

Implementations§

source§

impl Lvm

source

pub fn new() -> Self

Constructs a new Lvm.

source

pub fn run(&mut self, code: Code) -> Result<Value>

Execute a Code.

source

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

Call a callable Value with arguments.

source

pub fn set_global_variable(&mut self, key: String, value: Value)

Set the value of global variable.

source

pub fn get_global_variable(&self, key: &str) -> Option<Value>

Get the value of global variable.

source

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

Get the value of builtin variable.

source

pub fn get_builtin_str(&mut self, key: &str) -> Value

Get a builtin str.

source

pub fn iter_table(&mut self, table_value: Value) -> Value

Return an iterator Value from a Table Value.

source

pub fn new_gc_object<T: Trace + 'static>(&mut self, value: T) -> Gc<T>

Constructs a new Gc<T>.

source

pub fn new_str_value(&mut self, value: String) -> Value

source

pub fn new_table_value(&mut self, value: Table) -> Value

source

pub fn new_userdata_value(&mut self, value: UserData) -> Value

source

pub fn new_closure_value(&mut self, value: Closure) -> Value

source

pub fn new_ext_closure_value(&mut self, value: ExtClosure) -> Value

source

pub fn traceback(&self) -> Vec<TracebackFrame>

Get the traceback info of current stack frame.

source

pub unsafe fn gc(&mut self)

Run the garbage collection.

Safety

When calling this method, you have to ensure that all of Gc<T> can be traced by the root on stack frame.

Trait Implementations§

source§

impl Default for Lvm

source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl !RefUnwindSafe for Lvm

§

impl !Send for Lvm

§

impl !Sync for Lvm

§

impl Unpin for Lvm

§

impl !UnwindSafe for Lvm

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.