** Emit code for equality comparisons ('==', '~='). ** 'e1' was already put as RK by 'luaK_infix'. */
| 1582 | ** 'e1' was already put as RK by 'luaK_infix'. |
| 1583 | */ |
| 1584 | static void codeeq (FuncState *fs, BinOpr opr, expdesc *e1, expdesc *e2) { |
| 1585 | int r1, r2; |
| 1586 | int im; |
| 1587 | int isfloat = 0; /* not needed here, but kept for symmetry */ |
| 1588 | OpCode op; |
| 1589 | if (e1->k != VNONRELOC) { |
| 1590 | lua_assert(e1->k == VK || e1->k == VKINT || e1->k == VKFLT); |
| 1591 | swapexps(e1, e2); |
| 1592 | } |
| 1593 | r1 = luaK_exp2anyreg(fs, e1); /* 1st expression must be in register */ |
| 1594 | if (isSCnumber(e2, &im, &isfloat)) { |
| 1595 | op = OP_EQI; |
| 1596 | r2 = im; /* immediate operand */ |
| 1597 | } |
| 1598 | else if (exp2RK(fs, e2)) { /* 2nd expression is constant? */ |
| 1599 | op = OP_EQK; |
| 1600 | r2 = e2->u.info; /* constant index */ |
| 1601 | } |
| 1602 | else { |
| 1603 | op = OP_EQ; /* will compare two registers */ |
| 1604 | r2 = luaK_exp2anyreg(fs, e2); |
| 1605 | } |
| 1606 | freeexps(fs, e1, e2); |
| 1607 | e1->u.info = condjump(fs, op, r1, r2, isfloat, (opr == OPR_EQ)); |
| 1608 | e1->k = VJMP; |
| 1609 | } |
| 1610 | |
| 1611 | |
| 1612 | /* |
no test coverage detected