Skip to main content

Instruction

Struct Instruction 

Source
pub struct Instruction(/* private fields */);

Implementations§

Source§

impl Instruction

Source

pub fn new(word: InstructionWord) -> Self

Source

pub fn abc(opcode: Opcode, a: u8, b: u8, c: u8) -> Self

Source

pub fn ad(opcode: Opcode, a: u8, d: i16) -> Self

Source

pub fn ae(opcode: Opcode, e: i32) -> Self

Source

pub fn word(self) -> InstructionWord

Source

pub fn with_d(self, d: i16) -> Self

Source

pub fn with_c(self, c: u8) -> Self

Source

pub fn try_opcode(self) -> Result<Opcode, InvalidOpcode>

Decodes the opcode byte when this word is an instruction header.

Source

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.

Source

pub fn a(self) -> u8

Source

pub fn b(self) -> u8

Source

pub fn c(self) -> u8

Source

pub fn d(self) -> i16

Source

pub fn e(self) -> i32

Source

pub fn try_jump_target(self, pc: u32) -> Result<Option<i32>, InvalidOpcode>

Computes the jump target for a checked instruction header.

Source

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

Source§

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)

Performs copy-assignment from source. Read more
Source§

impl Copy for Instruction

Source§

impl Debug for Instruction

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Instruction

Source§

impl PartialEq for Instruction

Source§

fn eq(&self, other: &Instruction) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Instruction

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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 T
where 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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 T
where U: TryFrom<T>,

Source§

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.