vermilion_vm

Struct VirtualMachine

Source
pub struct VirtualMachine {
    pub heap: Vec<u8>,
    pub stack: Vec<VermilionObject>,
    pub call_stack: Vec<i64>,
    pub symbols: HashMap<i64, VermilionSymbol>,
    pub sections: HashMap<i64, VermilionSection>,
    pub pc: usize,
    pub exit_code: Option<i64>,
}
Expand description

A Vermilion 2021 R2 compliant virtual machine.

Fields§

§heap: Vec<u8>

The memory accessible to the virtual machine. Due to restrictions in the Vermilion 2021 R2 specification, there is a maximum of 4 GB of memory available.

§stack: Vec<VermilionObject>

The stack, as specified in the Vermilion 2021 R2 specification.

§call_stack: Vec<i64>

A call stack, used for resolving where a return instruction should jump to.

§symbols: HashMap<i64, VermilionSymbol>

The list of symbols accessible to the virtual machine.

§sections: HashMap<i64, VermilionSection>

List of allocated memory sections

§pc: usize

The program counter, the current position in memory that the virtual machine is reading bytecode from.

§exit_code: Option<i64>

The exit code of the virtual machine.

Implementations§

Source§

impl VirtualMachine

An implementation of the Vermilion 2021 R2 specification.

Source

pub fn new() -> Self

Creates a new empty virtual machine.

Source

pub fn call_function_id(&mut self, id: i64)

Calls a function based on its symbol ID.

Source

pub fn call_function(&mut self, name: String)

Calls an internal function.

Source

pub fn run(&mut self)

Runs the instructions in memory, starting at the program counter.

Auto Trait Implementations§

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.