Struct Context

Source
pub struct Context { /* private fields */ }
Expand description

The state of the virtual machine

This contains all necessary runtime data and gets shared with objects that implement CallProtocol as well as interrupts.

Implementations§

Source§

impl Context

Source

pub fn new() -> Self

Source

pub fn lookup_code_object(&self, name: &Variable) -> Lovm2Result<CallableRef>

Try to resolve the given name to a callable

Source

pub fn stack_mut(&mut self) -> &mut Vec<Value>

Get a mutable reference to the value stack itself

Source

pub fn lstack_mut(&mut self) -> &mut Vec<Frame>

Get a mutable reference to the value lstack itself

Source

pub fn frame_mut(&mut self) -> Lovm2Result<&mut Frame>

Get a mutable reference to the last stack frame

Source

pub fn set_global<T>(&mut self, var: T, val: Value)
where T: AsRef<str>,

Set value of a global variable

Source

pub fn push_frame(&mut self, argn: u8)

Create a frame on the callstack

Source

pub fn pop_frame(&mut self)

Remove a frame from the callstack

Source

pub fn push_value(&mut self, value: Value)

Put a new value on the stack

Source

pub fn pop_value(&mut self) -> Lovm2Result<Value>

Remove the last value on stack

Source

pub fn last_value_mut(&mut self) -> Lovm2Result<&mut Value>

Get a mutable reference to the last value on stack

Source

pub fn value_of<T>(&self, var: T) -> Lovm2Result<&Value>
where T: AsRef<str>,

Lookup a global value

Trait Implementations§

Source§

impl Debug for Context

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl Freeze for Context

§

impl !RefUnwindSafe for Context

§

impl !Send for Context

§

impl !Sync for Context

§

impl Unpin for Context

§

impl !UnwindSafe for Context

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.