Struct docs::bytecode_vm::bytecode::instructions::Instructions
source · pub struct Instructions { /* private fields */ }Implementations§
source§impl Instructions
impl Instructions
sourcepub fn create() -> Result<Self, InstructionsError>
pub fn create() -> Result<Self, InstructionsError>
create Instructions
§Panics
Panics if OOM (out of memory) and panic_flag is set to true
§Errors InstructionsError::AllocationFailed
This function will return an error if panic_flag is set to false and OOM occured
sourcepub fn to_string_with_highlight(&self, hidx: usize) -> String
pub fn to_string_with_highlight(&self, hidx: usize) -> String
Stringify this Instructions
- hidx - index of highlight target
sourcepub fn add_instruction(
&mut self,
ins: Instruction
) -> Result<usize, InstructionsError>
pub fn add_instruction( &mut self, ins: Instruction ) -> Result<usize, InstructionsError>
Add new instruction at the end. return new Instruction’s offset
§Errors InstructionsError
This function will return an error if this Instructions::grow() have failed.
sourcepub unsafe fn update_instruction(&mut self, ins: Instruction, offset: usize)
pub unsafe fn update_instruction(&mut self, ins: Instruction, offset: usize)
Update instruction at offset with given ins
§Safety
if lengths are different between ins and instruction at offset,
There will be Corruption of this Instructions
sourcepub fn remove_instruction(&mut self, new_len: usize)
pub fn remove_instruction(&mut self, new_len: usize)
Remove instructions by set Self::len with new_len
This will move Self::cursor with new position of next instruction’s one
sourcepub fn read_instruction(
&self,
offset: usize
) -> Result<Instruction, InstructionsError>
pub fn read_instruction( &self, offset: usize ) -> Result<Instruction, InstructionsError>
Read Instruction at given offset
§Errors InstructionsError::CannotRead
This function will return an error if failed to read opcode
from Self::byte at offset to convert it as Instruction
sourcepub fn length(&self) -> usize
pub fn length(&self) -> usize
Returns the length of this Instructions.
Trait Implementations§
source§impl Clone for Instructions
impl Clone for Instructions
source§fn clone(&self) -> Instructions
fn clone(&self) -> Instructions
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moresource§impl Debug for Instructions
impl Debug for Instructions
source§impl Display for Instructions
impl Display for Instructions
source§impl PartialEq for Instructions
impl PartialEq for Instructions
source§fn eq(&self, other: &Instructions) -> bool
fn eq(&self, other: &Instructions) -> bool
self and other values to be equal, and is used
by ==.