** Emit code for equality comparisons ('==', '~='). ** 'e1' was already put as RK by 'luaK_infix'. */
| 1664 | ** 'e1' was already put as RK by 'luaK_infix'. |
| 1665 | */ |
| 1666 | static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { |
| 1667 | int r1, r2; |
| 1668 | int im; |
| 1669 | int isfloat = 0; /* not needed here, but kept for symmetry */ |
| 1670 | OpCode op; |
| 1671 | if (e1->k != VNONRELOC) { |
| 1672 | lua_assert(e1->k == VK || e1->k == VKINT || e1->k == VKFLT); |
| 1673 | swapexps(e1, e2); |
| 1674 | } |
| 1675 | r1 = luaK_exp2anyreg(fs, e1); /* 1st expression must be in register */ |
| 1676 | if (isSCnumber(e2, &im, &isfloat)) { |
| 1677 | op = OP_EQI; |
| 1678 | r2 = im; /* immediate operand */ |
| 1679 | } |
| 1680 | else if (exp2RK(fs, e2)) { /* 2nd expression is constant? */ |
| 1681 | op = OP_EQK; |
| 1682 | r2 = e2->u.info; /* constant index */ |
| 1683 | } |
| 1684 | else { |
| 1685 | op = OP_EQ; /* will compare two registers */ |
| 1686 | r2 = luaK_exp2anyreg(fs, e2); |
| 1687 | } |
| 1688 | freeexps(fs, e1, e2); |
| 1689 | e1->u.info = condjump(fs, op, r1, r2, isfloat, (opr == OPR_EQ)); |
| 1690 | e1->k = VJMP; |
| 1691 | } |
| 1692 | |
| 1693 | |
| 1694 | /* |
no test coverage detected