diff options
| -rw-r--r-- | lcode.c | 10 | ||||
| -rw-r--r-- | lcode.h | 6 | ||||
| -rw-r--r-- | ldebug.c | 9 | ||||
| -rw-r--r-- | lopcodes.c | 4 | ||||
| -rw-r--r-- | lopcodes.h | 7 | ||||
| -rw-r--r-- | lvm.c | 10 |
6 files changed, 27 insertions, 19 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.c,v 2.50 2011/01/31 14:28:41 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.51 2011/02/01 18:03: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 | */ |
| @@ -242,11 +242,11 @@ static int codeextraarg (FuncState *fs, int a) { | |||
| 242 | } | 242 | } |
| 243 | 243 | ||
| 244 | 244 | ||
| 245 | int luaK_codeABxX (FuncState *fs, OpCode o, int reg, int k) { | 245 | int luaK_codek (FuncState *fs, int reg, int k) { |
| 246 | if (k < MAXARG_Bx) | 246 | if (k <= MAXARG_Bx) |
| 247 | return luaK_codeABx(fs, o, reg, k + 1); | 247 | return luaK_codeABx(fs, OP_LOADK, reg, k); |
| 248 | else { | 248 | else { |
| 249 | int p = luaK_codeABx(fs, o, reg, 0); | 249 | int p = luaK_codeABx(fs, OP_LOADKX, reg, 0); |
| 250 | codeextraarg(fs, k); | 250 | codeextraarg(fs, k); |
| 251 | return p; | 251 | return p; |
| 252 | } | 252 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.h,v 1.55 2010/07/02 20:42:40 roberto Exp roberto $ | 2 | ** $Id: lcode.h,v 1.56 2011/02/01 18:03: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 | */ |
| @@ -44,11 +44,9 @@ typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr; | |||
| 44 | 44 | ||
| 45 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) | 45 | #define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t) |
| 46 | 46 | ||
| 47 | #define luaK_codek(fs,reg,k) luaK_codeABxX(fs, OP_LOADK, reg, k) | ||
| 48 | |||
| 49 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); | 47 | LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx); |
| 50 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); | 48 | LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); |
| 51 | LUAI_FUNC int luaK_codeABxX (FuncState *fs, OpCode o, int reg, int k); | 49 | LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k); |
| 52 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); | 50 | LUAI_FUNC void luaK_fixline (FuncState *fs, int line); |
| 53 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); | 51 | LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n); |
| 54 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); | 52 | LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 2.75 2010/11/30 17:17:51 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.76 2011/01/26 16:30:02 roberto Exp roberto $ |
| 3 | ** Debug Interface | 3 | ** Debug Interface |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -342,10 +342,11 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int reg, | |||
| 342 | } | 342 | } |
| 343 | break; | 343 | break; |
| 344 | } | 344 | } |
| 345 | case OP_LOADK: { | 345 | case OP_LOADK: |
| 346 | case OP_LOADKX: { | ||
| 346 | if (reg == a) { | 347 | if (reg == a) { |
| 347 | int b = GETARG_Bx(i); | 348 | int b = (op == OP_LOADK) ? GETARG_Bx(i) |
| 348 | b = (b > 0) ? b - 1 : GETARG_Ax(p->code[pc + 1]); | 349 | : GETARG_Ax(p->code[pc + 1]); |
| 349 | if (ttisstring(&p->k[b])) { | 350 | if (ttisstring(&p->k[b])) { |
| 350 | what = "constant"; | 351 | what = "constant"; |
| 351 | *name = svalue(&p->k[b]); | 352 | *name = svalue(&p->k[b]); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lopcodes.c,v 1.44 2010/10/13 16:45:54 roberto Exp roberto $ | 2 | ** $Id: lopcodes.c,v 1.45 2011/02/07 12:24:42 roberto Exp roberto $ |
| 3 | ** See Copyright Notice in lua.h | 3 | ** See Copyright Notice in lua.h |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| @@ -16,6 +16,7 @@ | |||
| 16 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { | 16 | LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = { |
| 17 | "MOVE", | 17 | "MOVE", |
| 18 | "LOADK", | 18 | "LOADK", |
| 19 | "LOADKX", | ||
| 19 | "LOADBOOL", | 20 | "LOADBOOL", |
| 20 | "LOADNIL", | 21 | "LOADNIL", |
| 21 | "GETUPVAL", | 22 | "GETUPVAL", |
| @@ -63,6 +64,7 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = { | |||
| 63 | /* T A B C mode opcode */ | 64 | /* T A B C mode opcode */ |
| 64 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ | 65 | opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */ |
| 65 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ | 66 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */ |
| 67 | ,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADKX */ | ||
| 66 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ | 68 | ,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */ |
| 67 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ | 69 | ,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */ |
| 68 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ | 70 | ,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lopcodes.h,v 1.138 2011/02/01 18:03:10 roberto Exp roberto $ | 2 | ** $Id: lopcodes.h,v 1.139 2011/02/07 12:24:42 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 | */ |
| @@ -167,7 +167,8 @@ typedef enum { | |||
| 167 | name args description | 167 | name args description |
| 168 | ------------------------------------------------------------------------*/ | 168 | ------------------------------------------------------------------------*/ |
| 169 | OP_MOVE,/* A B R(A) := R(B) */ | 169 | OP_MOVE,/* A B R(A) := R(B) */ |
| 170 | OP_LOADK,/* A Bx R(A) := Kst(Bx - 1) */ | 170 | OP_LOADK,/* A Bx R(A) := Kst(Bx) */ |
| 171 | OP_LOADKX,/* A R(A) := Kst(extra arg) */ | ||
| 171 | OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */ | 172 | OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */ |
| 172 | OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */ | 173 | OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */ |
| 173 | OP_GETUPVAL,/* A B R(A) := UpValue[B] */ | 174 | OP_GETUPVAL,/* A B R(A) := UpValue[B] */ |
| @@ -242,7 +243,7 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | |||
| 242 | (*) In OP_SETLIST, if (B == 0) then B = `top'; if (C == 0) then next | 243 | (*) In OP_SETLIST, if (B == 0) then B = `top'; if (C == 0) then next |
| 243 | 'instruction' is EXTRAARG(real C). | 244 | 'instruction' is EXTRAARG(real C). |
| 244 | 245 | ||
| 245 | (*) In OP_LOADK, if (Bx == 0) then next 'instruction' is EXTRAARG(real Bx). | 246 | (*) In OP_LOADKX, the next 'instruction' is always EXTRAARG. |
| 246 | 247 | ||
| 247 | (*) For comparisons, A specifies what condition the test should accept | 248 | (*) For comparisons, A specifies what condition the test should accept |
| 248 | (true or false). | 249 | (true or false). |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lvm.c,v 2.132 2011/04/05 14:26:23 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.133 2011/04/05 18:32:06 roberto Exp roberto $ |
| 3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -522,7 +522,13 @@ void luaV_execute (lua_State *L) { | |||
| 522 | setobjs2s(L, ra, RB(i)); | 522 | setobjs2s(L, ra, RB(i)); |
| 523 | ) | 523 | ) |
| 524 | vmcase(OP_LOADK, | 524 | vmcase(OP_LOADK, |
| 525 | TValue *rb = KBx(i); | 525 | TValue *rb = k + GETARG_Bx(i); |
| 526 | setobj2s(L, ra, rb); | ||
| 527 | ) | ||
| 528 | vmcase(OP_LOADKX, | ||
| 529 | TValue *rb; | ||
| 530 | lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG); | ||
| 531 | rb = k + GETARG_Ax(*ci->u.l.savedpc++); | ||
| 526 | setobj2s(L, ra, rb); | 532 | setobj2s(L, ra, rb); |
| 527 | ) | 533 | ) |
| 528 | vmcase(OP_LOADBOOL, | 534 | vmcase(OP_LOADBOOL, |
