[−][src]Struct itsy::bytecode::VM
A virtual machine for running Itsy bytecode.
Fields
stack: Stack
heap: Heap
Methods
impl<T, U> VM<T, U> where
T: VMFunc<T> + VMData<T, U>,
U: Default,
[src]
T: VMFunc<T> + VMData<T, U>,
U: Default,
Public VM methods.
pub fn new(program: Program<T>) -> Self
[src]
Create a new VM instance with the given Program.
pub fn reset(&mut self)
[src]
Resets the VM, keeping only code and constants.
pub fn dump_program(&mut self) -> String
[src]
Disassembles the bytecode and returns it as a string.
pub fn dump_instruction(&mut self) -> Option<String>
[src]
Disassembles the current bytecode instruction and returns it as a string.
pub fn dump_stack(&self) -> String
[src]
Returns the current stack as a string.
pub fn dump_frame(&self) -> String
[src]
Returns the current stack-frame as a string.
pub fn run(&mut self) -> &mut Self
[src]
Executes bytecode until it terminates.
pub fn state(&self) -> VMState
[src]
Returns the current VM state.
pub fn context(&mut self) -> &mut U
[src]
Returns a reference to the custom context.
pub fn into_context(self) -> U
[src]
Destroys the VM and returns its custom context.
impl<T, U> VM<T, U> where
T: VMFunc<T> + VMData<T, U>,
U: Default,
[src]
T: VMFunc<T> + VMData<T, U>,
U: Default,
Bytecode instructions. Implemented on VM by the impl_vm!
macro.
pub fn debug(&mut self, label: u32)
[src]
Does nothing. Used as label when debugging.
pub fn reserve(&mut self, num_items: u8)
[src]
Moves the stack pointer by given number of items (32bit words) to make room for local variables.
pub fn constr16(&mut self, const_id: u8)
[src]
Load 2 byte from constant pool onto stack.
pub fn constr16_16(&mut self, const_id: u16)
[src]
Load 2 byte from constant pool onto stack.
pub fn constr32(&mut self, const_id: u8)
[src]
Load 4 byte from constant pool onto stack.
pub fn constr32_16(&mut self, const_id: u16)
[src]
Load 4 byte from constant pool onto stack.
pub fn constr64(&mut self, const_id: u8)
[src]
Load 8 byte from constant pool onto stack.
pub fn constr64_16(&mut self, const_id: u16)
[src]
Load 8 byte from constant pool onto stack.
pub fn consto(&mut self, const_id: u8)
[src]
Load object from constant pool onto stack+heap.
pub fn consto_16(&mut self, const_id: u16)
[src]
Load object from constant pool onto stack+heap.
pub fn litu(&mut self, value: u8)
[src]
Push value onto stack.
pub fn lits(&mut self, value: i8)
[src]
Push value onto stack.
pub fn lit0(&mut self)
[src]
Push 0 onto stack.
pub fn lit1(&mut self)
[src]
Push 1 onto stack.
pub fn lit2(&mut self)
[src]
Push 2 onto stack.
pub fn litm1(&mut self)
[src]
Push -1 onto stack.
pub fn loadr32(&mut self, offset: i32)
[src]
Load stackvalue from offset (relative to the stackframe) and push onto the stack.
pub fn storer32(&mut self, offset: i32)
[src]
Pop stackvalue and store it at the given offset (relative to the stackframe).
pub fn loadr64(&mut self, offset: i32)
[src]
Load 64 bit stackvalue from offset (relative to the stackframe) and push onto the stack.
pub fn storer64(&mut self, offset: i32)
[src]
Pop 64 bit stackvalue and store it at the given offset (relative to the stackframe).
pub fn load_arg1(&mut self)
[src]
Load function argument 1 and push it onto the stack. Equivalent to load -4.
pub fn load_arg2(&mut self)
[src]
Load function argument 2 and push it onto the stack. Equivalent to load -5.
pub fn load_arg3(&mut self)
[src]
Load function argument 3 and push it onto the stack. Equivalent to load -6.
pub fn rustcall(&mut self, func: u16)
[src]
Calls the given Rust function.
pub fn call(&mut self, addr: u32, num_args: u8)
[src]
Function call. Saves state and sets programm counter to given addr. Expects callee arguments on the stack and number of arguments (in 32 bit words) as num_args.
pub fn ret(&mut self, num_ret: u8)
[src]
Function return. Restores state, removes arguments left on stack by caller and leaves call result on the stack.
pub fn and(&mut self)
[src]
Pops 2 values from the stack and pushes their logical conjunction.
pub fn or(&mut self)
[src]
Pops 2 values from the stack and pushes their logical disjunction.
pub fn not(&mut self)
[src]
Pops a values from the stack and pushes its logical negation.
pub fn addi(&mut self)
[src]
Pops 2 values from the stack and pushes their sum.
pub fn subi(&mut self)
[src]
Pops 2 values from the stack and pushes their difference.
pub fn muli(&mut self)
[src]
Pops 2 values from the stack and pushes their product.
pub fn addf(&mut self)
[src]
Pops 2 values from the stack and pushes their sum.
pub fn subf(&mut self)
[src]
Pops 2 values from the stack and pushes their sum.
pub fn mulf(&mut self)
[src]
Pops 2 values from the stack and pushes their product.
pub fn addi64(&mut self)
[src]
Pops 2 values from the stack and pushes their sum.
pub fn subi64(&mut self)
[src]
Pops 2 values from the stack and pushes their difference.
pub fn muli64(&mut self)
[src]
Pops 2 values from the stack and pushes their product.
pub fn addf64(&mut self)
[src]
Pops 2 values from the stack and pushes their sum.
pub fn subf64(&mut self)
[src]
Pops 2 values from the stack and pushes their sum.
pub fn mulf64(&mut self)
[src]
Pops 2 values from the stack and pushes their product.
pub fn jmp(&mut self, addr: u32)
[src]
Jumps unconditionally to the given address.
pub fn j0(&mut self, addr: u32)
[src]
Pops one values and jumps to given address if it is 0.
pub fn jeqr32(&mut self, addr: u32)
[src]
Pops two values and jumps to given address it they equal.
pub fn jeqr64(&mut self, addr: u32)
[src]
Pops two values and jumps to given address it they equal.
pub fn jneqr32(&mut self, addr: u32)
[src]
Pops two values and jumps to given address it they are not equal.
pub fn jneqr64(&mut self, addr: u32)
[src]
Pops two values and jumps to given address it they are not equal.
pub fn jlts32(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less than the second.
pub fn jltu32(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less than the second.
pub fn jltf32(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less than the second.
pub fn jlts64(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less than the second.
pub fn jltu64(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less than the second.
pub fn jltf64(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less than the second.
pub fn jltes32(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less/equal the second.
pub fn jlteu32(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less/equal the second.
pub fn jltef32(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less/equal the second.
pub fn jltes64(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less/equal the second.
pub fn jlteu64(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less/equal the second.
pub fn jltef64(&mut self, addr: u32)
[src]
Pops two values and jumps to given address if the first value is less/equal the second.
pub fn ceqr32(&mut self)
[src]
Pops two values and pushes a 1 if the first value equals the second, otherwise a 0.
pub fn ceqr64(&mut self)
[src]
Pops two values and pushes a 1 if the first value equals the second, otherwise a 0.
pub fn cneqr32(&mut self)
[src]
Pops two values and pushes a 1 if the first value does not equal the second, otherwise a 0.
pub fn cneqr64(&mut self)
[src]
Pops two values and pushes a 1 if the first value does not equal the second, otherwise a 0.
pub fn clts32(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser than the second, otherwise a 0.
pub fn cltu32(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser than the second, otherwise a 0.
pub fn cltf32(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser than the second, otherwise a 0.
pub fn clts64(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser than the second, otherwise a 0.
pub fn cltu64(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser than the second, otherwise a 0.
pub fn cltf64(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser than the second, otherwise a 0.
pub fn cltes32(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser or equal the second, otherwise a 0.
pub fn clteu32(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser or equal the second, otherwise a 0.
pub fn cltef32(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser or equal the second, otherwise a 0.
pub fn cltes64(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser or equal the second, otherwise a 0.
pub fn clteu64(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser or equal the second, otherwise a 0.
pub fn cltef64(&mut self)
[src]
Pops two values and pushes a 1 if the first value is lesser or equal the second, otherwise a 0.
pub fn inci(&mut self)
[src]
Increments the value at the top of the stack.
pub fn deci(&mut self)
[src]
Decrements the value at the top of the stack.
pub fn inci64(&mut self)
[src]
Increments the value at the top of the stack.
pub fn deci64(&mut self)
[src]
Decrements the value at the top of the stack.
pub fn preinci(&mut self, offset: i32)
[src]
Increments the stackvalue at given offset (relative to the stackframe) and pushes the result onto the stack.
pub fn predeci(&mut self, offset: i32)
[src]
Decrements the stackvalue at given offset (relative to the stackframe) and pushes the result onto the stack.
pub fn preinci64(&mut self, offset: i32)
[src]
Increments the stackvalue at given offset (relative to the stackframe) and pushes the result onto the stack.
pub fn predeci64(&mut self, offset: i32)
[src]
Decrements the stackvalue at given offset (relative to the stackframe) and pushes the result onto the stack.
pub fn postinci(&mut self, offset: i32)
[src]
Increments the stackvalue at given offset (relative to the stackframe) and pushes the previous value onto the stack.
pub fn postdeci(&mut self, offset: i32)
[src]
Decrements the stackvalue at given offset (relative to the stackframe) and pushes the previous value onto the stack.
pub fn postinci64(&mut self, offset: i32)
[src]
Increments the stackvalue at given offset (relative to the stackframe) and pushes the previous value onto the stack.
pub fn postdeci64(&mut self, offset: i32)
[src]
Decrements the stackvalue at given offset (relative to the stackframe) and pushes the previous value onto the stack.
pub fn yld(&mut self)
[src]
Yield program execution.
pub fn exit(&mut self)
[src]
Terminate program execution.
Trait Implementations
impl<T: Debug, U: Debug> Debug for VM<T, U> where
T: VMFunc<T>,
U: Default,
[src]
T: VMFunc<T>,
U: Default,
impl<T, U> Read for VM<T, U> where
T: VMFunc<T>,
U: Default,
[src]
T: VMFunc<T>,
U: Default,
fn read(&mut self, buf: &mut [u8]) -> Result<usize>
[src]
fn read_exact(&mut self, buf: &mut [u8]) -> Result<()>
[src]
fn read_vectored(&mut self, bufs: &mut [IoVecMut]) -> Result<usize, Error>
[src]
iovec
)Like read
, except that it reads into a slice of buffers. Read more
unsafe fn initializer(&self) -> Initializer
[src]
read_initializer
)Determines if this Read
er can work with buffers of uninitialized memory. Read more
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
Read all bytes until EOF in this source, placing them into buf
. Read more
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
Read all bytes until EOF in this source, appending them to buf
. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Creates a "by reference" adaptor for this instance of Read
. Read more
fn bytes(self) -> Bytes<Self>
1.0.0[src]
Transforms this Read
instance to an [Iterator
] over its bytes. Read more
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
Creates an adaptor which will chain this stream with another. Read more
fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
Creates an adaptor which will read at most limit
bytes from it. Read more
Auto Trait Implementations
impl<T, U> Send for VM<T, U> where
T: Send,
U: Send,
T: Send,
U: Send,
impl<T, U> Sync for VM<T, U> where
T: Sync,
U: Sync,
T: Sync,
U: Sync,
Blanket Implementations
impl<T, U> Into for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From for T
[src]
impl<T, U> TryFrom for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T> Borrow for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> BorrowMut for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> TryInto for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<R> ReadBytesExt for R where
R: Read + ?Sized,
[src]
R: Read + ?Sized,
fn read_u8(&mut self) -> Result<u8, Error>
[src]
Reads an unsigned 8 bit integer from the underlying reader. Read more
fn read_i8(&mut self) -> Result<i8, Error>
[src]
Reads a signed 8 bit integer from the underlying reader. Read more
fn read_u16<T>(&mut self) -> Result<u16, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads an unsigned 16 bit integer from the underlying reader. Read more
fn read_i16<T>(&mut self) -> Result<i16, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a signed 16 bit integer from the underlying reader. Read more
fn read_u24<T>(&mut self) -> Result<u32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads an unsigned 24 bit integer from the underlying reader. Read more
fn read_i24<T>(&mut self) -> Result<i32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a signed 24 bit integer from the underlying reader. Read more
fn read_u32<T>(&mut self) -> Result<u32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads an unsigned 32 bit integer from the underlying reader. Read more
fn read_i32<T>(&mut self) -> Result<i32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a signed 32 bit integer from the underlying reader. Read more
fn read_u48<T>(&mut self) -> Result<u64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads an unsigned 48 bit integer from the underlying reader. Read more
fn read_i48<T>(&mut self) -> Result<i64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a signed 48 bit integer from the underlying reader. Read more
fn read_u64<T>(&mut self) -> Result<u64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads an unsigned 64 bit integer from the underlying reader. Read more
fn read_i64<T>(&mut self) -> Result<i64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a signed 64 bit integer from the underlying reader. Read more
fn read_u128<T>(&mut self) -> Result<u128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads an unsigned 128 bit integer from the underlying reader. Read more
fn read_i128<T>(&mut self) -> Result<i128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a signed 128 bit integer from the underlying reader. Read more
fn read_uint<T>(&mut self, nbytes: usize) -> Result<u64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads an unsigned n-bytes integer from the underlying reader. Read more
fn read_int<T>(&mut self, nbytes: usize) -> Result<i64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a signed n-bytes integer from the underlying reader. Read more
fn read_uint128<T>(&mut self, nbytes: usize) -> Result<u128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads an unsigned n-bytes integer from the underlying reader.
fn read_int128<T>(&mut self, nbytes: usize) -> Result<i128, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a signed n-bytes integer from the underlying reader.
fn read_f32<T>(&mut self) -> Result<f32, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a IEEE754 single-precision (4 bytes) floating point number from the underlying reader. Read more
fn read_f64<T>(&mut self) -> Result<f64, Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a IEEE754 double-precision (8 bytes) floating point number from the underlying reader. Read more
fn read_u16_into<T>(&mut self, dst: &mut [u16]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a sequence of unsigned 16 bit integers from the underlying reader. Read more
fn read_u32_into<T>(&mut self, dst: &mut [u32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a sequence of unsigned 32 bit integers from the underlying reader. Read more
fn read_u64_into<T>(&mut self, dst: &mut [u64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a sequence of unsigned 64 bit integers from the underlying reader. Read more
fn read_u128_into<T>(&mut self, dst: &mut [u128]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a sequence of unsigned 128 bit integers from the underlying reader. Read more
fn read_i16_into<T>(&mut self, dst: &mut [i16]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a sequence of signed 16 bit integers from the underlying reader. Read more
fn read_i32_into<T>(&mut self, dst: &mut [i32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a sequence of signed 32 bit integers from the underlying reader. Read more
fn read_i64_into<T>(&mut self, dst: &mut [i64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a sequence of signed 64 bit integers from the underlying reader. Read more
fn read_i128_into<T>(&mut self, dst: &mut [i128]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a sequence of signed 128 bit integers from the underlying reader. Read more
fn read_f32_into<T>(&mut self, dst: &mut [f32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a sequence of IEEE754 single-precision (4 bytes) floating point numbers from the underlying reader. Read more
fn read_f32_into_unchecked<T>(&mut self, dst: &mut [f32]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
please use read_f32_into
instead
DEPRECATED. Read more
fn read_f64_into<T>(&mut self, dst: &mut [f64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Reads a sequence of IEEE754 double-precision (8 bytes) floating point numbers from the underlying reader. Read more
fn read_f64_into_unchecked<T>(&mut self, dst: &mut [f64]) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
please use read_f64_into
instead
DEPRECATED. Read more