MCPcopy Create free account
hub / github.com/DFHack/dfhack / validop

Function validop

depends/lua/src/lcode.c:960–971  ·  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

958** operations cannot have 0 as divisor.
959*/
960static int validop (int op, TValue *v1, TValue *v2) {
961 switch (op) {
962 case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
963 case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */
964 lua_Integer i;
965 return (tointeger(v1, &i) && tointeger(v2, &i));
966 }
967 case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */
968 return (nvalue(v2) != 0);
969 default: return 1; /* everything else is valid */
970 }
971}
972
973
974/*

Callers 1

constfoldingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected