diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-10 15:37:44 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-03-10 15:37:44 -0300 |
| commit | 73aa465a8ed8dee6c6a27a6f8b2f51227b70789d (patch) | |
| tree | 496a63ffffe0312f1d0b9882d97944fa38ed7801 /lcode.c | |
| parent | 3d0577f4b98908be3f2d697ab75c5fbbd3f6999b (diff) | |
| download | lua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.tar.gz lua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.tar.bz2 lua-73aa465a8ed8dee6c6a27a6f8b2f51227b70789d.zip | |
some name changes
Diffstat (limited to 'lcode.c')
| -rw-r--r-- | lcode.c | 172 |
1 files changed, 86 insertions, 86 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 1.8 2000/03/09 13:57:37 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 1.9 2000/03/10 14:38:10 roberto Exp roberto $ |
| 3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -32,8 +32,8 @@ static Instruction *previous_instruction (LexState *ls) { | |||
| 32 | if (fs->pc > fs->lasttarget) /* no jumps to current position? */ | 32 | if (fs->pc > fs->lasttarget) /* no jumps to current position? */ |
| 33 | return &fs->f->code[fs->pc-1]; /* returns previous instruction */ | 33 | return &fs->f->code[fs->pc-1]; /* returns previous instruction */ |
| 34 | else { | 34 | else { |
| 35 | static Instruction dummy = CREATE_0(ENDCODE); | 35 | static Instruction dummy = CREATE_0(OP_END); |
| 36 | return &dummy; /* no optimizations after an `ENDCODE' */ | 36 | return &dummy; /* no optimizations after an `END' */ |
| 37 | } | 37 | } |
| 38 | } | 38 | } |
| 39 | 39 | ||
| @@ -49,10 +49,10 @@ int luaK_primitivecode (LexState *ls, Instruction i) { | |||
| 49 | static void luaK_minus (LexState *ls) { | 49 | static void luaK_minus (LexState *ls) { |
| 50 | Instruction *previous = previous_instruction(ls); | 50 | Instruction *previous = previous_instruction(ls); |
| 51 | switch(GET_OPCODE(*previous)) { | 51 | switch(GET_OPCODE(*previous)) { |
| 52 | case PUSHINT: SETARG_S(*previous, -GETARG_S(*previous)); return; | 52 | case OP_PUSHINT: SETARG_S(*previous, -GETARG_S(*previous)); return; |
| 53 | case PUSHNUM: SET_OPCODE(*previous, PUSHNEGNUM); return; | 53 | case OP_PUSHNUM: SET_OPCODE(*previous, OP_PUSHNEGNUM); return; |
| 54 | case PUSHNEGNUM: SET_OPCODE(*previous, PUSHNUM); return; | 54 | case OP_PUSHNEGNUM: SET_OPCODE(*previous, OP_PUSHNUM); return; |
| 55 | default: luaK_primitivecode(ls, CREATE_0(MINUSOP)); | 55 | default: luaK_primitivecode(ls, CREATE_0(OP_MINUS)); |
| 56 | } | 56 | } |
| 57 | } | 57 | } |
| 58 | 58 | ||
| @@ -61,8 +61,8 @@ static void luaK_gettable (LexState *ls) { | |||
| 61 | Instruction *previous = previous_instruction(ls); | 61 | Instruction *previous = previous_instruction(ls); |
| 62 | luaK_deltastack(ls, -1); | 62 | luaK_deltastack(ls, -1); |
| 63 | switch(GET_OPCODE(*previous)) { | 63 | switch(GET_OPCODE(*previous)) { |
| 64 | case PUSHSTRING: SET_OPCODE(*previous, GETDOTTED); break; | 64 | case OP_PUSHSTRING: SET_OPCODE(*previous, OP_GETDOTTED); break; |
| 65 | default: luaK_primitivecode(ls, CREATE_0(GETTABLE)); | 65 | default: luaK_primitivecode(ls, CREATE_0(OP_GETTABLE)); |
| 66 | } | 66 | } |
| 67 | } | 67 | } |
| 68 | 68 | ||
| @@ -71,8 +71,8 @@ static void luaK_add (LexState *ls) { | |||
| 71 | Instruction *previous = previous_instruction(ls); | 71 | Instruction *previous = previous_instruction(ls); |
| 72 | luaK_deltastack(ls, -1); | 72 | luaK_deltastack(ls, -1); |
| 73 | switch(GET_OPCODE(*previous)) { | 73 | switch(GET_OPCODE(*previous)) { |
| 74 | case PUSHINT: SET_OPCODE(*previous, ADDI); break; | 74 | case OP_PUSHINT: SET_OPCODE(*previous, OP_ADDI); break; |
| 75 | default: luaK_primitivecode(ls, CREATE_0(ADDOP)); | 75 | default: luaK_primitivecode(ls, CREATE_0(OP_ADD)); |
| 76 | } | 76 | } |
| 77 | } | 77 | } |
| 78 | 78 | ||
| @@ -81,11 +81,11 @@ static void luaK_sub (LexState *ls) { | |||
| 81 | Instruction *previous = previous_instruction(ls); | 81 | Instruction *previous = previous_instruction(ls); |
| 82 | luaK_deltastack(ls, -1); | 82 | luaK_deltastack(ls, -1); |
| 83 | switch(GET_OPCODE(*previous)) { | 83 | switch(GET_OPCODE(*previous)) { |
| 84 | case PUSHINT: | 84 | case OP_PUSHINT: |
| 85 | SET_OPCODE(*previous, ADDI); | 85 | SET_OPCODE(*previous, OP_ADDI); |
| 86 | SETARG_S(*previous, -GETARG_S(*previous)); | 86 | SETARG_S(*previous, -GETARG_S(*previous)); |
| 87 | break; | 87 | break; |
| 88 | default: luaK_primitivecode(ls, CREATE_0(SUBOP)); | 88 | default: luaK_primitivecode(ls, CREATE_0(OP_SUB)); |
| 89 | } | 89 | } |
| 90 | } | 90 | } |
| 91 | 91 | ||
| @@ -94,43 +94,43 @@ static void luaK_conc (LexState *ls) { | |||
| 94 | Instruction *previous = previous_instruction(ls); | 94 | Instruction *previous = previous_instruction(ls); |
| 95 | luaK_deltastack(ls, -1); | 95 | luaK_deltastack(ls, -1); |
| 96 | switch(GET_OPCODE(*previous)) { | 96 | switch(GET_OPCODE(*previous)) { |
| 97 | case CONCOP: SETARG_U(*previous, GETARG_U(*previous)+1); break; | 97 | case OP_CONC: SETARG_U(*previous, GETARG_U(*previous)+1); break; |
| 98 | default: luaK_primitivecode(ls, CREATE_U(CONCOP, 2)); | 98 | default: luaK_primitivecode(ls, CREATE_U(OP_CONC, 2)); |
| 99 | } | 99 | } |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | 102 | ||
| 103 | static void luaK_eq (LexState *ls) { | 103 | static void luaK_eq (LexState *ls) { |
| 104 | Instruction *previous = previous_instruction(ls); | 104 | Instruction *previous = previous_instruction(ls); |
| 105 | if (*previous == CREATE_U(PUSHNIL, 1)) { | 105 | if (*previous == CREATE_U(OP_PUSHNIL, 1)) { |
| 106 | *previous = CREATE_0(NOTOP); | 106 | *previous = CREATE_0(OP_NOT); |
| 107 | luaK_deltastack(ls, -1); /* undo effect of PUSHNIL */ | 107 | luaK_deltastack(ls, -1); /* undo effect of PUSHNIL */ |
| 108 | } | 108 | } |
| 109 | else | 109 | else |
| 110 | luaK_S(ls, IFEQJMP, 0, -2); | 110 | luaK_S(ls, OP_IFEQJMP, 0, -2); |
| 111 | } | 111 | } |
| 112 | 112 | ||
| 113 | 113 | ||
| 114 | static void luaK_neq (LexState *ls) { | 114 | static void luaK_neq (LexState *ls) { |
| 115 | Instruction *previous = previous_instruction(ls); | 115 | Instruction *previous = previous_instruction(ls); |
| 116 | if (*previous == CREATE_U(PUSHNIL, 1)) { | 116 | if (*previous == CREATE_U(OP_PUSHNIL, 1)) { |
| 117 | ls->fs->pc--; /* remove PUSHNIL */ | 117 | ls->fs->pc--; /* remove PUSHNIL */ |
| 118 | luaK_deltastack(ls, -1); /* undo effect of PUSHNIL */ | 118 | luaK_deltastack(ls, -1); /* undo effect of PUSHNIL */ |
| 119 | } | 119 | } |
| 120 | else | 120 | else |
| 121 | luaK_S(ls, IFNEQJMP, 0, -2); | 121 | luaK_S(ls, OP_IFNEQJMP, 0, -2); |
| 122 | } | 122 | } |
| 123 | 123 | ||
| 124 | 124 | ||
| 125 | void luaK_retcode (LexState *ls, int nlocals, int nexps) { | 125 | void luaK_retcode (LexState *ls, int nlocals, int nexps) { |
| 126 | Instruction *previous = previous_instruction(ls); | 126 | Instruction *previous = previous_instruction(ls); |
| 127 | if (nexps > 0 && GET_OPCODE(*previous) == CALL) { | 127 | if (nexps > 0 && GET_OPCODE(*previous) == OP_CALL) { |
| 128 | LUA_ASSERT(ls->L, GETARG_B(*previous) == MULT_RET, "call should be open"); | 128 | LUA_ASSERT(ls->L, GETARG_B(*previous) == MULT_RET, "call should be open"); |
| 129 | SET_OPCODE(*previous, TAILCALL); | 129 | SET_OPCODE(*previous, OP_TAILCALL); |
| 130 | SETARG_B(*previous, nlocals); | 130 | SETARG_B(*previous, nlocals); |
| 131 | } | 131 | } |
| 132 | else | 132 | else |
| 133 | luaK_primitivecode(ls, CREATE_U(RETCODE, nlocals)); | 133 | luaK_primitivecode(ls, CREATE_U(OP_RETURN, nlocals)); |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | 136 | ||
| @@ -138,8 +138,8 @@ static void luaK_pushnil (LexState *ls, int n) { | |||
| 138 | Instruction *previous = previous_instruction(ls); | 138 | Instruction *previous = previous_instruction(ls); |
| 139 | luaK_deltastack(ls, n); | 139 | luaK_deltastack(ls, n); |
| 140 | switch(GET_OPCODE(*previous)) { | 140 | switch(GET_OPCODE(*previous)) { |
| 141 | case PUSHNIL: SETARG_U(*previous, GETARG_U(*previous)+n); break; | 141 | case OP_PUSHNIL: SETARG_U(*previous, GETARG_U(*previous)+n); break; |
| 142 | default: luaK_primitivecode(ls, CREATE_U(PUSHNIL, n)); | 142 | default: luaK_primitivecode(ls, CREATE_U(OP_PUSHNIL, n)); |
| 143 | } | 143 | } |
| 144 | } | 144 | } |
| 145 | 145 | ||
| @@ -181,7 +181,7 @@ void luaK_deltastack (LexState *ls, int delta) { | |||
| 181 | 181 | ||
| 182 | 182 | ||
| 183 | void luaK_kstr (LexState *ls, int c) { | 183 | void luaK_kstr (LexState *ls, int c) { |
| 184 | luaK_U(ls, PUSHSTRING, c, 1); | 184 | luaK_U(ls, OP_PUSHSTRING, c, 1); |
| 185 | } | 185 | } |
| 186 | 186 | ||
| 187 | 187 | ||
| @@ -189,32 +189,32 @@ void luaK_kstr (LexState *ls, int c) { | |||
| 189 | #define LOOKBACKNUMS 20 /* arbitrary limit */ | 189 | #define LOOKBACKNUMS 20 /* arbitrary limit */ |
| 190 | #endif | 190 | #endif |
| 191 | 191 | ||
| 192 | static int real_constant (LexState *ls, real r) { | 192 | static int real_constant (LexState *ls, Number r) { |
| 193 | /* check whether `r' has appeared within the last LOOKBACKNUMS entries */ | 193 | /* check whether `r' has appeared within the last LOOKBACKNUMS entries */ |
| 194 | TProtoFunc *f = ls->fs->f; | 194 | Proto *f = ls->fs->f; |
| 195 | int c = f->nknum; | 195 | int c = f->nknum; |
| 196 | int lim = c < LOOKBACKNUMS ? 0 : c-LOOKBACKNUMS; | 196 | int lim = c < LOOKBACKNUMS ? 0 : c-LOOKBACKNUMS; |
| 197 | while (--c >= lim) | 197 | while (--c >= lim) |
| 198 | if (f->knum[c] == r) return c; | 198 | if (f->knum[c] == r) return c; |
| 199 | /* not found; create a new entry */ | 199 | /* not found; create a new entry */ |
| 200 | luaM_growvector(ls->L, f->knum, f->nknum, 1, real, constantEM, MAXARG_U); | 200 | luaM_growvector(ls->L, f->knum, f->nknum, 1, Number, constantEM, MAXARG_U); |
| 201 | c = f->nknum++; | 201 | c = f->nknum++; |
| 202 | f->knum[c] = r; | 202 | f->knum[c] = r; |
| 203 | return c; | 203 | return c; |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | 206 | ||
| 207 | void luaK_number (LexState *ls, real f) { | 207 | void luaK_number (LexState *ls, Number f) { |
| 208 | if (f <= (real)MAXARG_S && (int)f == f) | 208 | if (f <= (Number)MAXARG_S && (int)f == f) |
| 209 | luaK_S(ls, PUSHINT, (int)f, 1); /* f has a short integer value */ | 209 | luaK_S(ls, OP_PUSHINT, (int)f, 1); /* f has a short integer value */ |
| 210 | else | 210 | else |
| 211 | luaK_U(ls, PUSHNUM, real_constant(ls, f), 1); | 211 | luaK_U(ls, OP_PUSHNUM, real_constant(ls, f), 1); |
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | 214 | ||
| 215 | void luaK_adjuststack (LexState *ls, int n) { | 215 | void luaK_adjuststack (LexState *ls, int n) { |
| 216 | if (n > 0) | 216 | if (n > 0) |
| 217 | luaK_U(ls, POP, n, -n); | 217 | luaK_U(ls, OP_POP, n, -n); |
| 218 | else if (n < 0) | 218 | else if (n < 0) |
| 219 | luaK_pushnil(ls, -n); | 219 | luaK_pushnil(ls, -n); |
| 220 | } | 220 | } |
| @@ -223,7 +223,7 @@ void luaK_adjuststack (LexState *ls, int n) { | |||
| 223 | int luaK_lastisopen (LexState *ls) { | 223 | int luaK_lastisopen (LexState *ls) { |
| 224 | /* check whether last instruction is an (open) function call */ | 224 | /* check whether last instruction is an (open) function call */ |
| 225 | Instruction *i = previous_instruction(ls); | 225 | Instruction *i = previous_instruction(ls); |
| 226 | if (GET_OPCODE(*i) == CALL) { | 226 | if (GET_OPCODE(*i) == OP_CALL) { |
| 227 | LUA_ASSERT(ls->L, GETARG_B(*i) == MULT_RET, "call should be open"); | 227 | LUA_ASSERT(ls->L, GETARG_B(*i) == MULT_RET, "call should be open"); |
| 228 | return 1; | 228 | return 1; |
| 229 | } | 229 | } |
| @@ -233,7 +233,7 @@ int luaK_lastisopen (LexState *ls) { | |||
| 233 | 233 | ||
| 234 | void luaK_setcallreturns (LexState *ls, int nresults) { | 234 | void luaK_setcallreturns (LexState *ls, int nresults) { |
| 235 | Instruction *i = previous_instruction(ls); | 235 | Instruction *i = previous_instruction(ls); |
| 236 | if (GET_OPCODE(*i) == CALL) { /* expression is a function call? */ | 236 | if (GET_OPCODE(*i) == OP_CALL) { /* expression is a function call? */ |
| 237 | LUA_ASSERT(ls->L, GETARG_B(*i) == MULT_RET, "call should be open"); | 237 | LUA_ASSERT(ls->L, GETARG_B(*i) == MULT_RET, "call should be open"); |
| 238 | SETARG_B(*i, nresults); /* set nresults */ | 238 | SETARG_B(*i, nresults); /* set nresults */ |
| 239 | luaK_deltastack(ls, nresults); /* push results */ | 239 | luaK_deltastack(ls, nresults); /* push results */ |
| @@ -249,10 +249,10 @@ static void assertglobal (LexState *ls, int index) { | |||
| 249 | static int discharge (LexState *ls, expdesc *var) { | 249 | static int discharge (LexState *ls, expdesc *var) { |
| 250 | switch (var->k) { | 250 | switch (var->k) { |
| 251 | case VLOCAL: | 251 | case VLOCAL: |
| 252 | luaK_U(ls, PUSHLOCAL, var->u.index, 1); | 252 | luaK_U(ls, OP_PUSHLOCAL, var->u.index, 1); |
| 253 | break; | 253 | break; |
| 254 | case VGLOBAL: | 254 | case VGLOBAL: |
| 255 | luaK_U(ls, GETGLOBAL, var->u.index, 1); | 255 | luaK_U(ls, OP_GETGLOBAL, var->u.index, 1); |
| 256 | assertglobal(ls, var->u.index); /* make sure that there is a global */ | 256 | assertglobal(ls, var->u.index); /* make sure that there is a global */ |
| 257 | break; | 257 | break; |
| 258 | case VINDEXED: | 258 | case VINDEXED: |
| @@ -278,14 +278,14 @@ static void discharge1 (LexState *ls, expdesc *var) { | |||
| 278 | void luaK_storevar (LexState *ls, const expdesc *var) { | 278 | void luaK_storevar (LexState *ls, const expdesc *var) { |
| 279 | switch (var->k) { | 279 | switch (var->k) { |
| 280 | case VLOCAL: | 280 | case VLOCAL: |
| 281 | luaK_U(ls, SETLOCAL, var->u.index, -1); | 281 | luaK_U(ls, OP_SETLOCAL, var->u.index, -1); |
| 282 | break; | 282 | break; |
| 283 | case VGLOBAL: | 283 | case VGLOBAL: |
| 284 | luaK_U(ls, SETGLOBAL, var->u.index, -1); | 284 | luaK_U(ls, OP_SETGLOBAL, var->u.index, -1); |
| 285 | assertglobal(ls, var->u.index); /* make sure that there is a global */ | 285 | assertglobal(ls, var->u.index); /* make sure that there is a global */ |
| 286 | break; | 286 | break; |
| 287 | case VINDEXED: | 287 | case VINDEXED: |
| 288 | luaK_0(ls, SETTABLEPOP, -3); | 288 | luaK_0(ls, OP_SETTABLEPOP, -3); |
| 289 | break; | 289 | break; |
| 290 | default: | 290 | default: |
| 291 | LUA_INTERNALERROR(ls->L, "invalid var kind to store"); | 291 | LUA_INTERNALERROR(ls->L, "invalid var kind to store"); |
| @@ -295,17 +295,17 @@ void luaK_storevar (LexState *ls, const expdesc *var) { | |||
| 295 | 295 | ||
| 296 | static OpCode invertjump (OpCode op) { | 296 | static OpCode invertjump (OpCode op) { |
| 297 | switch (op) { | 297 | switch (op) { |
| 298 | case IFNEQJMP: return IFEQJMP; | 298 | case OP_IFNEQJMP: return OP_IFEQJMP; |
| 299 | case IFEQJMP: return IFNEQJMP; | 299 | case OP_IFEQJMP: return OP_IFNEQJMP; |
| 300 | case IFLTJMP: return IFGEJMP; | 300 | case OP_IFLTJMP: return OP_IFGEJMP; |
| 301 | case IFLEJMP: return IFGTJMP; | 301 | case OP_IFLEJMP: return OP_IFGTJMP; |
| 302 | case IFGTJMP: return IFLEJMP; | 302 | case OP_IFGTJMP: return OP_IFLEJMP; |
| 303 | case IFGEJMP: return IFLTJMP; | 303 | case OP_IFGEJMP: return OP_IFLTJMP; |
| 304 | case IFTJMP: case ONTJMP: return IFFJMP; | 304 | case OP_IFTJMP: case OP_ONTJMP: return OP_IFFJMP; |
| 305 | case IFFJMP: case ONFJMP: return IFTJMP; | 305 | case OP_IFFJMP: case OP_ONFJMP: return OP_IFTJMP; |
| 306 | default: | 306 | default: |
| 307 | LUA_INTERNALERROR(NULL, "invalid jump instruction"); | 307 | LUA_INTERNALERROR(NULL, "invalid jump instruction"); |
| 308 | return ENDCODE; /* to avoid warnings */ | 308 | return OP_END; /* to avoid warnings */ |
| 309 | } | 309 | } |
| 310 | } | 310 | } |
| 311 | 311 | ||
| @@ -313,7 +313,7 @@ static OpCode invertjump (OpCode op) { | |||
| 313 | static void luaK_jump (LexState *ls, OpCode jump) { | 313 | static void luaK_jump (LexState *ls, OpCode jump) { |
| 314 | Instruction *previous = previous_instruction(ls); | 314 | Instruction *previous = previous_instruction(ls); |
| 315 | luaK_deltastack(ls, -1); | 315 | luaK_deltastack(ls, -1); |
| 316 | if (*previous == CREATE_0(NOTOP)) | 316 | if (*previous == CREATE_0(OP_NOT)) |
| 317 | *previous = CREATE_S(invertjump(jump), 0); | 317 | *previous = CREATE_S(invertjump(jump), 0); |
| 318 | else | 318 | else |
| 319 | luaK_primitivecode(ls, CREATE_S(jump, 0)); | 319 | luaK_primitivecode(ls, CREATE_S(jump, 0)); |
| @@ -342,10 +342,10 @@ static void luaK_patchlistaux (LexState *ls, int list, int target, | |||
| 342 | SETARG_S(*i, special_target-(list+1)); | 342 | SETARG_S(*i, special_target-(list+1)); |
| 343 | else { | 343 | else { |
| 344 | SETARG_S(*i, target-(list+1)); /* do the patch */ | 344 | SETARG_S(*i, target-(list+1)); /* do the patch */ |
| 345 | if (op == ONTJMP) /* remove eventual values */ | 345 | if (op == OP_ONTJMP) /* remove eventual values */ |
| 346 | SET_OPCODE(*i, IFTJMP); | 346 | SET_OPCODE(*i, OP_IFTJMP); |
| 347 | else if (op == ONFJMP) | 347 | else if (op == OP_ONFJMP) |
| 348 | SET_OPCODE(*i, IFFJMP); | 348 | SET_OPCODE(*i, OP_IFFJMP); |
| 349 | } | 349 | } |
| 350 | if (next == 0) return; | 350 | if (next == 0) return; |
| 351 | list += next+1; | 351 | list += next+1; |
| @@ -355,7 +355,7 @@ static void luaK_patchlistaux (LexState *ls, int list, int target, | |||
| 355 | 355 | ||
| 356 | 356 | ||
| 357 | void luaK_patchlist (LexState *ls, int list, int target) { | 357 | void luaK_patchlist (LexState *ls, int list, int target) { |
| 358 | luaK_patchlistaux(ls, list, target, ENDCODE, 0); | 358 | luaK_patchlistaux(ls, list, target, OP_END, 0); |
| 359 | } | 359 | } |
| 360 | 360 | ||
| 361 | 361 | ||
| @@ -399,7 +399,7 @@ void luaK_goiftrue (LexState *ls, expdesc *v, int keepvalue) { | |||
| 399 | if (ISJUMP(GET_OPCODE(*previous))) | 399 | if (ISJUMP(GET_OPCODE(*previous))) |
| 400 | SET_OPCODE(*previous, invertjump(GET_OPCODE(*previous))); | 400 | SET_OPCODE(*previous, invertjump(GET_OPCODE(*previous))); |
| 401 | else { | 401 | else { |
| 402 | OpCode jump = keepvalue ? ONFJMP : IFFJMP; | 402 | OpCode jump = keepvalue ? OP_ONFJMP : OP_IFFJMP; |
| 403 | luaK_jump(ls, jump); | 403 | luaK_jump(ls, jump); |
| 404 | } | 404 | } |
| 405 | insert_last(fs, &v->u.l.f); | 405 | insert_last(fs, &v->u.l.f); |
| @@ -414,7 +414,7 @@ void luaK_goiffalse (LexState *ls, expdesc *v, int keepvalue) { | |||
| 414 | discharge1(ls, v); | 414 | discharge1(ls, v); |
| 415 | previous = fs->f->code[fs->pc-1]; | 415 | previous = fs->f->code[fs->pc-1]; |
| 416 | if (!ISJUMP(GET_OPCODE(previous))) { | 416 | if (!ISJUMP(GET_OPCODE(previous))) { |
| 417 | OpCode jump = keepvalue ? ONTJMP : IFTJMP; | 417 | OpCode jump = keepvalue ? OP_ONTJMP : OP_IFTJMP; |
| 418 | luaK_jump(ls, jump); | 418 | luaK_jump(ls, jump); |
| 419 | } | 419 | } |
| 420 | insert_last(fs, &v->u.l.t); | 420 | insert_last(fs, &v->u.l.t); |
| @@ -440,28 +440,28 @@ void luaK_tostack (LexState *ls, expdesc *v, int onlyone) { | |||
| 440 | int final; /* position after whole expression */ | 440 | int final; /* position after whole expression */ |
| 441 | if (ISJUMP(previous)) { | 441 | if (ISJUMP(previous)) { |
| 442 | insert_last(fs, &v->u.l.t); /* put `previous' in true list */ | 442 | insert_last(fs, &v->u.l.t); /* put `previous' in true list */ |
| 443 | p_nil = luaK_0(ls, PUSHNILJMP, 0); | 443 | p_nil = luaK_0(ls, OP_PUSHNILJMP, 0); |
| 444 | p_1 = luaK_S(ls, PUSHINT, 1, 1); | 444 | p_1 = luaK_S(ls, OP_PUSHINT, 1, 1); |
| 445 | } | 445 | } |
| 446 | else { /* still may need a PUSHNIL or a PUSHINT */ | 446 | else { /* still may need a PUSHNIL or a PUSHINT */ |
| 447 | int need_nil = need_value(fs, v->u.l.f, ONFJMP); | 447 | int need_nil = need_value(fs, v->u.l.f, OP_ONFJMP); |
| 448 | int need_1 = need_value(fs, v->u.l.t, ONTJMP); | 448 | int need_1 = need_value(fs, v->u.l.t, OP_ONTJMP); |
| 449 | if (need_nil && need_1) { | 449 | if (need_nil && need_1) { |
| 450 | luaK_S(ls, JMP, 2, 0); /* skip both pushes */ | 450 | luaK_S(ls, OP_JMP, 2, 0); /* skip both pushes */ |
| 451 | p_nil = luaK_0(ls, PUSHNILJMP, 0); | 451 | p_nil = luaK_0(ls, OP_PUSHNILJMP, 0); |
| 452 | p_1 = luaK_S(ls, PUSHINT, 1, 0); | 452 | p_1 = luaK_S(ls, OP_PUSHINT, 1, 0); |
| 453 | } | 453 | } |
| 454 | else if (need_nil || need_1) { | 454 | else if (need_nil || need_1) { |
| 455 | luaK_S(ls, JMP, 1, 0); /* skip one push */ | 455 | luaK_S(ls, OP_JMP, 1, 0); /* skip one push */ |
| 456 | if (need_nil) | 456 | if (need_nil) |
| 457 | p_nil = luaK_U(ls, PUSHNIL, 1, 0); | 457 | p_nil = luaK_U(ls, OP_PUSHNIL, 1, 0); |
| 458 | else /* need_1 */ | 458 | else /* need_1 */ |
| 459 | p_1 = luaK_S(ls, PUSHINT, 1, 0); | 459 | p_1 = luaK_S(ls, OP_PUSHINT, 1, 0); |
| 460 | } | 460 | } |
| 461 | } | 461 | } |
| 462 | final = luaK_getlabel(ls); | 462 | final = luaK_getlabel(ls); |
| 463 | luaK_patchlistaux(ls, v->u.l.f, p_nil, ONFJMP, final); | 463 | luaK_patchlistaux(ls, v->u.l.f, p_nil, OP_ONFJMP, final); |
| 464 | luaK_patchlistaux(ls, v->u.l.t, p_1, ONTJMP, final); | 464 | luaK_patchlistaux(ls, v->u.l.t, p_1, OP_ONTJMP, final); |
| 465 | v->u.l.f = v->u.l.t = 0; | 465 | v->u.l.f = v->u.l.t = 0; |
| 466 | } | 466 | } |
| 467 | } | 467 | } |
| @@ -481,7 +481,7 @@ void luaK_prefix (LexState *ls, int op, expdesc *v) { | |||
| 481 | if (ISJUMP(GET_OPCODE(*previous))) | 481 | if (ISJUMP(GET_OPCODE(*previous))) |
| 482 | SET_OPCODE(*previous, invertjump(GET_OPCODE(*previous))); | 482 | SET_OPCODE(*previous, invertjump(GET_OPCODE(*previous))); |
| 483 | else | 483 | else |
| 484 | luaK_0(ls, NOTOP, 0); | 484 | luaK_0(ls, OP_NOT, 0); |
| 485 | /* interchange true and false lists */ | 485 | /* interchange true and false lists */ |
| 486 | { int temp = v->u.l.f; v->u.l.f = v->u.l.t; v->u.l.t = temp; } | 486 | { int temp = v->u.l.f; v->u.l.f = v->u.l.t; v->u.l.t = temp; } |
| 487 | } | 487 | } |
| @@ -489,9 +489,9 @@ void luaK_prefix (LexState *ls, int op, expdesc *v) { | |||
| 489 | 489 | ||
| 490 | 490 | ||
| 491 | void luaK_infix (LexState *ls, int op, expdesc *v) { | 491 | void luaK_infix (LexState *ls, int op, expdesc *v) { |
| 492 | if (op == AND) | 492 | if (op == TK_AND) |
| 493 | luaK_goiftrue(ls, v, 1); | 493 | luaK_goiftrue(ls, v, 1); |
| 494 | else if (op == OR) | 494 | else if (op == TK_OR) |
| 495 | luaK_goiffalse(ls, v, 1); | 495 | luaK_goiffalse(ls, v, 1); |
| 496 | else | 496 | else |
| 497 | luaK_tostack(ls, v, 1); /* all other binary operators need a value */ | 497 | luaK_tostack(ls, v, 1); /* all other binary operators need a value */ |
| @@ -499,13 +499,13 @@ void luaK_infix (LexState *ls, int op, expdesc *v) { | |||
| 499 | 499 | ||
| 500 | 500 | ||
| 501 | void luaK_posfix (LexState *ls, int op, expdesc *v1, expdesc *v2) { | 501 | void luaK_posfix (LexState *ls, int op, expdesc *v1, expdesc *v2) { |
| 502 | if (op == AND) { | 502 | if (op == TK_AND) { |
| 503 | LUA_ASSERT(ls->L, v1->u.l.t == 0, "list must be closed"); | 503 | LUA_ASSERT(ls->L, v1->u.l.t == 0, "list must be closed"); |
| 504 | discharge1(ls, v2); | 504 | discharge1(ls, v2); |
| 505 | v1->u.l.t = v2->u.l.t; | 505 | v1->u.l.t = v2->u.l.t; |
| 506 | concatlists(ls, &v1->u.l.f, v2->u.l.f); | 506 | concatlists(ls, &v1->u.l.f, v2->u.l.f); |
| 507 | } | 507 | } |
| 508 | else if (op == OR) { | 508 | else if (op == TK_OR) { |
| 509 | LUA_ASSERT(ls->L, v1->u.l.f == 0, "list must be closed"); | 509 | LUA_ASSERT(ls->L, v1->u.l.f == 0, "list must be closed"); |
| 510 | discharge1(ls, v2); | 510 | discharge1(ls, v2); |
| 511 | v1->u.l.f = v2->u.l.f; | 511 | v1->u.l.f = v2->u.l.f; |
| @@ -516,16 +516,16 @@ void luaK_posfix (LexState *ls, int op, expdesc *v1, expdesc *v2) { | |||
| 516 | switch (op) { | 516 | switch (op) { |
| 517 | case '+': luaK_add(ls); break; | 517 | case '+': luaK_add(ls); break; |
| 518 | case '-': luaK_sub(ls); break; | 518 | case '-': luaK_sub(ls); break; |
| 519 | case '*': luaK_0(ls, MULTOP, -1); break; | 519 | case '*': luaK_0(ls, OP_MULT, -1); break; |
| 520 | case '/': luaK_0(ls, DIVOP, -1); break; | 520 | case '/': luaK_0(ls, OP_DIV, -1); break; |
| 521 | case '^': luaK_0(ls, POWOP, -1); break; | 521 | case '^': luaK_0(ls, OP_POW, -1); break; |
| 522 | case CONC: luaK_conc(ls); break; | 522 | case TK_CONC: luaK_conc(ls); break; |
| 523 | case EQ: luaK_eq(ls); break; | 523 | case TK_EQ: luaK_eq(ls); break; |
| 524 | case NE: luaK_neq(ls); break; | 524 | case TK_NE: luaK_neq(ls); break; |
| 525 | case '>': luaK_S(ls, IFGTJMP, 0, -2); break; | 525 | case '>': luaK_S(ls, OP_IFGTJMP, 0, -2); break; |
| 526 | case '<': luaK_S(ls, IFLTJMP, 0, -2); break; | 526 | case '<': luaK_S(ls, OP_IFLTJMP, 0, -2); break; |
| 527 | case GE: luaK_S(ls, IFGEJMP, 0, -2); break; | 527 | case TK_GE: luaK_S(ls, OP_IFGEJMP, 0, -2); break; |
| 528 | case LE: luaK_S(ls, IFLEJMP, 0, -2); break; | 528 | case TK_LE: luaK_S(ls, OP_IFLEJMP, 0, -2); break; |
| 529 | } | 529 | } |
| 530 | } | 530 | } |
| 531 | } | 531 | } |
