** Return false if folding can raise an error. ** Bitwise operations need operands convertible to integers; division ** operations cannot have 0 as divisor. */
| 1397 | ** operations cannot have 0 as divisor. |
| 1398 | */ |
| 1399 | static 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 | /* |
no test coverage detected