#[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).