Github User Fetcher 1.0.0
C Application with Server and GUI
Loading...
Searching...
No Matches
lopcodes.h File Reference
#include "llimits.h"

Go to the source code of this file.

Macros

#define SIZE_C   9
 
#define SIZE_B   9
 
#define SIZE_Bx   (SIZE_C + SIZE_B)
 
#define SIZE_A   8
 
#define SIZE_OP   6
 
#define POS_OP   0
 
#define POS_A   (POS_OP + SIZE_OP)
 
#define POS_C   (POS_A + SIZE_A)
 
#define POS_B   (POS_C + SIZE_C)
 
#define POS_Bx   POS_C
 
#define MAXARG_Bx   MAX_INT
 
#define MAXARG_sBx   MAX_INT
 
#define MAXARG_A   ((1<<SIZE_A)-1)
 
#define MAXARG_B   ((1<<SIZE_B)-1)
 
#define MAXARG_C   ((1<<SIZE_C)-1)
 
#define MASK1(n, p)   ((~((~(Instruction)0)<<n))<<p)
 
#define MASK0(n, p)   (~MASK1(n,p))
 
#define GET_OPCODE(i)   (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))
 
#define SET_OPCODE(i, o)
 
#define GETARG_A(i)   (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))
 
#define SETARG_A(i, u)
 
#define GETARG_B(i)   (cast(int, ((i)>>POS_B) & MASK1(SIZE_B,0)))
 
#define SETARG_B(i, b)
 
#define GETARG_C(i)   (cast(int, ((i)>>POS_C) & MASK1(SIZE_C,0)))
 
#define SETARG_C(i, b)
 
#define GETARG_Bx(i)   (cast(int, ((i)>>POS_Bx) & MASK1(SIZE_Bx,0)))
 
#define SETARG_Bx(i, b)
 
#define GETARG_sBx(i)   (GETARG_Bx(i)-MAXARG_sBx)
 
#define SETARG_sBx(i, b)   SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))
 
#define CREATE_ABC(o, a, b, c)
 
#define CREATE_ABx(o, a, bc)
 
#define BITRK   (1 << (SIZE_B - 1))
 
#define ISK(x)   ((x) & BITRK)
 
#define INDEXK(r)   ((int)(r) & ~BITRK)
 
#define MAXINDEXRK   (BITRK - 1)
 
#define RKASK(x)   ((x) | BITRK)
 
#define NO_REG   MAXARG_A
 
#define NUM_OPCODES   (cast(int, OP_VARARG) + 1)
 
#define getOpMode(m)   (cast(enum OpMode, luaP_opmodes[m] & 3))
 
#define getBMode(m)   (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))
 
#define getCMode(m)   (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))
 
#define testAMode(m)   (luaP_opmodes[m] & (1 << 6))
 
#define testTMode(m)   (luaP_opmodes[m] & (1 << 7))
 
#define LFIELDS_PER_FLUSH   50
 

Enumerations

enum  OpMode { iABC , iABx , iAsBx }
 
enum  OpCode {
  OP_MOVE , OP_LOADK , OP_LOADBOOL , OP_LOADNIL ,
  OP_GETUPVAL , OP_GETGLOBAL , OP_GETTABLE , OP_SETGLOBAL ,
  OP_SETUPVAL , OP_SETTABLE , OP_NEWTABLE , OP_SELF ,
  OP_ADD , OP_SUB , OP_MUL , OP_DIV ,
  OP_MOD , OP_POW , OP_UNM , OP_NOT ,
  OP_LEN , OP_CONCAT , OP_JMP , OP_EQ ,
  OP_LT , OP_LE , OP_TEST , OP_TESTSET ,
  OP_CALL , OP_TAILCALL , OP_RETURN , OP_FORLOOP ,
  OP_FORPREP , OP_TFORLOOP , OP_SETLIST , OP_CLOSE ,
  OP_CLOSURE , OP_VARARG
}
 
enum  OpArgMask { OpArgN , OpArgU , OpArgR , OpArgK }
 

Variables

LUAI_DATA const lu_byte luaP_opmodes [NUM_OPCODES]
 
LUAI_DATA const char *const luaP_opnames [NUM_OPCODES+1]
 

