#[repr(u8)]pub enum OpCode {
Show 63 variants
Constant = 0,
Undefined = 1,
Null = 2,
True = 3,
False = 4,
Add = 5,
Sub = 6,
Mul = 7,
Div = 8,
Mod = 9,
Negate = 10,
BitAnd = 11,
BitOr = 12,
BitXor = 13,
BitNot = 14,
ShiftLeft = 15,
ShiftRight = 16,
UShiftRight = 17,
StrictEqual = 18,
StrictNotEqual = 19,
Equal = 20,
NotEqual = 21,
LessThan = 22,
LessEqual = 23,
GreaterThan = 24,
GreaterEqual = 25,
Not = 26,
TypeOf = 27,
Void = 28,
UnaryPlus = 29,
GetVar = 30,
SetVar = 31,
DeclareVar = 32,
DeclareLet = 33,
DeclareConst = 34,
InitVar = 35,
InitBinding = 36,
GetLocal = 37,
SetLocal = 38,
InitLocal = 39,
Jump = 40,
JumpIfFalse = 41,
JumpIfTrue = 42,
LoopStart = 43,
Pop = 44,
Dup = 45,
Dup2 = 46,
PushScope = 47,
PopScope = 48,
GetProp = 49,
SetProp = 50,
GetElem = 51,
SetElem = 52,
Call = 53,
CallMethod = 54,
Return = 55,
Halt = 56,
PreIncVar = 57,
PreDecVar = 58,
PostIncVar = 59,
PostDecVar = 60,
GetVarForUpdate = 61,
MakeClosure = 62,
}Expand description
Bytecode opcodes for the stack-based VM.
Variants§
Constant = 0
Push a constant from the constant pool onto the stack.
Undefined = 1
Push undefined onto the stack.
Null = 2
Push null onto the stack.
True = 3
Push true onto the stack.
False = 4
Push false onto the stack.
Add = 5
Pop two values, push their sum.
Sub = 6
Pop two values, push their difference.
Mul = 7
Pop two values, push their product.
Div = 8
Pop two values, push their quotient.
Mod = 9
Pop two values, push their remainder.
Negate = 10
Pop one value, push its numeric negation.
BitAnd = 11
Bitwise AND.
BitOr = 12
Bitwise OR.
BitXor = 13
Bitwise XOR.
BitNot = 14
Bitwise NOT.
ShiftLeft = 15
Left shift.
ShiftRight = 16
Signed right shift.
UShiftRight = 17
Unsigned right shift.
StrictEqual = 18
Strict equality (===).
StrictNotEqual = 19
Strict inequality (!==).
Equal = 20
Abstract equality (==).
NotEqual = 21
Abstract inequality (!=).
LessThan = 22
Less than.
LessEqual = 23
Less than or equal.
GreaterThan = 24
Greater than.
GreaterEqual = 25
Greater than or equal.
Not = 26
Logical NOT.
TypeOf = 27
typeof operator — pops value, pushes type string.
Void = 28
void operator — pops value, pushes undefined.
UnaryPlus = 29
Unary + — converts to number.
GetVar = 30
Get a global/local variable by name (operand: constant pool index of name string).
SetVar = 31
Set a variable by name (operand: constant pool index of name string). The value to assign is on top of the stack.
DeclareVar = 32
Declare a var binding (operand: constant pool index of name string).
DeclareLet = 33
Declare a let binding (operand: constant pool index of name string).
DeclareConst = 34
Declare a const binding (operand: constant pool index of name string).
InitVar = 35
Initialize a binding with the value on top of the stack.
InitBinding = 36
Initialize a let/const binding with the value on top of the stack.
GetLocal = 37
Get a local slot by index (operand: local slot index).
SetLocal = 38
Set a local slot by index (operand: local slot index).
InitLocal = 39
Initialize a local slot (operand: local slot index).
Jump = 40
Unconditional jump (operand: absolute offset).
JumpIfFalse = 41
Jump if top of stack is falsy (operand: absolute offset). Pops the value.
JumpIfTrue = 42
Jump if top of stack is truthy (operand: absolute offset). Pops the value.
LoopStart = 43
Marker for loop start (used by break/continue resolution).
Pop = 44
Pop and discard the top of the stack.
Dup = 45
Duplicate the top of the stack.
Dup2 = 46
Duplicate the top two stack values (a,b -> a,b,a,b).
PushScope = 47
Push a new block scope.
PopScope = 48
Pop a block scope.
GetProp = 49
Get a property: pop object and push object.property. Operand: constant pool index of property name.
SetProp = 50
Set a property: stack has [value, object]. Operand: constant pool index of property name.
GetElem = 51
Get a computed property: stack has [key, object].
SetElem = 52
Set a computed property: stack has [value, key, object].
Call = 53
Call a function. Operand: argument count. Stack: [arg_n, …, arg_1, callee]
CallMethod = 54
Call a method. Operand: argument count. Stack: [arg_n, …, arg_1, object] Second operand: constant pool index of method name.
Return = 55
Return from the current function/script. Pops return value from stack.
Halt = 56
Halt execution (end of script).
PreIncVar = 57
Pre-increment a variable (++x). Operand: constant pool index of name.
PreDecVar = 58
Pre-decrement a variable (–x). Operand: constant pool index of name.
PostIncVar = 59
Post-increment a variable (x++). Operand: constant pool index of name.
PostDecVar = 60
Post-decrement a variable (x–). Operand: constant pool index of name.
GetVarForUpdate = 61
Get a variable for compound update. Operand: constant pool index of name.
MakeClosure = 62
Create a closure from a function template.
Operand: index into the chunk’s functions table.
Pushes the resulting function object onto the stack.