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_Ax   (SIZE_C + SIZE_B + SIZE_A)
 
#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 POS_Ax   POS_A
 
#define MAXARG_Bx   MAX_INT
 
#define MAXARG_sBx   MAX_INT
 
#define MAXARG_Ax   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(i, pos, size)   (cast(int, ((i)>>pos) & MASK1(size,0)))
 
#define setarg(i, v, pos, size)
 
#define GETARG_A(i)   getarg(i, POS_A, SIZE_A)
 
#define SETARG_A(i, v)   setarg(i, v, POS_A, SIZE_A)
 
#define GETARG_B(i)   getarg(i, POS_B, SIZE_B)
 
#define SETARG_B(i, v)   setarg(i, v, POS_B, SIZE_B)
 
#define GETARG_C(i)   getarg(i, POS_C, SIZE_C)
 
#define SETARG_C(i, v)   setarg(i, v, POS_C, SIZE_C)
 
#define GETARG_Bx(i)   getarg(i, POS_Bx, SIZE_Bx)
 
#define SETARG_Bx(i, v)   setarg(i, v, POS_Bx, SIZE_Bx)
 
#define GETARG_Ax(i)   getarg(i, POS_Ax, SIZE_Ax)
 
#define SETARG_Ax(i, v)   setarg(i, v, POS_Ax, SIZE_Ax)
 
#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 CREATE_Ax(o, a)
 
#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_EXTRAARG) + 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 , iAx }
 
enum  OpCode {
  OP_MOVE , OP_LOADK , OP_LOADKX , OP_LOADBOOL ,
  OP_LOADNIL , OP_GETUPVAL , OP_GETTABUP , OP_GETTABLE ,
  OP_SETTABUP , 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_TFORCALL , OP_TFORLOOP ,
  OP_SETLIST , OP_CLOSURE , OP_VARARG , OP_EXTRAARG
}
 
enum  OpArgMask { OpArgN , OpArgU , OpArgR , OpArgK }
 

Variables

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

Macro Definition Documentation

◆ BITRK

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

Definition at line 134 of file lua-5.2.4/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 116 of file lua-5.2.4/src/lopcodes.h.

116#define CREATE_ABC(o,a,b,c) ((cast(Instruction, o)<<POS_OP) \
117 | (cast(Instruction, a)<<POS_A) \
118 | (cast(Instruction, b)<<POS_B) \
119 | (cast(Instruction, c)<<POS_C))

◆ CREATE_ABx

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

Definition at line 121 of file lua-5.2.4/src/lopcodes.h.

121#define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \
122 | (cast(Instruction, a)<<POS_A) \
123 | (cast(Instruction, bc)<<POS_Bx))

◆ CREATE_Ax

#define CREATE_Ax ( o,
a )
Value:
#define POS_Ax

Definition at line 125 of file lua-5.2.4/src/lopcodes.h.

125#define CREATE_Ax(o,a) ((cast(Instruction, o)<<POS_OP) \
126 | (cast(Instruction, a)<<POS_Ax))

Referenced by codeextraarg(), codeextraarg(), codeextraarg(), and luaK_settablesize().

◆ GET_OPCODE

#define GET_OPCODE ( i)    (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0)))

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

◆ getarg

#define getarg ( i,
pos,
size )   (cast(int, ((i)>>pos) & MASK1(size,0)))

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

◆ GETARG_A

#define GETARG_A ( i)    getarg(i, POS_A, SIZE_A)

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

◆ GETARG_Ax

#define GETARG_Ax ( i)    getarg(i, POS_Ax, SIZE_Ax)

◆ GETARG_B

#define GETARG_B ( i)    getarg(i, POS_B, SIZE_B)

Definition at line 100 of file lua-5.2.4/src/lopcodes.h.

◆ GETARG_Bx

#define GETARG_Bx ( i)    getarg(i, POS_Bx, SIZE_Bx)

Definition at line 106 of file lua-5.2.4/src/lopcodes.h.

◆ GETARG_C

#define GETARG_C ( i)    getarg(i, POS_C, SIZE_C)

Definition at line 103 of file lua-5.2.4/src/lopcodes.h.

◆ GETARG_sBx

#define GETARG_sBx ( i)    (GETARG_Bx(i)-MAXARG_sBx)

Definition at line 112 of file lua-5.2.4/src/lopcodes.h.

◆ getBMode

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

Definition at line 275 of file lua-5.2.4/src/lopcodes.h.

◆ getCMode

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

Definition at line 276 of file lua-5.2.4/src/lopcodes.h.

◆ getOpMode

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

Definition at line 274 of file lua-5.2.4/src/lopcodes.h.

◆ INDEXK

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

Definition at line 140 of file lua-5.2.4/src/lopcodes.h.

