pub struct Instruction {
pub header: u32,
pub opcode: Opcode,
pub a: u8,
pub b: u8,
pub c: u8,
pub d: i16,
pub e: i32,
pub aux: Option<u32>,
}Expand description
One instruction header and its optional static AUX word.
Plain-old-data on purpose: the dispatch loop fetches instructions by copy,
so the type must never grow a heap allocation. Every aux-bearing Luau
opcode carries exactly one AUX word (Opcode::instruction_len).
Fields§
§header: u32Header word.
opcode: OpcodeDecoded opcode.
a: u8ABC A operand.
b: u8ABC B operand.
c: u8ABC C operand.
d: i16AD D operand.
e: i32E operand.
aux: Option<u32>The static AUX word following the header, when the opcode has one. Serialized as a 0/1-element array to keep the committed fixture shape.
Implementations§
Source§impl Instruction
impl Instruction
Sourcepub fn from_words(header: u32, aux: Option<u32>) -> Option<Self>
pub fn from_words(header: u32, aux: Option<u32>) -> Option<Self>
Creates an instruction from its raw words.
Sourcepub fn abc_with_aux(
opcode: Opcode,
a: u8,
b: u8,
c: u8,
aux: Option<u32>,
) -> Self
pub fn abc_with_aux( opcode: Opcode, a: u8, b: u8, c: u8, aux: Option<u32>, ) -> Self
Encodes ABC instruction fields followed by an optional static AUX word.
Sourcepub fn jump_offset_words(&self) -> Option<i32>
pub fn jump_offset_words(&self) -> Option<i32>
Returns the encoded jump offset in instruction words, if this opcode jumps.
Luau jump offsets are relative to the word after the instruction header.
For instructions with AUX words, the AUX words are part of the encoded
offset span; for example, comparison jumps use D = 1 for the next
decoded instruction because their AUX word occupies the intervening word.
Sourcepub fn jump_target_word(&self, instruction_word: u32) -> Option<i32>
pub fn jump_target_word(&self, instruction_word: u32) -> Option<i32>
Resolves this instruction’s jump target as an absolute instruction-word offset.
Sourcepub fn capture_type(&self) -> Option<CaptureType>
pub fn capture_type(&self) -> Option<CaptureType>
Returns the CAPTURE operand kind, if this is a valid capture instruction.
Sourcepub fn capture_source(&self) -> Option<u8>
pub fn capture_source(&self) -> Option<u8>
Returns the CAPTURE source register or upvalue index.
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 moreimpl Copy for Instruction
Source§impl Debug for Instruction
impl Debug for Instruction
Source§impl<'de> Deserialize<'de> for Instruction
impl<'de> Deserialize<'de> for Instruction
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq 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 ==.