Skip to main content

Instruction

Struct Instruction 

Source
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: u32

Header word.

§opcode: Opcode

Decoded opcode.

§a: u8

ABC A operand.

§b: u8

ABC B operand.

§c: u8

ABC C operand.

§d: i16

AD D operand.

§e: i32

E 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

Source

pub fn from_words(header: u32, aux: Option<u32>) -> Option<Self>

Creates an instruction from its raw words.

Source

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

Encodes ABC instruction fields.

Source

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.

Source

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

Encodes AD instruction fields.

Source

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.

Source

pub fn jump_target_word(&self, instruction_word: u32) -> Option<i32>

Resolves this instruction’s jump target as an absolute instruction-word offset.

Source

pub fn capture_type(&self) -> Option<CaptureType>

Returns the CAPTURE operand kind, if this is a valid capture instruction.

Source

pub fn capture_source(&self) -> Option<u8>

Returns the CAPTURE source register or upvalue index.

Source

pub fn word_len(&self) -> u32

Returns the number of instruction words this instruction occupies, counting its header word plus any AUX words.

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<'de> Deserialize<'de> for Instruction

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for Instruction

Source§

impl PartialEq for Instruction

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Instruction

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.