The Battle for Wesnoth  1.15.1+dev
Macros | Enumerations | Variables
lopcodes.h File Reference
#include "llimits.h"
Include dependency graph for lopcodes.h:
This graph shows which files directly or indirectly include this file:

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_MOD, OP_POW, OP_DIV, OP_IDIV,
  OP_BAND, OP_BOR, OP_BXOR, OP_SHL,
  OP_SHR, OP_UNM, OP_BNOT, 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 lopcodes.h.

◆ CREATE_ABC

#define CREATE_ABC (   o,
  a,
  b,
  c 
)
Value:
#define a
#define cast(t, exp)
Definition: llimits.h:111
#define POS_OP
Definition: lopcodes.h:46
#define b
#define POS_C
Definition: lopcodes.h:48
#define POS_A
Definition: lopcodes.h:47
unsigned long Instruction
Definition: llimits.h:165
#define POS_B
Definition: lopcodes.h:49
mock_char c

Definition at line 116 of file lopcodes.h.

Referenced by luaK_codeABC(), and patchtestreg().

◆ CREATE_ABx

#define CREATE_ABx (   o,
  a,
  bc 
)
Value:
| (cast(Instruction, bc)<<POS_Bx))
#define a
#define POS_Bx
Definition: lopcodes.h:50
#define cast(t, exp)
Definition: llimits.h:111
#define POS_OP
Definition: lopcodes.h:46
#define POS_A
Definition: lopcodes.h:47
unsigned long Instruction
Definition: llimits.h:165

Definition at line 121 of file lopcodes.h.

Referenced by luaK_codeABx().

◆ CREATE_Ax

#define CREATE_Ax (   o,
  a 
)
Value:
#define POS_Ax
Definition: lopcodes.h:51
#define a
#define cast(t, exp)
Definition: llimits.h:111
#define POS_OP
Definition: lopcodes.h:46
unsigned long Instruction
Definition: llimits.h:165

Definition at line 125 of file lopcodes.h.

Referenced by codeextraarg().

◆ GET_OPCODE

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

◆ getarg

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

Definition at line 93 of file lopcodes.h.

◆ GETARG_A

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

◆ GETARG_Ax

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

Definition at line 109 of file lopcodes.h.

Referenced by getobjname(), and luaV_execute().

◆ GETARG_B

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

◆ GETARG_Bx

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

Definition at line 106 of file lopcodes.h.

Referenced by getobjname(), and luaV_execute().

◆ GETARG_C

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

Definition at line 103 of file lopcodes.h.

Referenced by getobjname(), luaK_setoneret(), luaV_execute(), luaV_finishOp(), and patchtestreg().

◆ GETARG_sBx

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

Definition at line 112 of file lopcodes.h.

Referenced by findsetreg(), getjump(), and luaV_execute().

◆ getBMode

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

Definition at line 284 of file lopcodes.h.

Referenced by luaK_codeABC().

◆ getCMode

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

Definition at line 285 of file lopcodes.h.

Referenced by luaK_codeABC(), and luaK_codeABx().

◆ getOpMode

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

Definition at line 283 of file lopcodes.h.

Referenced by luaK_codeABC(), and luaK_codeABx().

◆ INDEXK

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

Definition at line 140 of file lopcodes.h.

Referenced by kname().

◆ ISK

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

Definition at line 137 of file lopcodes.h.

Referenced by freereg(), and kname().

◆ LFIELDS_PER_FLUSH

#define LFIELDS_PER_FLUSH   50

Definition at line 294 of file lopcodes.h.

Referenced by closelistfield(), luaK_setlist(), and luaV_execute().

◆ MASK0

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

Definition at line 83 of file lopcodes.h.

◆ MASK1

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

Definition at line 80 of file lopcodes.h.

◆ MAXARG_A

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

Definition at line 74 of file lopcodes.h.

Referenced by luaK_codeABC(), and luaK_codeABx().

◆ MAXARG_Ax

#define MAXARG_Ax   MAX_INT

Definition at line 70 of file lopcodes.h.

Referenced by addk(), codeextraarg(), and luaK_setlist().

◆ MAXARG_B

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

Definition at line 75 of file lopcodes.h.

Referenced by luaK_codeABC().

◆ MAXARG_Bx

#define MAXARG_Bx   MAX_INT

Definition at line 63 of file lopcodes.h.

Referenced by addprototype(), luaK_codeABx(), and luaK_codek().

◆ MAXARG_C

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

Definition at line 76 of file lopcodes.h.

Referenced by luaK_codeABC(), and luaK_setlist().

◆ MAXARG_sBx

#define MAXARG_sBx   MAX_INT

Definition at line 64 of file lopcodes.h.

Referenced by fixjump().

◆ MAXINDEXRK

#define MAXINDEXRK   (BITRK - 1)

Definition at line 143 of file lopcodes.h.

Referenced by luaK_exp2RK().

◆ NO_REG

#define NO_REG   MAXARG_A

Definition at line 153 of file lopcodes.h.

Referenced by dischargejpc(), jumponcond(), luaK_patchlist(), patchtestreg(), and removevalues().

◆ NUM_OPCODES

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

Definition at line 237 of file lopcodes.h.

◆ POS_A

#define POS_A   (POS_OP + SIZE_OP)

Definition at line 47 of file lopcodes.h.

◆ POS_Ax

#define POS_Ax   POS_A

Definition at line 51 of file lopcodes.h.

◆ POS_B

#define POS_B   (POS_C + SIZE_C)

Definition at line 49 of file lopcodes.h.

◆ POS_Bx

#define POS_Bx   POS_C

Definition at line 50 of file lopcodes.h.

◆ POS_C

#define POS_C   (POS_A + SIZE_A)

Definition at line 48 of file lopcodes.h.

◆ POS_OP

#define POS_OP   0

Definition at line 46 of file lopcodes.h.

◆ RKASK

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

Definition at line 147 of file lopcodes.h.

Referenced by codecomp(), and luaK_exp2RK().

◆ SET_OPCODE

#define SET_OPCODE (   i,
 
)
Value:
((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \
#define SIZE_OP
Definition: lopcodes.h:44
#define MASK0(n, p)
Definition: lopcodes.h:83
#define cast(t, exp)
Definition: llimits.h:111
#define POS_OP
Definition: lopcodes.h:46
#define MASK1(n, p)
Definition: lopcodes.h:80
std::size_t i
Definition: function.cpp:933
unsigned long Instruction
Definition: llimits.h:165

Definition at line 90 of file lopcodes.h.

Referenced by retstat().

◆ setarg

#define setarg (   i,
  v,
  pos,
  size 
)
Value:
((i) = (((i)&MASK0(size,pos)) | \
((cast(Instruction, v)<<pos)&MASK1(size,pos))))
#define MASK0(n, p)
Definition: lopcodes.h:83
#define cast(t, exp)
Definition: llimits.h:111
std::size_t size(const std::string &str)
Length in characters of a UTF-8 string.
Definition: unicode.cpp:86
#define MASK1(n, p)
Definition: lopcodes.h:80
std::size_t i
Definition: function.cpp:933
unsigned long Instruction
Definition: llimits.h:165

Definition at line 94 of file lopcodes.h.

◆ SETARG_A

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

◆ SETARG_Ax

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

Definition at line 110 of file lopcodes.h.

◆ SETARG_B

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

Definition at line 101 of file lopcodes.h.

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

◆ SETARG_Bx

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

Definition at line 107 of file lopcodes.h.

◆ SETARG_C

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

Definition at line 104 of file lopcodes.h.

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

◆ SETARG_sBx

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

Definition at line 113 of file lopcodes.h.

Referenced by fixjump().

◆ SIZE_A

#define SIZE_A   8

Definition at line 41 of file lopcodes.h.

◆ SIZE_Ax

#define SIZE_Ax   (SIZE_C + SIZE_B + SIZE_A)

Definition at line 42 of file lopcodes.h.

◆ SIZE_B

#define SIZE_B   9

Definition at line 39 of file lopcodes.h.

◆ SIZE_Bx

#define SIZE_Bx   (SIZE_C + SIZE_B)

Definition at line 40 of file lopcodes.h.

◆ SIZE_C

#define SIZE_C   9

Definition at line 38 of file lopcodes.h.

◆ SIZE_OP

#define SIZE_OP   6

Definition at line 44 of file lopcodes.h.

◆ testAMode

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

Definition at line 286 of file lopcodes.h.

Referenced by findsetreg().

◆ testTMode

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

Definition at line 287 of file lopcodes.h.

Referenced by getjumpcontrol(), and negatecondition().

Enumeration Type Documentation

◆ OpArgMask

enum OpArgMask
Enumerator
OpArgN 
OpArgU 
OpArgR 
OpArgK 

Definition at line 274 of file lopcodes.h.

◆ 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_MOD 
OP_POW 
OP_DIV 
OP_IDIV 
OP_BAND 
OP_BOR 
OP_BXOR 
OP_SHL 
OP_SHR 
OP_UNM 
OP_BNOT 
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 167 of file lopcodes.h.

◆ OpMode

enum OpMode
Enumerator
iABC 
iABx 
iAsBx 
iAx 

Definition at line 32 of file lopcodes.h.

Variable Documentation

◆ luaP_opmodes

LUAI_DDEC const lu_byte luaP_opmodes[NUM_OPCODES]

Definition at line 281 of file lopcodes.h.

◆ luaP_opnames

LUAI_DDEC const char* const luaP_opnames[NUM_OPCODES+1]

Definition at line 290 of file lopcodes.h.