Macro Definition Documentation

◆ BITRK

#define BITRK   (1 << (SIZE_B - 1))

Definition at line 119 of file lua-5.1.5/src/lopcodes.h.

◆ CREATE_ABC

#define CREATE_ABC ( o,
a,
b,
c )
Value:
| (cast(Instruction, b)<<POS_B) \
lu_int32 Instruction
#define cast(t, exp)
#define POS_OP
#define POS_A
#define POS_C
#define POS_B

Definition at line 104 of file lua-5.1.5/src/lopcodes.h.

104#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \
105 | (cast(Instruction, a)<<POS_A) \
106 | (cast(Instruction, b)<<POS_B) \
107 | (cast(Instruction, c)<<POS_C))

Referenced by combine(), luaK_codeABC(), patchtestreg(), patchtestreg(), and patchtestreg().

◆ CREATE_ABx

#define CREATE_ABx ( o,
a,
bc )
Value:
| (cast(Instruction, bc)<<POS_Bx))
#define POS_Bx

Definition at line 109 of file lua-5.1.5/src/lopcodes.h.

109#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \
110 | (cast(Instruction, a)<<POS_A) \
111 | (cast(Instruction, bc)<<POS_Bx))

Referenced by combine(), luaK_codeABx(), and luaK_codeAsBx().

◆ GET_OPCODE

◆ GETARG_A

◆ GETARG_B

◆ GETARG_Bx

◆ GETARG_C

◆ GETARG_sBx

◆ getBMode

#define getBMode ( m)    (cast(enum OpArgMask, (luaP_opmodes[m] >> 4) & 3))

Definition at line 255 of file lua-5.1.5/src/lopcodes.h.

Referenced by luaK_codeABC(), PrintCode(), PrintCode(), PrintCode(), and symbexec().

◆ getCMode

#define getCMode ( m)    (cast(enum OpArgMask, (luaP_opmodes[m] >> 2) & 3))

◆ getOpMode

#define getOpMode ( m)    (cast(enum OpMode, luaP_opmodes[m] & 3))

◆ INDEXK

#define INDEXK ( r)    ((int)(r) & ~BITRK)

◆ ISK

#define ISK ( x)    ((x) & BITRK)

◆ LFIELDS_PER_FLUSH

#define LFIELDS_PER_FLUSH   50

◆ MASK0

#define MASK0 ( n,
p )   (~MASK1(n,p))

Definition at line 74 of file lua-5.1.5/src/lopcodes.h.

◆ MASK1

#define MASK1 ( n,
p )   ((~((~(Instruction)0)<<n))<<p)

Definition at line 71 of file lua-5.1.5/src/lopcodes.h.

◆ MAXARG_A

#define MAXARG_A   ((1<<SIZE_A)-1)

Definition at line 65 of file lua-5.1.5/src/lopcodes.h.

Referenced by luaK_codeABC(), luaK_codeABCk(), luaK_codeABx(), and luaK_codeAsBx().

◆ MAXARG_B

#define MAXARG_B   ((1<<SIZE_B)-1)

Definition at line 66 of file lua-5.1.5/src/lopcodes.h.

Referenced by isKstr(), luaK_codeABC(), and luaK_codeABCk().

◆ MAXARG_Bx

◆ MAXARG_C

#define MAXARG_C   ((1<<SIZE_C)-1)

◆ MAXARG_sBx

#define MAXARG_sBx   MAX_INT

Definition at line 61 of file lua-5.1.5/src/lopcodes.h.

Referenced by fixjump(), fixjump(), and fixjump().

◆ MAXINDEXRK

#define MAXINDEXRK   (BITRK - 1)

Definition at line 127 of file lua-5.1.5/src/lopcodes.h.

Referenced by luaK_exp2K(), and luaK_exp2RK().

◆ NO_REG

◆ NUM_OPCODES

#define NUM_OPCODES   (cast(int, OP_VARARG) + 1)

Definition at line 211 of file lua-5.1.5/src/lopcodes.h.

Referenced by symbexec().

◆ POS_A

#define POS_A   (POS_OP + SIZE_OP)

Definition at line 45 of file lua-5.1.5/src/lopcodes.h.

◆ POS_B

