mirror of https://github.com/rusefi/lua.git
new instruction OP_LOADKX (to replace OP_LOADK with extra argument)
This commit is contained in:
parent
a958b711f5
commit
427ee519db
10
lcode.c
10
lcode.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lcode.c,v 2.50 2011/01/31 14:28:41 roberto Exp roberto $
|
||||
** $Id: lcode.c,v 2.51 2011/02/01 18:03:10 roberto Exp roberto $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -242,11 +242,11 @@ static int codeextraarg (FuncState *fs, int a) {
|
|||
}
|
||||
|
||||
|
||||
int luaK_codeABxX (FuncState *fs, OpCode o, int reg, int k) {
|
||||
if (k < MAXARG_Bx)
|
||||
return luaK_codeABx(fs, o, reg, k + 1);
|
||||
int luaK_codek (FuncState *fs, int reg, int k) {
|
||||
if (k <= MAXARG_Bx)
|
||||
return luaK_codeABx(fs, OP_LOADK, reg, k);
|
||||
else {
|
||||
int p = luaK_codeABx(fs, o, reg, 0);
|
||||
int p = luaK_codeABx(fs, OP_LOADKX, reg, 0);
|
||||
codeextraarg(fs, k);
|
||||
return p;
|
||||
}
|
||||
|
|
6
lcode.h
6
lcode.h
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lcode.h,v 1.55 2010/07/02 20:42:40 roberto Exp roberto $
|
||||
** $Id: lcode.h,v 1.56 2011/02/01 18:03:10 roberto Exp roberto $
|
||||
** Code generator for Lua
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -44,11 +44,9 @@ typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
|
|||
|
||||
#define luaK_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t)
|
||||
|
||||
#define luaK_codek(fs,reg,k) luaK_codeABxX(fs, OP_LOADK, reg, k)
|
||||
|
||||
LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
|
||||
LUAI_FUNC int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
|
||||
LUAI_FUNC int luaK_codeABxX (FuncState *fs, OpCode o, int reg, int k);
|
||||
LUAI_FUNC int luaK_codek (FuncState *fs, int reg, int k);
|
||||
LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
|
||||
LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
|
||||
LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
|
||||
|
|
9
ldebug.c
9
ldebug.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: ldebug.c,v 2.75 2010/11/30 17:17:51 roberto Exp roberto $
|
||||
** $Id: ldebug.c,v 2.76 2011/01/26 16:30:02 roberto Exp roberto $
|
||||
** Debug Interface
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -342,10 +342,11 @@ static const char *getobjname (lua_State *L, CallInfo *ci, int reg,
|
|||
}
|
||||
break;
|
||||
}
|
||||
case OP_LOADK: {
|
||||
case OP_LOADK:
|
||||
case OP_LOADKX: {
|
||||
if (reg == a) {
|
||||
int b = GETARG_Bx(i);
|
||||
b = (b > 0) ? b - 1 : GETARG_Ax(p->code[pc + 1]);
|
||||
int b = (op == OP_LOADK) ? GETARG_Bx(i)
|
||||
: GETARG_Ax(p->code[pc + 1]);
|
||||
if (ttisstring(&p->k[b])) {
|
||||
what = "constant";
|
||||
*name = svalue(&p->k[b]);
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lopcodes.c,v 1.44 2010/10/13 16:45:54 roberto Exp roberto $
|
||||
** $Id: lopcodes.c,v 1.45 2011/02/07 12:24:42 roberto Exp roberto $
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
|||
LUAI_DDEF const char *const luaP_opnames[NUM_OPCODES+1] = {
|
||||
"MOVE",
|
||||
"LOADK",
|
||||
"LOADKX",
|
||||
"LOADBOOL",
|
||||
"LOADNIL",
|
||||
"GETUPVAL",
|
||||
|
@ -63,6 +64,7 @@ LUAI_DDEF const lu_byte luaP_opmodes[NUM_OPCODES] = {
|
|||
/* T A B C mode opcode */
|
||||
opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_MOVE */
|
||||
,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADK */
|
||||
,opmode(0, 1, OpArgK, OpArgN, iABx) /* OP_LOADKX */
|
||||
,opmode(0, 1, OpArgU, OpArgU, iABC) /* OP_LOADBOOL */
|
||||
,opmode(0, 1, OpArgR, OpArgN, iABC) /* OP_LOADNIL */
|
||||
,opmode(0, 1, OpArgU, OpArgN, iABC) /* OP_GETUPVAL */
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lopcodes.h,v 1.138 2011/02/01 18:03:10 roberto Exp roberto $
|
||||
** $Id: lopcodes.h,v 1.139 2011/02/07 12:24:42 roberto Exp roberto $
|
||||
** Opcodes for Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -167,7 +167,8 @@ typedef enum {
|
|||
name args description
|
||||
------------------------------------------------------------------------*/
|
||||
OP_MOVE,/* A B R(A) := R(B) */
|
||||
OP_LOADK,/* A Bx R(A) := Kst(Bx - 1) */
|
||||
OP_LOADK,/* A Bx R(A) := Kst(Bx) */
|
||||
OP_LOADKX,/* A R(A) := Kst(extra arg) */
|
||||
OP_LOADBOOL,/* A B C R(A) := (Bool)B; if (C) pc++ */
|
||||
OP_LOADNIL,/* A B R(A) := ... := R(B) := nil */
|
||||
OP_GETUPVAL,/* A B R(A) := UpValue[B] */
|
||||
|
@ -242,7 +243,7 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
|
|||
(*) In OP_SETLIST, if (B == 0) then B = `top'; if (C == 0) then next
|
||||
'instruction' is EXTRAARG(real C).
|
||||
|
||||
(*) In OP_LOADK, if (Bx == 0) then next 'instruction' is EXTRAARG(real Bx).
|
||||
(*) In OP_LOADKX, the next 'instruction' is always EXTRAARG.
|
||||
|
||||
(*) For comparisons, A specifies what condition the test should accept
|
||||
(true or false).
|
||||
|
|
10
lvm.c
10
lvm.c
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
** $Id: lvm.c,v 2.132 2011/04/05 14:26:23 roberto Exp roberto $
|
||||
** $Id: lvm.c,v 2.133 2011/04/05 18:32:06 roberto Exp roberto $
|
||||
** Lua virtual machine
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
|
@ -522,7 +522,13 @@ void luaV_execute (lua_State *L) {
|
|||
setobjs2s(L, ra, RB(i));
|
||||
)
|
||||
vmcase(OP_LOADK,
|
||||
TValue *rb = KBx(i);
|
||||
TValue *rb = k + GETARG_Bx(i);
|
||||
setobj2s(L, ra, rb);
|
||||
)
|
||||
vmcase(OP_LOADKX,
|
||||
TValue *rb;
|
||||
lua_assert(GET_OPCODE(*ci->u.l.savedpc) == OP_EXTRAARG);
|
||||
rb = k + GETARG_Ax(*ci->u.l.savedpc++);
|
||||
setobj2s(L, ra, rb);
|
||||
)
|
||||
vmcase(OP_LOADBOOL,
|
||||
|
|
Loading…
Reference in New Issue