mirror of https://github.com/rusefi/lua.git
new function 'luaK_codek' (detail)
This commit is contained in:
parent
4a67e48611
commit
2598138ece
14
lcode.c
14
lcode.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lcode.c,v 2.35 2008/04/02 16:16:06 roberto Exp roberto $
|
** $Id: lcode.c,v 2.36 2008/04/07 18:41:47 roberto Exp roberto $
|
||||||
** Code generator for Lua
|
** Code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -349,11 +349,11 @@ static void discharge2reg (FuncState *fs, expdesc *e, int reg) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VK: {
|
case VK: {
|
||||||
luaK_codeABx(fs, OP_LOADK, reg, e->u.s.info);
|
luaK_codek(fs, reg, e->u.s.info);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VKNUM: {
|
case VKNUM: {
|
||||||
luaK_codeABx(fs, OP_LOADK, reg, luaK_numberK(fs, e->u.nval));
|
luaK_codek(fs, reg, luaK_numberK(fs, e->u.nval));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case VRELOCABLE: {
|
case VRELOCABLE: {
|
||||||
|
@ -813,6 +813,7 @@ int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
|
||||||
lua_assert(getOpMode(o) == iABC);
|
lua_assert(getOpMode(o) == iABC);
|
||||||
lua_assert(getBMode(o) != OpArgN || b == 0);
|
lua_assert(getBMode(o) != OpArgN || b == 0);
|
||||||
lua_assert(getCMode(o) != OpArgN || c == 0);
|
lua_assert(getCMode(o) != OpArgN || c == 0);
|
||||||
|
lua_assert(a <= MAXARG_A && b <= MAXARG_B && c <= MAXARG_C);
|
||||||
return luaK_code(fs, CREATE_ABC(o, a, b, c));
|
return luaK_code(fs, CREATE_ABC(o, a, b, c));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -820,16 +821,23 @@ int luaK_codeABC (FuncState *fs, OpCode o, int a, int b, int c) {
|
||||||
int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
|
int luaK_codeABx (FuncState *fs, OpCode o, int a, unsigned int bc) {
|
||||||
lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
|
lua_assert(getOpMode(o) == iABx || getOpMode(o) == iAsBx);
|
||||||
lua_assert(getCMode(o) == OpArgN);
|
lua_assert(getCMode(o) == OpArgN);
|
||||||
|
lua_assert(a <= MAXARG_A && bc <= MAXARG_Bx);
|
||||||
return luaK_code(fs, CREATE_ABx(o, a, bc));
|
return luaK_code(fs, CREATE_ABx(o, a, bc));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int luaK_codeAx (FuncState *fs, OpCode o, int a) {
|
static int luaK_codeAx (FuncState *fs, OpCode o, int a) {
|
||||||
lua_assert(getOpMode(o) == iAx);
|
lua_assert(getOpMode(o) == iAx);
|
||||||
|
lua_assert(a <= MAXARG_Ax);
|
||||||
return luaK_code(fs, CREATE_Ax(o, a));
|
return luaK_code(fs, CREATE_Ax(o, a));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void luaK_codek (FuncState *fs, int reg, int k) {
|
||||||
|
luaK_codeABx(fs, OP_LOADK, reg, k);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
|
void luaK_setlist (FuncState *fs, int base, int nelems, int tostore) {
|
||||||
int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
|
int c = (nelems - 1)/LFIELDS_PER_FLUSH + 1;
|
||||||
int b = (tostore == LUA_MULTRET) ? 0 : tostore;
|
int b = (tostore == LUA_MULTRET) ? 0 : tostore;
|
||||||
|
|
3
lcode.h
3
lcode.h
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lcode.h,v 1.48 2006/03/21 19:28:03 roberto Exp roberto $
|
** $Id: lcode.h,v 1.49 2008/10/28 12:55:00 roberto Exp roberto $
|
||||||
** Code generator for Lua
|
** Code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -44,6 +44,7 @@ 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_jumpto(fs,t) luaK_patchlist(fs, luaK_jump(fs), t)
|
||||||
|
|
||||||
|
LUAI_FUNC void luaK_codek (FuncState *fs, int reg, int k);
|
||||||
LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
|
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_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
|
||||||
LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
|
LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 2.61 2009/03/26 12:56:38 roberto Exp roberto $
|
** $Id: lparser.c,v 2.62 2009/04/30 17:42:21 roberto Exp roberto $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -1085,7 +1085,7 @@ static void fornum (LexState *ls, TString *varname, int line) {
|
||||||
if (testnext(ls, ','))
|
if (testnext(ls, ','))
|
||||||
exp1(ls); /* optional step */
|
exp1(ls); /* optional step */
|
||||||
else { /* default step = 1 */
|
else { /* default step = 1 */
|
||||||
luaK_codeABx(fs, OP_LOADK, fs->freereg, luaK_numberK(fs, 1));
|
luaK_codek(fs, fs->freereg, luaK_numberK(fs, 1));
|
||||||
luaK_reserveregs(fs, 1);
|
luaK_reserveregs(fs, 1);
|
||||||
}
|
}
|
||||||
forbody(ls, base, line, 1, 1);
|
forbody(ls, base, line, 1, 1);
|
||||||
|
|
Loading…
Reference in New Issue