new function 'luaV_flttointeger' to convert floats to integers (without
string coercions) + string operands to bitwise operations handled by string metamethods
This commit is contained in:
6
lcode.c
6
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);
|
||||
|
||||
Reference in New Issue
Block a user