details
This commit is contained in:
70
lvm.c
70
lvm.c
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 2.57 2005/10/13 12:21:26 roberto Exp roberto $
|
** $Id: lvm.c,v 2.58 2005/10/24 17:37:52 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
@@ -65,7 +65,6 @@ static void traceexec (lua_State *L, const Instruction *pc) {
|
|||||||
if (L->hookcount == 0) {
|
if (L->hookcount == 0) {
|
||||||
resethookcount(L);
|
resethookcount(L);
|
||||||
luaD_callhook(L, LUA_HOOKCOUNT, -1);
|
luaD_callhook(L, LUA_HOOKCOUNT, -1);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (mask & LUA_MASKLINE) {
|
if (mask & LUA_MASKLINE) {
|
||||||
@@ -357,6 +356,19 @@ static void Arith (lua_State *L, StkId ra, const TValue *rb,
|
|||||||
#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
|
#define Protect(x) { L->savedpc = pc; {x;}; base = L->base; }
|
||||||
|
|
||||||
|
|
||||||
|
#define arith_op(op,tm) { \
|
||||||
|
TValue *rb = RKB(i); \
|
||||||
|
TValue *rc = RKC(i); \
|
||||||
|
if (ttisnumber(rb) && ttisnumber(rc)) { \
|
||||||
|
lua_Number nb = nvalue(rb), nc = nvalue(rc); \
|
||||||
|
setnvalue(ra, op(nb, nc)); \
|
||||||
|
} \
|
||||||
|
else \
|
||||||
|
Protect(Arith(L, ra, rb, rc, tm)); \
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
void luaV_execute (lua_State *L, int nexeccalls) {
|
void luaV_execute (lua_State *L, int nexeccalls) {
|
||||||
LClosure *cl;
|
LClosure *cl;
|
||||||
StkId base;
|
StkId base;
|
||||||
@@ -454,69 +466,27 @@ void luaV_execute (lua_State *L, int nexeccalls) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_ADD: {
|
case OP_ADD: {
|
||||||
TValue *rb = RKB(i);
|
arith_op(luai_numadd, TM_ADD);
|
||||||
TValue *rc = RKC(i);
|
|
||||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
|
||||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
|
||||||
setnvalue(ra, luai_numadd(nb, nc));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Protect(Arith(L, ra, rb, rc, TM_ADD));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_SUB: {
|
case OP_SUB: {
|
||||||
TValue *rb = RKB(i);
|
arith_op(luai_numsub, TM_SUB);
|
||||||
TValue *rc = RKC(i);
|
|
||||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
|
||||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
|
||||||
setnvalue(ra, luai_numsub(nb, nc));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Protect(Arith(L, ra, rb, rc, TM_SUB));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_MUL: {
|
case OP_MUL: {
|
||||||
TValue *rb = RKB(i);
|
arith_op(luai_nummul, TM_MUL);
|
||||||
TValue *rc = RKC(i);
|
|
||||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
|
||||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
|
||||||
setnvalue(ra, luai_nummul(nb, nc));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Protect(Arith(L, ra, rb, rc, TM_MUL));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_DIV: {
|
case OP_DIV: {
|
||||||
TValue *rb = RKB(i);
|
arith_op(luai_numdiv, TM_DIV);
|
||||||
TValue *rc = RKC(i);
|
|
||||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
|
||||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
|
||||||
setnvalue(ra, luai_numdiv(nb, nc));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Protect(Arith(L, ra, rb, rc, TM_DIV));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_MOD: {
|
case OP_MOD: {
|
||||||
TValue *rb = RKB(i);
|
arith_op(luai_nummod, TM_MOD);
|
||||||
TValue *rc = RKC(i);
|
|
||||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
|
||||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
|
||||||
setnvalue(ra, luai_nummod(nb, nc));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Protect(Arith(L, ra, rb, rc, TM_MOD));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_POW: {
|
case OP_POW: {
|
||||||
TValue *rb = RKB(i);
|
arith_op(luai_numpow, TM_POW);
|
||||||
TValue *rc = RKC(i);
|
|
||||||
if (ttisnumber(rb) && ttisnumber(rc)) {
|
|
||||||
lua_Number nb = nvalue(rb), nc = nvalue(rc);
|
|
||||||
setnvalue(ra, luai_numpow(nb, nc));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
Protect(Arith(L, ra, rb, rc, TM_POW));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_UNM: {
|
case OP_UNM: {
|
||||||
|
|||||||
Reference in New Issue
Block a user