TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/pw4k/ironbrew-2/llms.txt
Use this file to discover all available pages before exploring further.
Instruction class represents a single Lua VM bytecode instruction, including its opcode, operands, and cross-references to other instructions, constants, and chunks.
Namespace
Properties
The operation code specifying what action this instruction performs (e.g., Move, Add, LoadConst, Jmp)
The instruction encoding type: ABC, ABx, AsBx, AsBxC, or Data
Bitmask indicating which operands reference constants
First operand (typically a register index)
Second operand (register, constant, or jump offset depending on opcode)
Third operand (register, constant, or unused depending on opcode)
Raw instruction data (32-bit encoded instruction)
Program counter (instruction index within the chunk)
Source line number for debugging
Reference to the parent chunk containing this instruction
Array of 3 object references that operands may point to:
- Constants (for LoadConst, GetGlobal, etc.)
- Instructions (for Jmp, ForLoop, etc.)
- Chunks (for Closure)
List of instructions that reference this instruction (e.g., jump targets)
Custom data used during obfuscation and VM virtualization
Constructors
Copy Constructor
The instruction to copy
Create New Instruction
The parent chunk containing this instruction
The operation code for this instruction
Variable-length array of reference operands (Constants, Instructions, or Chunks)
The constructor automatically sets up back-references, so instructions or constants referenced in refOperands will have this instruction added to their BackReferences list.
Methods
UpdateRegisters
- LoadConst, GetGlobal, SetGlobal: Sets B to the constant’s index
- Jmp, ForLoop, ForPrep: Sets B to the relative jump offset
- Closure: Sets B to the nested chunk’s index
- Arithmetic/Table ops: Adds 256 to B/C if they reference constants
SetupRefs
- LoadConst, GetGlobal, SetGlobal: RefOperands[0] = Constants[B]
- Jmp, ForLoop, ForPrep: RefOperands[0] = Instructions[PC + B + 1]
- Closure: RefOperands[0] = Functions[B]
- Arithmetic/Table ops: RefOperands[0/1] = Constants[B/C - 256] if B/C > 255
SetupRefs also registers back-references, adding this instruction to the BackReferences list of any referenced objects.
Instruction Types
Three operands: A (8 bits), B (9 bits), C (9 bits)
Two operands: A (8 bits), Bx (18 bits unsigned)
Two operands: A (8 bits), sBx (18 bits signed)
Custom type with signed Bx and C operand
Raw data instruction (used after SetList with C=0)
Usage Example
Working with RefOperands
See Also
- Chunk - Container for instructions
- Deserializer - Decode instructions from bytecode
- Serializer - Encode instructions to bytecode