MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / validop

Function validop

third-party/lua-5.4.6/src/lcode.c:1318–1330  ·  view source on GitHub ↗

** Return false if folding can raise an error. ** Bitwise operations need operands convertible to integers; division ** operations cannot have 0 as divisor. */

Source from the content-addressed store, hash-verified

1316** operations cannot have 0 as divisor.
1317*/
1318static int validop (int op, TValue *v1, TValue *v2) {
1319 switch (op) {
1320 case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
1321 case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */
1322 lua_Integer i;
1323 return (luaV_tointegerns(v1, &i, LUA_FLOORN2I) &&
1324 luaV_tointegerns(v2, &i, LUA_FLOORN2I));
1325 }
1326 case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */
1327 return (nvalue(v2) != 0);
1328 default: return 1; /* everything else is valid */
1329 }
1330}
1331
1332
1333/*

Callers 1

constfoldingFunction · 0.70

Calls 1

luaV_tointegernsFunction · 0.70

Tested by

no test coverage detected