MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / validop

Function validop

lib/lua/src/lcode.c:1317–1329  ·  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

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

Callers 1

constfoldingFunction · 0.85

Calls 1

luaV_tointegernsFunction · 0.85

Tested by

no test coverage detected