#define POS_B   (POS_C + SIZE_C)

Definition at line 47 of file lua-5.1.5/src/lopcodes.h.

◆ POS_Bx

#define POS_Bx   POS_C

Definition at line 48 of file lua-5.1.5/src/lopcodes.h.

◆ POS_C

#define POS_C   (POS_A + SIZE_A)

Definition at line 46 of file lua-5.1.5/src/lopcodes.h.

◆ POS_OP

#define POS_OP   0

Definition at line 44 of file lua-5.1.5/src/lopcodes.h.

◆ RKASK

#define RKASK ( x)    ((x) | BITRK)

Definition at line 130 of file lua-5.1.5/src/lopcodes.h.

Referenced by codecomp(), and luaK_exp2RK().

◆ SET_OPCODE

#define SET_OPCODE ( i,
o )
Value:
((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
#define SIZE_OP
#define MASK0(n, p)
#define MASK1(n, p)

Definition at line 81 of file lua-5.1.5/src/lopcodes.h.

81#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
82 ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP))))

Referenced by luaK_finish(), retstat(), retstat(), retstat(), and retstat().

◆ SETARG_A

#define SETARG_A ( i,
u )
Value:
((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
#define SIZE_A

Definition at line 85 of file lua-5.1.5/src/lopcodes.h.

85#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
86 ((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A))))

Referenced by codeconcat(), discharge2reg(), discharge2reg(), discharge2reg(), discharge2reg(), invertjump(), invertjump(), luaK_nil(), luaK_patchclose(), luaK_setreturns(), negatecondition(), patchtestreg(), patchtestreg(), patchtestreg(), and patchtestreg().

◆ SETARG_B

#define SETARG_B ( i,
b )
Value:
((i) = (((i)&MASK0(SIZE_B,POS_B)) | \
#define SIZE_B

Definition at line 89 of file lua-5.1.5/src/lopcodes.h.

89#define SETARG_B(i,b) ((i) = (((i)&MASK0(SIZE_B,POS_B)) | \
90 ((cast(Instruction, b)<<POS_B)&MASK1(SIZE_B,POS_B))))

Referenced by codeconcat(), constructor(), constructor(), constructor(), finishbinexpneg(), luaK_nil(), luaK_posfix(), luaK_posfix(), luaK_setoneret(), and luaK_setreturns().

◆ SETARG_Bx

#define SETARG_Bx ( i,
b )
Value:
((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \
#define SIZE_Bx

Definition at line 97 of file lua-5.1.5/src/lopcodes.h.

97#define SETARG_Bx(i,b) ((i) = (((i)&MASK0(SIZE_Bx,POS_Bx)) | \
98 ((cast(Instruction, b)<<POS_Bx)&MASK1(SIZE_Bx,POS_Bx))))

Referenced by fixforjump().

◆ SETARG_C

#define SETARG_C ( i,
b )
Value:
((i) = (((i)&MASK0(SIZE_C,POS_C)) | \
#define SIZE_C

Definition at line 93 of file lua-5.1.5/src/lopcodes.h.

93#define SETARG_C(i,b) ((i) = (((i)&MASK0(SIZE_C,POS_C)) | \
94 ((cast(Instruction, b)<<POS_C)&MASK1(SIZE_C,POS_C))))

Referenced by constructor(), constructor(), constructor(), exprstat(), exprstat(), exprstat(), exprstat(), luaK_finish(), luaK_setoneret(), and luaK_setreturns().

◆ SETARG_sBx

#define SETARG_sBx ( i,
b )   SETARG_Bx((i),cast(unsigned int, (b)+MAXARG_sBx))

Definition at line 101 of file lua-5.1.5/src/lopcodes.h.

Referenced by fixjump(), fixjump(), and fixjump().

◆ SIZE_A

#define SIZE_A   8

Definition at line 40 of file lua-5.1.5/src/lopcodes.h.

◆ SIZE_B

#define SIZE_B   9

Definition at line 38 of file lua-5.1.5/src/lopcodes.h.

◆ SIZE_Bx

#define SIZE_Bx   (SIZE_C + SIZE_B)

Definition at line 39 of file lua-5.1.5/src/lopcodes.h.

◆ SIZE_C

#define SIZE_C   9

