Skip to main content

Op

Enum Op 

Source
#[repr(u8)]
pub enum Op {
Show 64 variants Move = 0, LoadI = 1, LoadF = 2, LoadK = 3, LoadKx = 4, LoadFalse = 5, LFalseSkip = 6, LoadTrue = 7, LoadNil = 8, GetUpval = 9, SetUpval = 10, GetTabUp = 11, GetTable = 12, GetI = 13, GetField = 14, SetTabUp = 15, SetTable = 16, SetI = 17, SetField = 18, NewTable = 19, SelfOp = 20, Add = 21, Sub = 22, Mul = 23, Mod = 24, Pow = 25, Div = 26, IDiv = 27, BAnd = 28, BOr = 29, BXor = 30, Shl = 31, Shr = 32, Unm = 33, BNot = 34, Not = 35, Len = 36, Concat = 37, Close = 38, Tbc = 39, Jmp = 40, Eq = 41, Lt = 42, Le = 43, EqK = 44, Test = 45, TestSet = 46, Call = 47, TailCall = 48, Return = 49, Return0 = 50, Return1 = 51, ForLoop = 52, ForPrep = 53, TForPrep = 54, TForCall = 55, TForLoop = 56, SetList = 57, Closure = 58, Vararg = 59, GetVarg = 60, VargIdx = 61, ErrNNil = 62, ExtraArg = 63,
}
Expand description

Opcode kinds for the luna bytecode. Layout follows PUC lopcodes.h (5.5.0); semantics may differ where noted in the dispatcher.

Variants§

§

Move = 0

R[A] := R[B] register move.

§

LoadI = 1

R[A] := sBx load immediate integer.

§

LoadF = 2

R[A] := (lua_Number)sBx load immediate float.

§

LoadK = 3

R[A] := K[Bx] load constant.

§

LoadKx = 4

R[A] := K[extra_arg] load constant with extended index (next op must be ExtraArg).

§

LoadFalse = 5

R[A] := false.

§

LFalseSkip = 6

R[A] := false; pc++ load false and skip next instruction.

§

LoadTrue = 7

R[A] := true.

§

LoadNil = 8

R[A..A+B] := nil clear a register range.

§

GetUpval = 9

R[A] := Upvalues[B].

§

SetUpval = 10

Upvalues[B] := R[A].

§

GetTabUp = 11

R[A] := Upvalues[B][K[C]:string] global-style table read on an upvalue.

§

GetTable = 12

R[A] := R[B][R[C]].

§

GetI = 13

R[A] := R[B][C:int] integer-indexed read.

§

GetField = 14

R[A] := R[B][K[C]:string] field read with constant key.

§

SetTabUp = 15

Upvalues[A][K[B]:string] := R[C]/K[C].

§

SetTable = 16

R[A][R[B]] := R[C]/K[C].

§

SetI = 17

R[A][B:int] := R[C]/K[C] integer-indexed write.

§

SetField = 18

R[A][K[B]:string] := R[C]/K[C] field write.

§

NewTable = 19

R[A] := {} allocate a new table; B/C carry size hints.

§

SelfOp = 20

R[A+1] := R[B]; R[A] := R[B][K[C]:string] self-method prep for obj:m(...).

§

Add = 21

R[A] := R[B] + R[C]/K[C].

§

Sub = 22

R[A] := R[B] - R[C]/K[C].

§

Mul = 23

R[A] := R[B] * R[C]/K[C].

§

Mod = 24

R[A] := R[B] % R[C]/K[C].

§

Pow = 25

R[A] := R[B] ^ R[C]/K[C].

§

Div = 26

R[A] := R[B] / R[C]/K[C].

§

IDiv = 27

R[A] := R[B] // R[C]/K[C].

§

BAnd = 28

R[A] := R[B] & R[C]/K[C].

§

BOr = 29

R[A] := R[B] | R[C]/K[C].

§

BXor = 30

R[A] := R[B] ~ R[C]/K[C].

§

Shl = 31

R[A] := R[B] << R[C]/K[C].

§

Shr = 32

R[A] := R[B] >> R[C]/K[C].

§

Unm = 33

R[A] := -R[B] arithmetic negation.

§

BNot = 34

R[A] := ~R[B] bitwise NOT.

§

Not = 35

R[A] := not R[B].

§

Len = 36

R[A] := #R[B] length operator.

§

Concat = 37

R[A] := R[A] .. ... .. R[A+B-1] string concatenation chain.

§

Close = 38

Close upvalues in scope A (closes pending <close> and upvalues).

§

Tbc = 39

Mark to-be-closed slot A (5.4).

§

Jmp = 40

pc += sJ unconditional jump.

§

Eq = 41

Equality comparison with optional skip.

§

Lt = 42

Less-than comparison with optional skip.

§

Le = 43

Less-or-equal comparison with optional skip.

§

EqK = 44

Equality against a constant.

§

Test = 45

if (not R[A]) == k then pc++.

§

TestSet = 46

if (not R[B]) == k then pc++ else R[A] := R[B].

§

Call = 47

R[A], ..., R[A+C-2] := R[A](R[A+1], ..., R[A+B-1]).

§

TailCall = 48

Tail call (same register/return contract as Call).

§

Return = 49

return R[A], ..., R[A+B-2].

§

Return0 = 50

return with no values.

§

Return1 = 51

return R[A] single-value return.

§

ForLoop = 52

Numeric-for iteration step.

§

ForPrep = 53

Numeric-for prepare (validates types, normalizes step).

§

TForPrep = 54

Generic-for prepare.

§

TForCall = 55

Generic-for call: invoke iterator once.

§

TForLoop = 56

Generic-for loop tail (branch back if iterator returned non-nil).

§

SetList = 57

Bulk-store a sequence into a table (table constructor).

§

Closure = 58

R[A] := closure(KPROTO[Bx]).

§

Vararg = 59

R[A], R[A+1], ..., R[A+C-2] := vararg.

§

GetVarg = 60

5.5: materialize the vararg table into R[A] (named vararg that is written / escapes / is _ENV). Builds it from the stack varargs.

§

VargIdx = 61

5.5: R[A] := vararg[R[C]] — index the virtual named vararg without allocating a table. Integer key in [1,n] → that vararg, key "n" → the count, else nil (PUC OP_GETVARG on an unmaterialized vararg).

§

ErrNNil = 62

5.5: error if R[A] is not nil — a defining global write whose target already exists. Bx is the name constant index + 1 (0 ⇒ unknown name).

§

ExtraArg = 63

Extended-immediate payload for the preceding instruction (see LoadKx).

Trait Implementations§

Source§

impl Clone for Op

Source§

fn clone(&self) -> Op

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 Op

Source§

impl Debug for Op

Source§

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

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

impl Eq for Op

Source§

impl PartialEq for Op

Source§

fn eq(&self, other: &Op) -> 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 StructuralPartialEq for Op

Auto Trait Implementations§

§

impl Freeze for Op

§

impl RefUnwindSafe for Op

§

impl Send for Op

§

impl Sync for Op

§

impl Unpin for Op

§

impl UnsafeUnpin for Op

§

impl UnwindSafe for Op

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.