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

Function validop

third-party/lua-5.5.0/src/lcode.c:1399–1411  ·  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

1397** operations cannot have 0 as divisor.
1398*/
1399static int validop (int op, TValue *v1, TValue *v2) {
1400 switch (op) {
1401 case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
1402 case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */
1403 lua_Integer i;
1404 return (luaV_tointegerns(v1, &i, LUA_FLOORN2I) &&
1405 luaV_tointegerns(v2, &i, LUA_FLOORN2I));
1406 }
1407 case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */
1408 return (nvalue(v2) != 0);
1409 default: return 1; /* everything else is valid */
1410 }
1411}
1412
1413
1414/*

Callers 1

constfoldingFunction · 0.70

Calls 1

luaV_tointegernsFunction · 0.70

Tested by

no test coverage detected