Definition at line 37 of file lua-5.1.5/src/lopcodes.h.

◆ SIZE_OP

#define SIZE_OP   6

Definition at line 42 of file lua-5.1.5/src/lopcodes.h.

◆ testAMode

#define testAMode ( m)    (luaP_opmodes[m] & (1 << 6))

Definition at line 257 of file lua-5.1.5/src/lopcodes.h.

Referenced by findsetreg(), findsetreg(), findsetreg(), and symbexec().

◆ testTMode

Enumeration Type Documentation

◆ OpArgMask

enum OpArgMask
Enumerator
OpArgN 
OpArgU 
OpArgR 
OpArgK 

Definition at line 245 of file lua-5.1.5/src/lopcodes.h.

245 {
246 OpArgN, /* argument is not used */
247 OpArgU, /* argument is used */
248 OpArgR, /* argument is a register or a jump offset */
249 OpArgK /* argument is a constant or register/constant */
250};

◆ OpCode

enum OpCode
Enumerator
OP_MOVE 
OP_LOADK 
OP_LOADBOOL 
OP_LOADNIL 
OP_GETUPVAL 
OP_GETGLOBAL 
OP_GETTABLE 
OP_SETGLOBAL 
OP_SETUPVAL 
OP_SETTABLE 
OP_NEWTABLE 
OP_SELF 
OP_ADD 
OP_SUB 
OP_MUL 
OP_DIV 
OP_MOD 
OP_POW 
OP_UNM 
OP_NOT 
OP_LEN 
OP_CONCAT 
OP_JMP 
OP_EQ 
OP_LT 
OP_LE 
OP_TEST 
OP_TESTSET 
OP_CALL 
OP_TAILCALL 
OP_RETURN 
OP_FORLOOP 
OP_FORPREP 
OP_TFORLOOP 
OP_SETLIST 
OP_CLOSE 
OP_CLOSURE 
OP_VARARG 

Definition at line 150 of file lua-5.1.5/src/lopcodes.h.

150 {
151/*----------------------------------------------------------------------
152name args description
153------------------------------------------------------------------------*/
154OP_MOVE,/* A B R(A) := R(B) */
155OP_LOADK,/* A Bx R(A) := Kst(Bx) */
156OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */
157OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */
158OP_GETUPVAL,/* A B R(A) := UpValue[B] */
159
160OP_GETGLOBAL,/* A Bx R(A) := Gbl[Kst(Bx)] */
161OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */
162
163OP_SETGLOBAL,/* A Bx Gbl[Kst(Bx)] := R(A) */
164OP_SETUPVAL,/* A B UpValue[B] := R(A) */
165OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */
166
167OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */
168
169OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
170
171OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
172OP_SUB,/* A B C R(A) := RK(B) - RK(C) */
173OP_MUL,/* A B C R(A) := RK(B) * RK(C) */
174OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
175OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
176OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
177OP_UNM,/* A B R(A) := -R(B) */
178OP_NOT,/* A B R(A) := not R(B) */
179OP_LEN,/* A B R(A) := length of R(B) */
180
181OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
182
183OP_JMP,/* sBx pc+=sBx */
184
185OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
186OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
187OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
188
189OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
190OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
191
192OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
193OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
194OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
195
196OP_FORLOOP,/* A sBx R(A)+=R(A+2);
197 if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
198OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
199
200OP_TFORLOOP,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2));
201 if R(A+3) ~= nil then R(A+2)=R(A+3) else pc++ */
202OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
203
204OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/
205OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */
206
207OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
208} OpCode;

◆ OpMode

enum OpMode
Enumerator
iABC 
iABx 
iAsBx 

Definition at line 31 of file lua-5.1.5/src/lopcodes.h.

31{iABC, iABx, iAsBx}; /* basic instruction format */

Variable Documentation

◆ luaP_opmodes

LUAI_DATA const lu_byte luaP_opmodes[NUM_OPCODES]

Definition at line 252 of file lua-5.1.5/src/lopcodes.h.

◆ luaP_opnames

LUAI_DATA const char* const luaP_opnames[NUM_OPCODES+1]

Definition at line 261 of file lua-5.1.5/src/lopcodes.h.