** Return false if folding can raise an error. ** Bitwise operations need operands convertible to integers; division ** operations cannot have 0 as divisor. */
| 958 | ** operations cannot have 0 as divisor. |
| 959 | */ |
| 960 | static int validop (int op, TValue *v1, TValue *v2) { |
| 961 | switch (op) { |
| 962 | case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: |
| 963 | case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ |
| 964 | lua_Integer i; |
| 965 | return (tointeger(v1, &i) && tointeger(v2, &i)); |
| 966 | } |
| 967 | case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ |
| 968 | return (nvalue(v2) != 0); |
| 969 | default: return 1; /* everything else is valid */ |
| 970 | } |
| 971 | } |
| 972 | |
| 973 | |
| 974 | /* |