Skip to main content

Module opcodes

Module opcodes 

Source
Expand description

Opcode definitions and instruction encoding/decoding for the Lua 5.4 VM.

Ports src/lopcodes.c (the luaP_opmodes table) and src/lopcodes.h (the OpCode/OpMode enums, field-size constants, and instruction accessor macros). Per PORTING.md §1, headers merge into their consuming .rs.

C source preserved inline as `

Structs§

Instruction
A single Lua bytecode instruction (unsigned 32-bit word).

Enums§

OpCode
All opcodes for the Lua 5.4 virtual machine.
OpMode
Instruction addressing mode.

Constants§

LFIELDS_PER_FLUSH
Number of list items to accumulate before a SETLIST instruction.
MAXARG_A
MAXARG_AX
MAXARG_B
MAXARG_BX
MAXARG_C
MAXARG_S_J
MAXINDEXRK
Maximum RK index (for debugging only).
NO_REG
Sentinel “no register” value that fits in 8 bits.
NUM_OPCODES
Total number of opcodes.
OFFSET_S_BX
OFFSET_S_C
OFFSET_S_J
POS_A
POS_AX
POS_B
POS_BX
POS_C
POS_K
POS_OP
POS_S_J
SIZE_A
SIZE_AX
SIZE_B
SIZE_BX
SIZE_C
SIZE_OP
SIZE_S_J

Functions§

get_op_mode
Extract the OpMode for an opcode.
int_to_s_c
Encode a signed integer into an unsigned C-field value.
s_c_to_int
Decode a C-field unsigned value to a signed integer.
test_a_mode
True if this opcode writes to register A.
test_it_mode
True if this opcode uses L->top as set by the previous instruction (B == 0 case).
test_mm_mode
True if this opcode is a metamethod call.
test_ot_mode
True if this opcode sets L->top for the next instruction (C == 0 case).
test_t_mode
True if this opcode is a test (the next instruction must be a jump).