** Return false if folding can raise an error. ** Bitwise operations need operands convertible to integers; division ** operations cannot have 0 as divisor. */
| 1312 | ** operations cannot have 0 as divisor. |
| 1313 | */ |
| 1314 | static int validop (int op, TValue *v1, TValue *v2) { |
| 1315 | switch (op) { |
| 1316 | case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: |
| 1317 | case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ |
| 1318 | lua_Integer i; |
| 1319 | return (luaV_tointegerns(v1, &i, LUA_FLOORN2I) && |
| 1320 | luaV_tointegerns(v2, &i, LUA_FLOORN2I)); |
| 1321 | } |
| 1322 | case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ |
| 1323 | return (nvalue(v2) != 0); |
| 1324 | default: return 1; /* everything else is valid */ |
| 1325 | } |
| 1326 | } |
| 1327 | |
| 1328 | |
| 1329 | /* |
no test coverage detected