pub struct Strontium {
    pub registers: Registers,
    pub ip: usize,
    pub call_stack: Vec<u8>,
    /* private fields */
}

Fields§

§registers: Registers

Holds general-purpose registers for storing different types of values

§ip: usize

Points to the next index in the buffer of the bytecode register.

§call_stack: Vec<u8>

Contains references for function arguments and return values

Implementations§

source§

impl Strontium

source

pub fn new() -> Self

Create a new instance of the virtual machine

source

pub fn push_bytecode(&mut self, bytes: Vec<u8>)

Append machine code to the array in the bytecode register.

source

pub fn execute( &mut self, instruction: Instruction ) -> Result<bool, StrontiumError>

Execute a single instruction.

source

pub fn consume_u64(&mut self) -> Result<u64, StrontiumError>

Consume an unsigned 64-bit integer from the bytecode register.

This performs a lookahead on the bytecode register to read the next eight bytes and converts the bytes into a 64-bit integer value. The byte encoding within Strontium bytecode is always Little Endian.

source

pub fn consume_u32(&mut self) -> Result<u32, StrontiumError>

source

pub fn consume_u16(&mut self) -> Result<u16, StrontiumError>

source

pub fn consume_u8(&mut self) -> Result<u8, StrontiumError>

source

pub fn consume_i64(&mut self) -> Result<i64, StrontiumError>

source

pub fn consume_i32(&mut self) -> Result<i32, StrontiumError>

source

pub fn consume_i16(&mut self) -> Result<i16, StrontiumError>

source

pub fn consume_i8(&mut self) -> Result<i8, StrontiumError>

source

pub fn consume_f64(&mut self) -> Result<f64, StrontiumError>

source

pub fn consume_f32(&mut self) -> Result<f32, StrontiumError>

source

pub fn consume_bool(&mut self) -> Result<bool, StrontiumError>

source

pub fn consume_byte(&mut self) -> Result<u8, StrontiumError>

source

pub fn consume_string(&mut self) -> Result<String, StrontiumError>

Auto Trait Implementations§

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,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.