pub struct Instruction(/* private fields */);Implementations§
Source§impl Instruction
impl Instruction
pub fn new(word: InstructionWord) -> Self
pub fn abc(opcode: Opcode, a: u8, b: u8, c: u8) -> Self
pub fn ad(opcode: Opcode, a: u8, d: i16) -> Self
pub fn ae(opcode: Opcode, e: i32) -> Self
pub fn word(self) -> InstructionWord
pub fn with_d(self, d: i16) -> Self
pub fn with_c(self, c: u8) -> Self
Sourcepub fn try_opcode(self) -> Result<Opcode, InvalidOpcode>
pub fn try_opcode(self) -> Result<Opcode, InvalidOpcode>
Decodes the opcode byte when this word is an instruction header.
Sourcepub unsafe fn opcode_unchecked(self) -> Opcode
pub unsafe fn opcode_unchecked(self) -> Opcode
Decodes the opcode byte without checking that it is in range.
§Safety
The word must be an instruction header from bytecode that has already passed opcode validation. AUX words and VM cache/sentinel words must not be decoded through this function.
pub fn a(self) -> u8
pub fn b(self) -> u8
pub fn c(self) -> u8
pub fn d(self) -> i16
pub fn e(self) -> i32
Sourcepub fn try_jump_target(self, pc: u32) -> Result<Option<i32>, InvalidOpcode>
pub fn try_jump_target(self, pc: u32) -> Result<Option<i32>, InvalidOpcode>
Computes the jump target for a checked instruction header.
Sourcepub unsafe fn jump_target_unchecked(self, pc: u32) -> Option<i32>
pub unsafe fn jump_target_unchecked(self, pc: u32) -> Option<i32>
Computes the jump target without checking the opcode byte.
§Safety
The word must satisfy the safety requirements of Self::opcode_unchecked.
Non-jump opcodes are valid inputs and return None.
Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for Instruction
Source§impl Debug for Instruction
impl Debug for Instruction
impl Eq for Instruction
Source§impl PartialEq for Instruction
impl PartialEq for Instruction
impl StructuralPartialEq for Instruction
Auto Trait Implementations§
impl Freeze for Instruction
impl RefUnwindSafe for Instruction
impl Send for Instruction
impl Sync for Instruction
impl Unpin for Instruction
impl UnsafeUnpin for Instruction
impl UnwindSafe for Instruction
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more