diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-03-06 13:15:18 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2014-03-06 13:15:18 -0300 |
commit | 5ff1c18a715b842a6146a6a07d99c84f48cac999 (patch) | |
tree | b90579a688fd971f80e7628cba179fdf389a27c8 /lcode.c | |
parent | 99ac4a260fc1bf958515c1816d866852194493f2 (diff) | |
download | lua-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.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -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 | */ |
756 | static int validop (OpCode op, TValue *v1, TValue *v2) { | 756 | static 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); |