diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-06-29 15:49:02 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2004-06-29 15:49:02 -0300 |
| commit | 02a2c01ccd4dda04636a30cb60b6dd52511fd790 (patch) | |
| tree | e2d76d2647ca613715738f37ba1d532a149a187e /lopcodes.h | |
| parent | 23e08a68f51b36506c5ee8571e9dca01d67b7454 (diff) | |
| download | lua-02a2c01ccd4dda04636a30cb60b6dd52511fd790.tar.gz lua-02a2c01ccd4dda04636a30cb60b6dd52511fd790.tar.bz2 lua-02a2c01ccd4dda04636a30cb60b6dd52511fd790.zip | |
new way to code RK values
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 | ||