◆ ISK

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

Definition at line 137 of file lua-5.2.4/src/lopcodes.h.

◆ LFIELDS_PER_FLUSH

#define LFIELDS_PER_FLUSH   50

Definition at line 285 of file lua-5.2.4/src/lopcodes.h.

◆ MASK0

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

Definition at line 83 of file lua-5.2.4/src/lopcodes.h.

◆ MASK1

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

Definition at line 80 of file lua-5.2.4/src/lopcodes.h.

◆ MAXARG_A

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

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

◆ MAXARG_Ax

#define MAXARG_Ax   MAX_INT

◆ MAXARG_B

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

Definition at line 75 of file lua-5.2.4/src/lopcodes.h.

◆ MAXARG_Bx

#define MAXARG_Bx   MAX_INT

Definition at line 63 of file lua-5.2.4/src/lopcodes.h.

◆ MAXARG_C

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

Definition at line 76 of file lua-5.2.4/src/lopcodes.h.

◆ MAXARG_sBx

#define MAXARG_sBx   MAX_INT

Definition at line 64 of file lua-5.2.4/src/lopcodes.h.

◆ MAXINDEXRK

#define MAXINDEXRK   (BITRK - 1)

Definition at line 142 of file lua-5.2.4/src/lopcodes.h.

◆ NO_REG

#define NO_REG   MAXARG_A

Definition at line 151 of file lua-5.2.4/src/lopcodes.h.

◆ NUM_OPCODES

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

Definition at line 228 of file lua-5.2.4/src/lopcodes.h.

◆ POS_A

#define POS_A   (POS_OP + SIZE_OP)

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

◆ POS_Ax

#define POS_Ax   POS_A

Definition at line 51 of file lua-5.2.4/src/lopcodes.h.

◆ POS_B

#define POS_B   (POS_C + SIZE_C)

Definition at line 49 of file lua-5.2.4/src/lopcodes.h.

◆ POS_Bx

#define POS_Bx   POS_C

Definition at line 50 of file lua-5.2.4/src/lopcodes.h.

◆ POS_C

#define POS_C   (POS_A + SIZE_A)

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

◆ POS_OP

#define POS_OP   0

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

◆ RKASK

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

Definition at line 145 of file lua-5.2.4/src/lopcodes.h.

◆ 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 90 of file lua-5.2.4/src/lopcodes.h.

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

◆ setarg

#define setarg ( i,
v,
pos,
size )
Value:
((i) = (((i)&MASK0(size,pos)) | \
((cast(Instruction, v)<<pos)&MASK1(size,pos))))

Definition at line 94 of file lua-5.2.4/src/lopcodes.h.

94#define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \
95 ((cast(Instruction, v)<<pos)&MASK1(size,pos))))

◆ SETARG_A

#define SETARG_A ( i,
v )   setarg(i, v, POS_A, SIZE_A)

Definition at line 98 of file lua-5.2.4/src/lopcodes.h.

◆ SETARG_Ax

#define SETARG_Ax ( i,
v )   setarg(i, v, POS_Ax, SIZE_Ax)

Definition at line 110 of file lua-5.2.4/src/lopcodes.h.

◆ SETARG_B

#define SETARG_B ( i,
v )   setarg(i, v, POS_B, SIZE_B)

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

◆ SETARG_Bx

#define SETARG_Bx ( i,
v )   setarg(i, v, POS_Bx, SIZE_Bx)

Definition at line 107 of file lua-5.2.4/src/lopcodes.h.

◆ SETARG_C

#define SETARG_C ( i,
v )   setarg(i, v, POS_C, SIZE_C)

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

◆ SETARG_sBx

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

Definition at line 113 of file lua-5.2.4/src/lopcodes.h.

◆ SIZE_A

#define SIZE_A   8

Definition at line 41 of file lua-5.2.4/src/lopcodes.h.

◆ SIZE_Ax

#define SIZE_Ax   (SIZE_C + SIZE_B + SIZE_A)

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

◆ SIZE_B

#define SIZE_B   9

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

◆ SIZE_Bx

#define SIZE_Bx   (SIZE_C + SIZE_B)

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

◆ SIZE_C

#define SIZE_C   9

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

◆ SIZE_OP

#define SIZE_OP   6

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

◆ testAMode

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

Definition at line 277 of file lua-5.2.4/src/lopcodes.h.

◆ testTMode

#define testTMode ( m)    (luaP_opmodes[m] & (1 << 7))

Definition at line 278 of file lua-5.2.4/src/lopcodes.h.

Enumeration Type Documentation

◆ OpArgMask

enum OpArgMask
Enumerator
OpArgN 
OpArgU 
OpArgR 
OpArgK 

Definition at line 265 of file lua-5.2.4/src/lopcodes.h.

