** Return false if folding can raise an error. ** Bitwise operations need operands convertible to integers; division ** operations cannot have 0 as divisor. */
| 1539 | ** operations cannot have 0 as divisor. |
| 1540 | */ |
| 1541 | static int validop (int op, TValue *v1, TValue *v2) { |
| 1542 | switch (op) { |
| 1543 | case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: |
| 1544 | case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ |
| 1545 | lua_Integer i; |
| 1546 | return (luaV_tointegerns(v1, &i, LUA_FLOORN2I) && |
| 1547 | luaV_tointegerns(v2, &i, LUA_FLOORN2I)); |
| 1548 | } |
| 1549 | case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ |
| 1550 | return (nvalue(v2) != 0); |
| 1551 | default: return 1; /* everything else is valid */ |
| 1552 | } |
| 1553 | } |
| 1554 | |
| 1555 | |
| 1556 | /* |
no test coverage detected