pub struct Instruction {
pub opcode: Opcode,
/* private fields */
}Expand description
A fully decoded bytecode instruction: an Opcode paired with its
Operand list.
The number and types of operands are always determined by
Opcode::operand_types.
Fields§
§opcode: OpcodeThe operation to perform.
Implementations§
Source§impl Instruction
impl Instruction
Sourcepub fn new(
opcode: Opcode,
operands: impl IntoIterator<Item = Operand>,
) -> StatorResult<Self>
pub fn new( opcode: Opcode, operands: impl IntoIterator<Item = Operand>, ) -> StatorResult<Self>
Construct an instruction, verifying that the operand count matches the opcode’s declared operand list.
Returns an error if the wrong number of operands is supplied.
Sourcepub fn new_unchecked(
opcode: Opcode,
operands: impl IntoIterator<Item = Operand>,
) -> Self
pub fn new_unchecked( opcode: Opcode, operands: impl IntoIterator<Item = Operand>, ) -> Self
Construct an instruction without operand-count validation.
Prefer Instruction::new unless you are certain the operand count
is correct (e.g. inside the decoder).
Sourcepub fn operand_count(&self) -> usize
pub fn operand_count(&self) -> usize
Return the number of operands carried by this instruction.
Sourcepub fn operand(&self, idx: usize) -> &Operand
pub fn operand(&self, idx: usize) -> &Operand
Return the operand at idx.
Panics if idx is out of bounds for this instruction.
Sourcepub fn operand_at(&self, idx: usize) -> Option<&Operand>
pub fn operand_at(&self, idx: usize) -> Option<&Operand>
Return the operand at idx, if present.
Sourcepub fn operand_mut(&mut self, idx: usize) -> &mut Operand
pub fn operand_mut(&mut self, idx: usize) -> &mut Operand
Return the operand at idx mutably.
Panics if idx is out of bounds for this instruction.
Sourcepub unsafe fn operand_unchecked(&self, idx: usize) -> &Operand
pub unsafe fn operand_unchecked(&self, idx: usize) -> &Operand
Return the operand at idx without bounds checks.
§Safety
idx must be less than Instruction::operand_count.
Sourcepub fn register_count(&self, idx: usize) -> u32
pub fn register_count(&self, idx: usize) -> u32
Return operand idx as a register-count operand.
Sourcepub fn constant_pool_idx(&self, idx: usize) -> u32
pub fn constant_pool_idx(&self, idx: usize) -> u32
Return operand idx as a constant-pool index.
Sourcepub fn feedback_slot(&self, idx: usize) -> u32
pub fn feedback_slot(&self, idx: usize) -> u32
Return operand idx as a feedback-slot index.
Sourcepub fn runtime_id(&self, idx: usize) -> u32
pub fn runtime_id(&self, idx: usize) -> u32
Return operand idx as a runtime identifier.
Sourcepub fn jump_offset(&self, idx: usize) -> i32
pub fn jump_offset(&self, idx: usize) -> i32
Return operand idx as a jump offset.
Trait Implementations§
Source§impl Clone for Instruction
impl Clone for Instruction
Source§fn clone(&self) -> Instruction
fn clone(&self) -> Instruction
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Instruction
impl Debug for Instruction
Source§impl PartialEq for Instruction
impl PartialEq for Instruction
Source§fn eq(&self, other: &Instruction) -> bool
fn eq(&self, other: &Instruction) -> bool
self and other values to be equal, and is used by ==.impl Eq 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more