265 {
266 OpArgN, /* argument is not used */
267 OpArgU, /* argument is used */
268 OpArgR, /* argument is a register or a jump offset */
269 OpArgK /* argument is a constant or register/constant */
270};

◆ OpCode

enum OpCode
Enumerator
OP_MOVE 
OP_LOADK 
OP_LOADKX 
OP_LOADBOOL 
OP_LOADNIL 
OP_GETUPVAL 
OP_GETTABUP 
OP_GETTABLE 
OP_SETTABUP 
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_TFORCALL 
OP_TFORLOOP 
OP_SETLIST 
OP_CLOSURE 
OP_VARARG 
OP_EXTRAARG 

Definition at line 165 of file lua-5.2.4/src/lopcodes.h.

165 {
166/*----------------------------------------------------------------------
167name args description
168------------------------------------------------------------------------*/
169OP_MOVE,/* A B R(A) := R(B) */
170OP_LOADK,/* A Bx R(A) := Kst(Bx) */
171OP_LOADKX,/* A R(A) := Kst(extra arg) */
172OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */
173OP_LOADNIL,/* A B R(A), R(A+1), ..., R(A+B) := nil */
174OP_GETUPVAL,/* A B R(A) := UpValue[B] */
175
176OP_GETTABUP,/* A B C R(A) := UpValue[B][RK(C)] */
177OP_GETTABLE,/* A B C R(A) := R(B)[RK(C)] */
178
179OP_SETTABUP,/* A B C UpValue[A][RK(B)] := RK(C) */
180OP_SETUPVAL,/* A B UpValue[B] := R(A) */
181OP_SETTABLE,/* A B C R(A)[RK(B)] := RK(C) */
182
183OP_NEWTABLE,/* A B C R(A) := {} (size = B,C) */
184
185OP_SELF,/* A B C R(A+1) := R(B); R(A) := R(B)[RK(C)] */
186
187OP_ADD,/* A B C R(A) := RK(B) + RK(C) */
188OP_SUB,/* A B C R(A) := RK(B) - RK(C) */
189OP_MUL,/* A B C R(A) := RK(B) * RK(C) */
190OP_DIV,/* A B C R(A) := RK(B) / RK(C) */
191OP_MOD,/* A B C R(A) := RK(B) % RK(C) */
192OP_POW,/* A B C R(A) := RK(B) ^ RK(C) */
193OP_UNM,/* A B R(A) := -R(B) */
194OP_NOT,/* A B R(A) := not R(B) */
195OP_LEN,/* A B R(A) := length of R(B) */
196
197OP_CONCAT,/* A B C R(A) := R(B).. ... ..R(C) */
198
199OP_JMP,/* A sBx pc+=sBx; if (A) close all upvalues >= R(A - 1) */
200OP_EQ,/* A B C if ((RK(B) == RK(C)) ~= A) then pc++ */
201OP_LT,/* A B C if ((RK(B) < RK(C)) ~= A) then pc++ */
202OP_LE,/* A B C if ((RK(B) <= RK(C)) ~= A) then pc++ */
203
204OP_TEST,/* A C if not (R(A) <=> C) then pc++ */
205OP_TESTSET,/* A B C if (R(B) <=> C) then R(A) := R(B) else pc++ */
206
207OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
208OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */
209OP_RETURN,/* A B return R(A), ... ,R(A+B-2) (see note) */
210
211OP_FORLOOP,/* A sBx R(A)+=R(A+2);
212 if R(A) <?= R(A+1) then { pc+=sBx; R(A+3)=R(A) }*/
213OP_FORPREP,/* A sBx R(A)-=R(A+2); pc+=sBx */
214
215OP_TFORCALL,/* A C R(A+3), ... ,R(A+2+C) := R(A)(R(A+1), R(A+2)); */
216OP_TFORLOOP,/* A sBx if R(A+1) ~= nil then { R(A)=R(A+1); pc += sBx }*/
217
218OP_SETLIST,/* A B C R(A)[(C-1)*FPF+i] := R(A+i), 1 <= i <= B */
219
220OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx]) */
221
222OP_VARARG,/* A B R(A), R(A+1), ..., R(A+B-2) = vararg */
223
224OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
225} OpCode;

◆ OpMode

enum OpMode
Enumerator
iABC 
iABx 
iAsBx 
iAx 

Definition at line 32 of file lua-5.2.4/src/lopcodes.h.

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

Variable Documentation

◆ luaP_opmodes

LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES]

Definition at line 272 of file lua-5.2.4/src/lopcodes.h.

◆ luaP_opnames

LUAI_DDEC const char* const luaP_opnames[NUM_OPCODES+1]

Definition at line 281 of file lua-5.2.4/src/lopcodes.h.