[−][src]Struct itsy::bytecode::Writer
Bytecode buffer and writer. Extended from opcodes.rs with the individual opcodes that can be written.
Methods
impl<T> Writer<T> where
T: VMFunc<T>,
[src]
T: VMFunc<T>,
pub fn new() -> Self
[src]
Creates a new writer instance.
pub fn len(&self) -> u32
[src]
Returns the current length of the program.
pub fn position(&self) -> u32
[src]
Returns the current write position.
pub fn set_position(&mut self, new_position: u32)
[src]
Sets the current write position.
pub fn into_program(self) -> Program<T>
[src]
Converts the writer into the underlying buffer.
pub fn overwrite<F>(&mut self, position: u32, write_fn: F) -> u32 where
F: FnMut(&mut Self) -> u32,
[src]
F: FnMut(&mut Self) -> u32,
Overwrites the program at given position and returns to the previous position afterwards.
impl<T> Writer<T> where
T: VMFunc<T>,
[src]
T: VMFunc<T>,
Bytecode writers. Generated from bytecode method signatures defined via the impl_vm!
macro.
pub fn debug(&mut self, label: u32) -> u32
[src]
Does nothing. Used as label when debugging.
pub fn reserve(&mut self, num_items: u8) -> u32
[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) -> u32
[src]
Load 2 byte from constant pool onto stack.
pub fn constr16_16(&mut self, const_id: u16) -> u32
[src]
Load 2 byte from constant pool onto stack.
pub fn constr32(&mut self, const_id: u8) -> u32
[src]
Load 4 byte from constant pool onto stack.
pub fn constr32_16(&mut self, const_id: u16) -> u32
[src]
Load 4 byte from constant pool onto stack.
pub fn constr64(&mut self, const_id: u8) -> u32
[src]
Load 8 byte from constant pool onto stack.
pub fn constr64_16(&mut self, const_id: u16) -> u32
[src]
Load 8 byte from constant pool onto stack.
pub fn consto(&mut self, const_id: u8) -> u32
[src]
Load object from constant pool onto stack+heap.
pub fn consto_16(&mut self, const_id: u16) -> u32
[src]
Load object from constant pool onto stack+heap.
pub fn litu(&mut self, value: u8) -> u32
[src]
Push value onto stack.
pub fn lits(&mut self, value: i8) -> u32
[src]
Push value onto stack.
pub fn lit0(&mut self) -> u32
[src]
Push 0 onto stack.
pub fn lit1(&mut self) -> u32
[src]
Push 1 onto stack.
pub fn lit2(&mut self) -> u32
[src]
Push 2 onto stack.
pub fn litm1(&mut self) -> u32
[src]
Push -1 onto stack.
pub fn loadr32(&mut self, offset: i32) -> u32
[src]
Load stackvalue from offset (relative to the stackframe) and push onto the stack.
pub fn storer32(&mut self, offset: i32) -> u32
[src]
Pop stackvalue and store it at the given offset (relative to the stackframe).
pub fn loadr64(&mut self, offset: i32) -> u32
[src]
Load 64 bit stackvalue from offset (relative to the stackframe) and push onto the stack.
pub fn storer64(&mut self, offset: i32) -> u32
[src]
Pop 64 bit stackvalue and store it at the given offset (relative to the stackframe).
pub fn load_arg1(&mut self) -> u32
[src]
Load function argument 1 and push it onto the stack. Equivalent to load -4.
pub fn load_arg2(&mut self) -> u32
[src]
Load function argument 2 and push it onto the stack. Equivalent to load -5.
pub fn load_arg3(&mut self) -> u32
[src]
Load function argument 3 and push it onto the stack. Equivalent to load -6.
pub fn rustcall(&mut self, func: T) -> u32
[src]
Calls the given Rust function.
pub fn call(&mut self, addr: u32, num_args: u8) -> u32
[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) -> u32
[src]
Function return. Restores state, removes arguments left on stack by caller and leaves call result on the stack.
pub fn and(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their logical conjunction.
pub fn or(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their logical disjunction.
pub fn not(&mut self) -> u32
[src]
Pops a values from the stack and pushes its logical negation.
pub fn addi(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their sum.
pub fn subi(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their difference.
pub fn muli(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their product.
pub fn addf(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their sum.
pub fn subf(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their sum.
pub fn mulf(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their product.
pub fn addi64(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their sum.
pub fn subi64(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their difference.
pub fn muli64(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their product.
pub fn addf64(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their sum.
pub fn subf64(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their sum.
pub fn mulf64(&mut self) -> u32
[src]
Pops 2 values from the stack and pushes their product.
pub fn jmp(&mut self, addr: u32) -> u32
[src]
Jumps unconditionally to the given address.
pub fn j0(&mut self, addr: u32) -> u32
[src]
Pops one values and jumps to given address if it is 0.
pub fn jeqr32(&mut self, addr: u32) -> u32
[src]
Pops two values and jumps to given address it they equal.
pub fn jeqr64(&mut self, addr: u32) -> u32
[src]
Pops two values and jumps to given address it they equal.
pub fn jneqr32(&mut self, addr: u32) -> u32
[src]
Pops two values and jumps to given address it they are not equal.
pub fn jneqr64(&mut self, addr: u32) -> u32
[src]
Pops two values and jumps to given address it they are not equal.
pub fn jlts32(&mut self, addr: u32) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> 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) -> u32
[src]
Pops two values and jumps to given address if the first value is less/equal the second.
pub fn ceqr32(&mut self) -> u32
[src]
Pops two values and pushes a 1 if the first value equals the second, otherwise a 0.
pub fn ceqr64(&mut self) -> u32
[src]
Pops two values and pushes a 1 if the first value equals the second, otherwise a 0.
pub fn cneqr32(&mut self) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[src]
Increments the value at the top of the stack.
pub fn deci(&mut self) -> u32
[src]
Decrements the value at the top of the stack.
pub fn inci64(&mut self) -> u32
[src]
Increments the value at the top of the stack.
pub fn deci64(&mut self) -> u32
[src]
Decrements the value at the top of the stack.
pub fn preinci(&mut self, offset: i32) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[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) -> u32
[src]
Decrements the stackvalue at given offset (relative to the stackframe) and pushes the previous value onto the stack.
pub fn yld(&mut self) -> u32
[src]
Yield program execution.
pub fn exit(&mut self) -> u32
[src]
Terminate program execution.
Trait Implementations
impl<T: Debug> Debug for Writer<T> where
T: VMFunc<T>,
[src]
T: VMFunc<T>,
impl<T> Write for Writer<T> where
T: VMFunc<T>,
[src]
T: VMFunc<T>,
Implement Write trait for program instructions.
fn write(&mut self, buf: &[u8]) -> Result<usize>
[src]
fn write_all(&mut self, buf: &[u8]) -> Result<()>
[src]
fn flush(&mut self) -> Result<()>
[src]
fn write_vectored(&mut self, bufs: &[IoVec]) -> Result<usize, Error>
[src]
iovec
)Like write
, except that it writes from a slice of buffers. Read more
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
Writes a formatted string into this writer, returning any error encountered. Read more
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Creates a "by reference" adaptor for this instance of Write
. Read more
impl<T> Seek for Writer<T> where
T: VMFunc<T>,
[src]
T: VMFunc<T>,
Implement Seek trait for program instructions.
Auto Trait Implementations
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<W> WriteBytesExt for W where
W: Write + ?Sized,
[src]
W: Write + ?Sized,
fn write_u8(&mut self, n: u8) -> Result<(), Error>
[src]
Writes an unsigned 8 bit integer to the underlying writer. Read more
fn write_i8(&mut self, n: i8) -> Result<(), Error>
[src]
Writes a signed 8 bit integer to the underlying writer. Read more
fn write_u16<T>(&mut self, n: u16) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes an unsigned 16 bit integer to the underlying writer. Read more
fn write_i16<T>(&mut self, n: i16) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes a signed 16 bit integer to the underlying writer. Read more
fn write_u24<T>(&mut self, n: u32) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes an unsigned 24 bit integer to the underlying writer. Read more
fn write_i24<T>(&mut self, n: i32) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes a signed 24 bit integer to the underlying writer. Read more
fn write_u32<T>(&mut self, n: u32) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes an unsigned 32 bit integer to the underlying writer. Read more
fn write_i32<T>(&mut self, n: i32) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes a signed 32 bit integer to the underlying writer. Read more
fn write_u48<T>(&mut self, n: u64) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes an unsigned 48 bit integer to the underlying writer. Read more
fn write_i48<T>(&mut self, n: i64) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes a signed 48 bit integer to the underlying writer. Read more
fn write_u64<T>(&mut self, n: u64) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes an unsigned 64 bit integer to the underlying writer. Read more
fn write_i64<T>(&mut self, n: i64) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes a signed 64 bit integer to the underlying writer. Read more
fn write_u128<T>(&mut self, n: u128) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes an unsigned 128 bit integer to the underlying writer.
fn write_i128<T>(&mut self, n: i128) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes a signed 128 bit integer to the underlying writer.
fn write_uint<T>(&mut self, n: u64, nbytes: usize) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes an unsigned n-bytes integer to the underlying writer. Read more
fn write_int<T>(&mut self, n: i64, nbytes: usize) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes a signed n-bytes integer to the underlying writer. Read more
fn write_uint128<T>(&mut self, n: u128, nbytes: usize) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes an unsigned n-bytes integer to the underlying writer. Read more
fn write_int128<T>(&mut self, n: i128, nbytes: usize) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes a signed n-bytes integer to the underlying writer. Read more
fn write_f32<T>(&mut self, n: f32) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes a IEEE754 single-precision (4 bytes) floating point number to the underlying writer. Read more
fn write_f64<T>(&mut self, n: f64) -> Result<(), Error> where
T: ByteOrder,
[src]
T: ByteOrder,
Writes a IEEE754 double-precision (8 bytes) floating point number to the underlying writer. Read more