From 26679ea35bf261f2b5edc2fb2f5cc4df483fd50d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 8 Nov 2017 12:50:23 -0200 Subject: new function 'luaV_flttointeger' to convert floats to integers (without string coercions) + string operands to bitwise operations handled by string metamethods --- lcode.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'lcode.c') diff --git a/lcode.c b/lcode.c index 5ca597eb..c36a49ad 100644 --- a/lcode.c +++ b/lcode.c @@ -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); -- cgit v1.2.3-55-g6feb