diff --git a/lcode.c b/lcode.c index f75ac359..abf4f537 100644 --- a/lcode.c +++ b/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 1.23 2000/04/07 19:35:20 roberto Exp roberto $ +** $Id: lcode.c,v 1.24 2000/04/12 18:57:19 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -460,6 +460,9 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { case OP_MULT: case OP_DIV: case OP_POW: delta = -1; mode = iO; break; + case OP_SETLOCAL: /* `setlocal' default pops one value */ + delta = -1; arg2 = 1; mode = iAB; break; + case OP_RETURN: if (GET_OPCODE(i) == OP_CALL && GETARG_B(i) == MULT_RET) { SET_OPCODE(i, OP_TAILCALL); @@ -501,26 +504,6 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { } break; - case OP_SETLOCAL: { - int pc = fs->pc; - Instruction *code = fs->f->code; - delta = -1; - if (pc-1 > fs->lasttarget && /* no jumps in-between instructions? */ - code[pc-2] == CREATE_U(OP_GETLOCAL, arg1) && - GET_OPCODE(i) == OP_ADDI && abs(GETARG_S(i)) <= MAXARG_sA) { - /* `local=local+k' */ - fs->pc = pc-1; - code[pc-2] = CREATE_sAB(OP_INCLOCAL, GETARG_S(i), arg1); - luaK_deltastack(fs, delta); - return pc-1; - } - else { - arg2 = 1; /* `setlocal' default pops one value */ - mode = iAB; - } - break; - } - case OP_ADD: delta = -1; switch(GET_OPCODE(i)) { @@ -585,8 +568,7 @@ int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2) { break; case OP_GETDOTTED: case OP_GETINDEXED: - case OP_TAILCALL: case OP_INCLOCAL: - case OP_ADDI: + case OP_TAILCALL: case OP_ADDI: LUA_INTERNALERROR(L, "instruction used only for optimizations"); return 0; /* to avoid warnings */ diff --git a/lopcodes.h b/lopcodes.h index 91c74759..d7548d9b 100644 --- a/lopcodes.h +++ b/lopcodes.h @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.h,v 1.56 2000/04/07 19:35:31 roberto Exp roberto $ +** $Id: lopcodes.h,v 1.57 2000/04/12 18:57:19 roberto Exp roberto $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -36,8 +36,6 @@ -#define MAXARG_sA (MAXARG_A>>1) /* max value for a signed A */ - /* creates a mask with `n' 1 bits at position `p' */ #define MASK1(n,p) ((~((~(Instruction)0)<0) ? index<=limit : index>=limit) { nvalue(top-3) = index;