MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / validop

Function validop

extlibs/lua/src/lcode.c:1297–1308  ·  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

1295** operations cannot have 0 as divisor.
1296*/
1297static int validop (int op, TValue *v1, TValue *v2) {
1298 switch (op) {
1299 case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR:
1300 case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */
1301 lua_Integer i;
1302 return (tointegerns(v1, &i) && tointegerns(v2, &i));
1303 }
1304 case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */
1305 return (nvalue(v2) != 0);
1306 default: return 1; /* everything else is valid */
1307 }
1308}
1309
1310
1311/*

Callers 1

constfoldingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected