diff options
Diffstat (limited to 'lopcodes.h')
-rw-r--r-- | lopcodes.h | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lopcodes.h,v 1.108 2004/05/17 12:34:00 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.109 2004/05/31 18:51:50 roberto Exp roberto $ |
3 | ** Opcodes for Lua virtual machine | 3 | ** Opcodes for Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -109,6 +109,23 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ | |||
109 | | (cast(Instruction, bc)<<POS_Bx)) | 109 | | (cast(Instruction, bc)<<POS_Bx)) |
110 | 110 | ||
111 | 111 | ||
112 | /* | ||
113 | ** Macros to operate RK indices | ||
114 | */ | ||
115 | |||
116 | /* this bit 1 means constant (0 means register) */ | ||
117 | #define BITRK (1 << (SIZE_B - 1)) | ||
118 | |||
119 | /* test whether value is a constant */ | ||
120 | #define ISK(x) ((x) & BITRK) | ||
121 | |||
122 | /* gets the index of the constant */ | ||
123 | #define INDEXK(r) ((int)(r) & ~BITRK) | ||
124 | |||
125 | #define MAXINDEXRK (BITRK - 1) | ||
126 | |||
127 | /* code a constant index as a RK value */ | ||
128 | #define RKASK(x) ((x) | BITRK) | ||
112 | 129 | ||
113 | 130 | ||
114 | /* | 131 | /* |
@@ -120,7 +137,7 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ | |||
120 | /* | 137 | /* |
121 | ** R(x) - register | 138 | ** R(x) - register |
122 | ** Kst(x) - constant (in constant table) | 139 | ** Kst(x) - constant (in constant table) |
123 | ** RK(x) == if x < MAXSTACK then R(x) else Kst(x-MAXSTACK) | 140 | ** RK(x) == if ISK(x) then Kst(INDEXK(x)) else R(x) |
124 | */ | 141 | */ |
125 | 142 | ||
126 | 143 | ||