diff --git a/lcode.c b/lcode.c index 416d8fe1..c76b899e 100644 --- a/lcode.c +++ b/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.17 2005/09/30 14:23:33 roberto Exp roberto $ +** $Id: lcode.c,v 2.19 2005/10/13 12:21:51 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -27,7 +27,7 @@ #define hasjumps(e) ((e)->t != (e)->f) -static int isnumeral(FuncState *fs, expdesc *e) { +static int isnumeral(expdesc *e) { return (e->k == VKNUM && e->t == NO_JUMP && e->f == NO_JUMP); } @@ -627,21 +627,21 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { } -static int constfolding (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { +static int constfolding (OpCode op, expdesc *e1, expdesc *e2) { lua_Number v1, v2, r; - if (!isnumeral(fs, e1) || !isnumeral(fs, e2)) return 0; + if (!isnumeral(e1) || !isnumeral(e2)) return 0; v1 = e1->u.nval; v2 = e2->u.nval; switch (op) { - case OP_ADD: r = luai_numadd(fs->L, v1, v2); break; - case OP_SUB: r = luai_numsub(fs->L, v1, v2); break; - case OP_MUL: r = luai_nummul(fs->L, v1, v2); break; + case OP_ADD: r = luai_numadd(v1, v2); break; + case OP_SUB: r = luai_numsub(v1, v2); break; + case OP_MUL: r = luai_nummul(v1, v2); break; case OP_DIV: if (v2 == 0) return 0; /* do not attempt to divide by 0 */ - r = luai_numdiv(fs->L, v1, v2); break; - case OP_MOD: r = luai_nummod(fs->L, v1, v2); break; - case OP_POW: r = luai_numpow(fs->L, v1, v2); break; - case OP_UNM: r = luai_numunm(fs->L, v1); break; + r = luai_numdiv(v1, v2); break; + case OP_MOD: r = luai_nummod(v1, v2); break; + case OP_POW: r = luai_numpow(v1, v2); break; + case OP_UNM: r = luai_numunm(v1); break; case OP_LEN: return 0; /* no constant folding for 'len' */ default: lua_assert(0); r = 0; break; } @@ -652,7 +652,7 @@ static int constfolding (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { static void codearith (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { - if (constfolding(fs, op, e1, e2)) + if (constfolding(op, e1, e2)) return; else { int o1 = luaK_exp2RK(fs, e1); @@ -717,7 +717,7 @@ void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { break; } default: { - if (!isnumeral(fs, v)) luaK_exp2RK(fs, v); + if (!isnumeral(v)) luaK_exp2RK(fs, v); break; } } diff --git a/lobject.c b/lobject.c index 5c32ac80..be3236f5 100644 --- a/lobject.c +++ b/lobject.c @@ -1,5 +1,5 @@ /* -** $Id: lobject.c,v 2.17 2005/07/31 17:11:50 roberto Exp roberto $ +** $Id: lobject.c,v 2.18 2005/08/01 04:22:23 roberto Exp roberto $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ @@ -75,7 +75,7 @@ int luaO_rawequalObj (const TValue *t1, const TValue *t2) { case LUA_TNIL: return 1; case LUA_TNUMBER: - return luai_numeq(L, nvalue(t1), nvalue(t2)); + return luai_numeq(nvalue(t1), nvalue(t2)); case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* boolean true must be 1 !! */ case LUA_TLIGHTUSERDATA: diff --git a/ltable.c b/ltable.c index 73b59328..b640a809 100644 --- a/ltable.c +++ b/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.25 2005/05/31 14:25:18 roberto Exp roberto $ +** $Id: ltable.c,v 2.26 2005/07/11 14:01:37 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -120,7 +120,7 @@ static int arrayindex (const TValue *key) { lua_Number n = nvalue(key); int k; lua_number2int(k, n); - if (luai_numeq(L, cast(lua_Number, k), nvalue(key))) + if (luai_numeq(cast(lua_Number, k), nvalue(key))) return k; } return -1; /* `key' did not match some condition */ @@ -437,7 +437,7 @@ const TValue *luaH_getnum (Table *t, int key) { lua_Number nk = cast(lua_Number, key); Node *n = hashnum(t, nk); do { /* check whether `key' is somewhere in the chain */ - if (ttisnumber(gkey(n)) && luai_numeq(L, nvalue(gkey(n)), nk)) + if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) return gval(n); /* that's it */ else n = gnext(n); } while (n); @@ -471,7 +471,7 @@ const TValue *luaH_get (Table *t, const TValue *key) { int k; lua_Number n = nvalue(key); lua_number2int(k, n); - if (luai_numeq(L, cast(lua_Number, k), nvalue(key))) /* index is int? */ + if (luai_numeq(cast(lua_Number, k), nvalue(key))) /* index is int? */ return luaH_getnum(t, k); /* use specialized version */ /* else go through */ } @@ -495,7 +495,7 @@ TValue *luaH_set (lua_State *L, Table *t, const TValue *key) { return cast(TValue *, p); else { if (ttisnil(key)) luaG_runerror(L, "table index is nil"); - else if (ttisnumber(key) && !luai_numeq(L, nvalue(key), nvalue(key))) + else if (ttisnumber(key) && !luai_numeq(nvalue(key), nvalue(key))) luaG_runerror(L, "table index is NaN"); return newkey(L, t, key); } diff --git a/lvm.c b/lvm.c index 5e8637c9..87d3d0dc 100644 --- a/lvm.c +++ b/lvm.c @@ -1,5 +1,5 @@ /* -** $Id: lvm.c,v 2.56 2005/10/03 14:01:26 roberto Exp roberto $ +** $Id: lvm.c,v 2.57 2005/10/13 12:21:26 roberto Exp roberto $ ** Lua virtual machine ** See Copyright Notice in lua.h */ @@ -225,7 +225,7 @@ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) { if (ttype(l) != ttype(r)) return luaG_ordererror(L, l, r); else if (ttisnumber(l)) - return luai_numlt(L, nvalue(l), nvalue(r)); + return luai_numlt(nvalue(l), nvalue(r)); else if (ttisstring(l)) return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0; else if ((res = call_orderTM(L, l, r, TM_LT)) != -1) @@ -239,7 +239,7 @@ static int lessequal (lua_State *L, const TValue *l, const TValue *r) { if (ttype(l) != ttype(r)) return luaG_ordererror(L, l, r); else if (ttisnumber(l)) - return luai_numle(L, nvalue(l), nvalue(r)); + return luai_numle(nvalue(l), nvalue(r)); else if (ttisstring(l)) return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0; else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */ @@ -255,7 +255,7 @@ int luaV_equalval (lua_State *L, const TValue *t1, const TValue *t2) { lua_assert(ttype(t1) == ttype(t2)); switch (ttype(t1)) { case LUA_TNIL: return 1; - case LUA_TNUMBER: return luai_numeq(L, nvalue(t1), nvalue(t2)); + case LUA_TNUMBER: return luai_numeq(nvalue(t1), nvalue(t2)); case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); case LUA_TUSERDATA: { @@ -318,13 +318,13 @@ static void Arith (lua_State *L, StkId ra, const TValue *rb, (c = luaV_tonumber(rc, &tempc)) != NULL) { lua_Number nb = nvalue(b), nc = nvalue(c); switch (op) { - case TM_ADD: setnvalue(ra, luai_numadd(L, nb, nc)); break; - case TM_SUB: setnvalue(ra, luai_numsub(L, nb, nc)); break; - case TM_MUL: setnvalue(ra, luai_nummul(L, nb, nc)); break; - case TM_DIV: setnvalue(ra, luai_numdiv(L, nb, nc)); break; - case TM_MOD: setnvalue(ra, luai_nummod(L, nb, nc)); break; - case TM_POW: setnvalue(ra, luai_numpow(L, nb, nc)); break; - case TM_UNM: setnvalue(ra, luai_numunm(L, nb)); break; + case TM_ADD: setnvalue(ra, luai_numadd(nb, nc)); break; + case TM_SUB: setnvalue(ra, luai_numsub(nb, nc)); break; + case TM_MUL: setnvalue(ra, luai_nummul(nb, nc)); break; + case TM_DIV: setnvalue(ra, luai_numdiv(nb, nc)); break; + case TM_MOD: setnvalue(ra, luai_nummod(nb, nc)); break; + case TM_POW: setnvalue(ra, luai_numpow(nb, nc)); break; + case TM_UNM: setnvalue(ra, luai_numunm(nb)); break; default: lua_assert(0); break; } } @@ -458,7 +458,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { TValue *rc = RKC(i); if (ttisnumber(rb) && ttisnumber(rc)) { lua_Number nb = nvalue(rb), nc = nvalue(rc); - setnvalue(ra, luai_numadd(L, nb, nc)); + setnvalue(ra, luai_numadd(nb, nc)); } else Protect(Arith(L, ra, rb, rc, TM_ADD)); @@ -469,7 +469,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { TValue *rc = RKC(i); if (ttisnumber(rb) && ttisnumber(rc)) { lua_Number nb = nvalue(rb), nc = nvalue(rc); - setnvalue(ra, luai_numsub(L, nb, nc)); + setnvalue(ra, luai_numsub(nb, nc)); } else Protect(Arith(L, ra, rb, rc, TM_SUB)); @@ -480,7 +480,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { TValue *rc = RKC(i); if (ttisnumber(rb) && ttisnumber(rc)) { lua_Number nb = nvalue(rb), nc = nvalue(rc); - setnvalue(ra, luai_nummul(L, nb, nc)); + setnvalue(ra, luai_nummul(nb, nc)); } else Protect(Arith(L, ra, rb, rc, TM_MUL)); @@ -491,7 +491,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { TValue *rc = RKC(i); if (ttisnumber(rb) && ttisnumber(rc)) { lua_Number nb = nvalue(rb), nc = nvalue(rc); - setnvalue(ra, luai_numdiv(L, nb, nc)); + setnvalue(ra, luai_numdiv(nb, nc)); } else Protect(Arith(L, ra, rb, rc, TM_DIV)); @@ -502,7 +502,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { TValue *rc = RKC(i); if (ttisnumber(rb) && ttisnumber(rc)) { lua_Number nb = nvalue(rb), nc = nvalue(rc); - setnvalue(ra, luai_nummod(L, nb, nc)); + setnvalue(ra, luai_nummod(nb, nc)); } else Protect(Arith(L, ra, rb, rc, TM_MOD)); @@ -513,7 +513,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { TValue *rc = RKC(i); if (ttisnumber(rb) && ttisnumber(rc)) { lua_Number nb = nvalue(rb), nc = nvalue(rc); - setnvalue(ra, luai_numpow(L, nb, nc)); + setnvalue(ra, luai_numpow(nb, nc)); } else Protect(Arith(L, ra, rb, rc, TM_POW)); @@ -523,7 +523,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { TValue *rb = RB(i); if (ttisnumber(rb)) { lua_Number nb = nvalue(rb); - setnvalue(ra, luai_numunm(L, nb)); + setnvalue(ra, luai_numunm(nb)); } else { Protect(Arith(L, ra, rb, rb, TM_UNM)); @@ -677,9 +677,9 @@ void luaV_execute (lua_State *L, int nexeccalls) { } case OP_FORLOOP: { lua_Number step = nvalue(ra+2); - lua_Number idx = luai_numadd(L, nvalue(ra), step); /* increment index */ + lua_Number idx = luai_numadd(nvalue(ra), step); /* increment index */ lua_Number limit = nvalue(ra+1); - if (step > 0 ? luai_numle(L, idx, limit) : luai_numle(L, limit, idx)) { + if (step > 0 ? luai_numle(idx, limit) : luai_numle(limit, idx)) { dojump(L, pc, GETARG_sBx(i)); /* jump back */ setnvalue(ra, idx); /* update internal index... */ setnvalue(ra+3, idx); /* ...and external index */ @@ -697,7 +697,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { luaG_runerror(L, LUA_QL("for") " limit must be a number"); else if (!tonumber(pstep, ra+2)) luaG_runerror(L, LUA_QL("for") " step must be a number"); - setnvalue(ra, luai_numsub(L, nvalue(ra), nvalue(pstep))); + setnvalue(ra, luai_numsub(nvalue(ra), nvalue(pstep))); dojump(L, pc, GETARG_sBx(i)); continue; }