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:
Roberto Ierusalimschy
2017-11-08 12:50:23 -02:00
parent c3e5946fb2
commit 26679ea35b
8 changed files with 126 additions and 48 deletions

5
ltm.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: ltm.c,v 2.45 2017/10/04 15:49:05 roberto Exp $
** $Id: ltm.c,v 2.47 2017/11/07 13:25:26 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@@ -153,8 +153,7 @@ void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2,
/* call never returns, but to avoid warnings: *//* FALLTHROUGH */
case TM_BAND: case TM_BOR: case TM_BXOR:
case TM_SHL: case TM_SHR: case TM_BNOT: {
lua_Number dummy;
if (tonumber(p1, &dummy) && tonumber(p2, &dummy))
if (ttisnumber(p1) && ttisnumber(p2))
luaG_tointerror(L, p1, p2);
else
luaG_opinterror(L, p1, p2, "perform bitwise operation on");