** return false if folding can raise an error */
| 748 | ** return false if folding can raise an error |
| 749 | */ |
| 750 | static int validop(int op, TValue *v1, TValue *v2) { |
| 751 | switch (op) { |
| 752 | case LUA_OPBAND: case LUA_OPBOR: case LUA_OPBXOR: |
| 753 | case LUA_OPSHL: case LUA_OPSHR: case LUA_OPBNOT: { /* conversion errors */ |
| 754 | lua_Integer i; |
| 755 | return (tointeger(v1, &i) && tointeger(v2, &i)); |
| 756 | } |
| 757 | case LUA_OPDIV: case LUA_OPIDIV: case LUA_OPMOD: /* division by 0 */ |
| 758 | return (nvalue(v2) != 0); |
| 759 | default: return 1; /* everything else is valid */ |
| 760 | } |
| 761 | } |
| 762 | |
| 763 | |
| 764 | /* |