mirror of https://github.com/rusefi/lua.git
simpler implementation for unary minus
This commit is contained in:
parent
39c0f391c6
commit
42a662334a
14
lvm.c
14
lvm.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lvm.c,v 2.49 2005/08/09 17:42:02 roberto Exp roberto $
|
** $Id: lvm.c,v 2.50 2005/08/09 19:49:04 roberto Exp roberto $
|
||||||
** Lua virtual machine
|
** Lua virtual machine
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -325,6 +325,7 @@ static void Arith (lua_State *L, StkId ra, const TValue *rb,
|
||||||
case TM_DIV: setnvalue(ra, luai_numdiv(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_MOD: setnvalue(ra, luai_nummod(L, nb, nc)); break;
|
||||||
case TM_POW: setnvalue(ra, luai_numpow(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;
|
||||||
default: lua_assert(0); break;
|
default: lua_assert(0); break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,18 +521,13 @@ StkId luaV_execute (lua_State *L, int nexeccalls) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case OP_UNM: {
|
case OP_UNM: {
|
||||||
const TValue *rb = RB(i);
|
TValue *rb = RB(i);
|
||||||
TValue temp;
|
if (ttisnumber(rb)) {
|
||||||
if (tonumber(rb, &temp)) {
|
|
||||||
lua_Number nb = nvalue(rb);
|
lua_Number nb = nvalue(rb);
|
||||||
setnvalue(ra, luai_numunm(L, nb));
|
setnvalue(ra, luai_numunm(L, nb));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb = RB(i); /* `tonumber' erased `rb' */
|
Protect(Arith(L, ra, rb, rb, TM_UNM));
|
||||||
Protect(
|
|
||||||
if (!call_binTM(L, rb, &luaO_nilobject, ra, TM_UNM))
|
|
||||||
luaG_aritherror(L, rb, &luaO_nilobject);
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue