** Process 1st operand 'v' of binary operation 'op' before reading ** 2nd operand. */
| 1572 | ** 2nd operand. |
| 1573 | */ |
| 1574 | void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) { |
| 1575 | luaK_dischargevars(fs, v); |
| 1576 | switch (op) { |
| 1577 | case OPR_AND: { |
| 1578 | luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */ |
| 1579 | break; |
| 1580 | } |
| 1581 | case OPR_OR: { |
| 1582 | luaK_goiffalse(fs, v); /* go ahead only if 'v' is false */ |
| 1583 | break; |
| 1584 | } |
| 1585 | case OPR_CONCAT: { |
| 1586 | luaK_exp2nextreg(fs, v); /* operand must be on the stack */ |
| 1587 | break; |
| 1588 | } |
| 1589 | case OPR_ADD: case OPR_SUB: |
| 1590 | case OPR_MUL: case OPR_DIV: case OPR_IDIV: |
| 1591 | case OPR_MOD: case OPR_POW: |
| 1592 | case OPR_BAND: case OPR_BOR: case OPR_BXOR: |
| 1593 | case OPR_SHL: case OPR_SHR: { |
| 1594 | if (!tonumeral(v, NULL)) |
| 1595 | luaK_exp2anyreg(fs, v); |
| 1596 | /* else keep numeral, which may be folded with 2nd operand */ |
| 1597 | break; |
| 1598 | } |
| 1599 | case OPR_EQ: case OPR_NE: { |
| 1600 | if (!tonumeral(v, NULL)) |
| 1601 | luaK_exp2RK(fs, v); |
| 1602 | /* else keep numeral, which may be an immediate operand */ |
| 1603 | break; |
| 1604 | } |
| 1605 | case OPR_LT: case OPR_LE: |
| 1606 | case OPR_GT: case OPR_GE: { |
| 1607 | int dummy, dummy2; |
| 1608 | if (!isSCnumber(v, &dummy, &dummy2)) |
| 1609 | luaK_exp2anyreg(fs, v); |
| 1610 | /* else keep numeral, which may be an immediate operand */ |
| 1611 | break; |
| 1612 | } |
| 1613 | default: lua_assert(0); |
| 1614 | } |
| 1615 | } |
| 1616 | |
| 1617 | /* |
| 1618 | ** Create code for '(e1 .. e2)'. |
no test coverage detected