details
This commit is contained in:
45
lcode.c
45
lcode.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lcode.c,v 1.109 2002/08/05 14:07:34 roberto Exp roberto $
|
** $Id: lcode.c,v 1.110 2002/08/20 20:03:05 roberto Exp roberto $
|
||||||
** Code generator for Lua
|
** Code generator for Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -616,38 +616,21 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
|
|||||||
|
|
||||||
static void codebinop (FuncState *fs, expdesc *res, BinOpr op,
|
static void codebinop (FuncState *fs, expdesc *res, BinOpr op,
|
||||||
int o1, int o2) {
|
int o1, int o2) {
|
||||||
switch (op) {
|
if (op <= OPR_POW) { /* arithmetic operator? */
|
||||||
case OPR_SUB:
|
OpCode opc = cast(OpCode, (op - OPR_ADD) + OP_ADD); /* ORDER OP */
|
||||||
case OPR_DIV:
|
res->info = luaK_codeABC(fs, opc, 0, o1, o2);
|
||||||
case OPR_POW:
|
res->k = VRELOCABLE;
|
||||||
case OPR_ADD:
|
}
|
||||||
case OPR_MULT: { /* ORDER OPR */
|
else { /* test operator */
|
||||||
OpCode opc = cast(OpCode, (op - OPR_ADD) + OP_ADD);
|
static const OpCode ops[] = {OP_EQ, OP_EQ, OP_LT, OP_LE, OP_LT, OP_LE};
|
||||||
res->info = luaK_codeABC(fs, opc, 0, o1, o2);
|
int cond = 1;
|
||||||
res->k = VRELOCABLE;
|
if (op >= OPR_GT) { /* `>' or `>='? */
|
||||||
break;
|
int temp; /* exchange args and replace by `<' or `<=' */
|
||||||
}
|
|
||||||
case OPR_NE:
|
|
||||||
case OPR_EQ: {
|
|
||||||
res->info = luaK_condjump(fs, OP_EQ, (op == OPR_EQ), o1, o2);
|
|
||||||
res->k = VJMP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case OPR_GT:
|
|
||||||
case OPR_GE: { /* ORDER OPR */
|
|
||||||
int temp;
|
|
||||||
temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */
|
temp = o1; o1 = o2; o2 = temp; /* o1 <==> o2 */
|
||||||
op -= 2; /* GT -> LT, GE -> LE */
|
|
||||||
/* go through */
|
|
||||||
}
|
}
|
||||||
case OPR_LT:
|
else if (op == OPR_NE) cond = 0;
|
||||||
case OPR_LE: {
|
res->info = luaK_condjump(fs, ops[op - OPR_NE], cond, o1, o2);
|
||||||
OpCode opc = cast(OpCode, (op - OPR_LT) + OP_LT);
|
res->k = VJMP;
|
||||||
res->info = luaK_condjump(fs, opc, 1, o1, o2);
|
|
||||||
res->k = VJMP;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default: lua_assert(0);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lopcodes.h,v 1.100 2002/08/05 14:46:43 roberto Exp roberto $
|
** $Id: lopcodes.h,v 1.101 2002/08/20 20:03:05 roberto Exp roberto $
|
||||||
** Opcodes for Lua virtual machine
|
** Opcodes for Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -123,6 +123,11 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
|
|||||||
** RK(x) == if x < MAXSTACK then R(x) else Kst(x-MAXSTACK)
|
** RK(x) == if x < MAXSTACK then R(x) else Kst(x-MAXSTACK)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
** grep "ORDER OP" if you change these enums
|
||||||
|
*/
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
/*----------------------------------------------------------------------
|
/*----------------------------------------------------------------------
|
||||||
name args description
|
name args description
|
||||||
|
|||||||
4
lvm.c
4
lvm.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 1.252 2002/08/12 17:23:12 roberto Exp roberto $
|
** $Id: lvm.c,v 1.253 2002/08/20 20:03:05 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -555,7 +555,7 @@ StkId luaV_execute (lua_State *L) {
|
|||||||
dojump(pc, GETARG_sBx(i));
|
dojump(pc, GETARG_sBx(i));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case OP_EQ: { /* skip next instruction if test fails */
|
case OP_EQ: {
|
||||||
if (equalobj(L, RKB(i), RKC(i)) != GETARG_A(i)) pc++;
|
if (equalobj(L, RKB(i), RKC(i)) != GETARG_A(i)) pc++;
|
||||||
else dojump(pc, GETARG_sBx(*pc) + 1);
|
else dojump(pc, GETARG_sBx(*pc) + 1);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user