diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-11-08 12:50:23 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-11-08 12:50:23 -0200 |
commit | 26679ea35bf261f2b5edc2fb2f5cc4df483fd50d (patch) | |
tree | 94c99ed74251cdf3e10a7e52560c3a7a78053ad1 /lcode.c | |
parent | c3e5946fb2b7b5781d9bca9d303967abe6263482 (diff) | |
download | lua-github-26679ea35bf261f2b5edc2fb2f5cc4df483fd50d.tar.gz |
new function 'luaV_flttointeger' to convert floats to integers (without
string coercions) + string operands to bitwise operations handled
by string metamethods
Diffstat (limited to 'lcode.c')
-rw-r--r-- | lcode.c | 6 |
1 files changed, 3 insertions, 3 deletions
@@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.130 2017/10/04 21:56:32 roberto Exp roberto $ +** $Id: lcode.c,v 2.131 2017/11/07 17:20:42 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -611,7 +611,7 @@ static void luaK_float (FuncState *fs, int reg, lua_Number f) { TValue v; lua_Integer fi; setfltvalue(&v, f); - if (luaV_tointeger(&v, &fi, 0) && + if (luaV_flttointeger(&v, &fi, 0) && l_castS2U(fi) + MAXARG_sBx <= l_castS2U(MAXARG_Bx)) luaK_codeAsBx(fs, OP_LOADF, reg, cast_int(fi)); else @@ -1146,7 +1146,7 @@ static int validop (int op, TValue *v1, TValue *v2) { case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ lua_Integer i; - return (tointeger(v1, &i) && tointeger(v2, &i)); + return (tointegerns(v1, &i) && tointegerns(v2, &i)); } case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ return (nvalue(v2) != 0); |