Struct fn_vm::VM

source ·
pub struct VM<T: Clone + VMValue<T> + Default + PartialEq> {
    pub fp: usize,
    pub frames: Vec<Frame<T>>,
    pub functions: Vec<VMFunction<T>>,
    pub registers: HashMap<Length, T>,
    pub index_registers: HashMap<Length, Length>,
    pub stack: Vec<usize>,
    pub program_data: Bytes,
    pub hcf_trigger: Option<fn(_: &mut VM<T>) -> Result<(), VMError>>,
}

Fields§

§fp: usize§frames: Vec<Frame<T>>§functions: Vec<VMFunction<T>>§registers: HashMap<Length, T>§index_registers: HashMap<Length, Length>§stack: Vec<usize>§program_data: Bytes§hcf_trigger: Option<fn(_: &mut VM<T>) -> Result<(), VMError>>

Implementations§

source§

impl<T: Clone + VMValue<T> + Default + PartialEq> VM<T>

source

pub fn empty() -> VM<T>

source

pub fn pc(&mut self) -> usize

source

pub fn pc_set(&mut self, new: usize) -> usize

source

pub fn instructions(&mut self) -> &Vec<u8>

source

pub fn instruction(&mut self, index: usize) -> u8

source

pub fn get_local(&mut self, fp: usize, var: String) -> Result<T, VMError>

source

pub fn local_exists(&mut self, fp: usize, var: &String) -> (bool, usize)

source

pub fn set_local( &mut self, fp: usize, var: String, value: T, ) -> Result<(), VMError>

source

pub fn set_mutable_local( &mut self, fp: usize, var: String, value: T, ) -> Result<(), VMError>

source

pub fn remove_register(&mut self, index: &Length) -> Result<T, VMError>

source

pub fn remove_index_register( &mut self, index: &Length, ) -> Result<Length, VMError>

source

pub fn run(&mut self) -> Result<(), VMError>

source

pub fn next_str(&mut self) -> String

source

pub fn set_register_value(&mut self, register: Length, value: T) -> &mut Self

source

pub fn set_index_register_value( &mut self, register: Length, value: Length, ) -> &mut Self

source

pub fn next_len(&mut self) -> Length

source

pub fn next_byte(&mut self) -> u8

source

pub fn next_n_bytes<const N: usize>(&mut self) -> [u8; N]

source

pub fn next_n_bytes_vec(&mut self, n: Length) -> Vec<u8>

Auto Trait Implementations§

§

impl<T> !Freeze for VM<T>

§

impl<T> RefUnwindSafe for VM<T>
where T: RefUnwindSafe,

§

impl<T> Send for VM<T>
where T: Send,

§

impl<T> Sync for VM<T>
where T: Sync,

§

impl<T> Unpin for VM<T>
where T: Unpin,

§

impl<T> UnwindSafe for VM<T>
where T: UnwindSafe,

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>,

§

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>,

§

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.