aboutsummaryrefslogtreecommitdiff
path: root/lcode.c
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-06 13:15:18 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2014-03-06 13:15:18 -0300
commit5ff1c18a715b842a6146a6a07d99c84f48cac999 (patch)
treeb90579a688fd971f80e7628cba179fdf389a27c8 /lcode.c
parent99ac4a260fc1bf958515c1816d866852194493f2 (diff)
downloadlua-5ff1c18a715b842a6146a6a07d99c84f48cac999.tar.gz
lua-5ff1c18a715b842a6146a6a07d99c84f48cac999.tar.bz2
lua-5ff1c18a715b842a6146a6a07d99c84f48cac999.zip
back with 'L' for macros 'luai_num*', but now with a new macro
'luai_numinvalidop' to protect constant folding
Diffstat (limited to 'lcode.c')
-rw-r--r--lcode.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/lcode.c b/lcode.c
index 1e85dde0..6d26bd5c 100644
--- a/lcode.c
+++ b/lcode.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lcode.c,v 2.80 2014/03/06 13:39:05 roberto Exp roberto $ 2** $Id: lcode.c,v 2.81 2014/03/06 13:58:28 roberto Exp roberto $
3** Code generator for Lua 3** Code generator for Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -754,7 +754,11 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) {
754** return false if folding can raise an error 754** return false if folding can raise an error
755*/ 755*/
756static int validop (OpCode op, TValue *v1, TValue *v2) { 756static int validop (OpCode op, TValue *v1, TValue *v2) {
757 lua_Number a, b;
757 lua_Integer i; 758 lua_Integer i;
759 (void)a; (void)b; /* macro may not use its arguments */
760 if (luai_numinvalidop(op, (tonumber(v1, &a), a), (tonumber(v2, &b), b)))
761 return 0;
758 switch (op) { 762 switch (op) {
759 case LUA_OPIDIV: /* division by 0 and conversion errors */ 763 case LUA_OPIDIV: /* division by 0 and conversion errors */
760 return (tointeger(v1, &i) && tointeger(v2, &i) && i != 0); 764 return (tointeger(v1, &i) && tointeger(v2, &i) && i != 0);