** Emit code for order comparisons. When using an immediate operand, ** 'isfloat' tells whether the original value was a float. */
| 1490 | ** 'isfloat' tells whether the original value was a float. |
| 1491 | */ |
| 1492 | static void codeorder (FuncState *fs, OpCode op, expdesc *e1, expdesc *e2) { |
| 1493 | int r1, r2; |
| 1494 | int im; |
| 1495 | int isfloat = 0; |
| 1496 | if (isSCnumber(e2, &im, &isfloat)) { |
| 1497 | /* use immediate operand */ |
| 1498 | r1 = luaK_exp2anyreg(fs, e1); |
| 1499 | r2 = im; |
| 1500 | op = cast(OpCode, (op - OP_LT) + OP_LTI); |
| 1501 | } |
| 1502 | else if (isSCnumber(e1, &im, &isfloat)) { |
| 1503 | /* transform (A < B) to (B > A) and (A <= B) to (B >= A) */ |
| 1504 | r1 = luaK_exp2anyreg(fs, e2); |
| 1505 | r2 = im; |
| 1506 | op = (op == OP_LT) ? OP_GTI : OP_GEI; |
| 1507 | } |
| 1508 | else { /* regular case, compare two registers */ |
| 1509 | r1 = luaK_exp2anyreg(fs, e1); |
| 1510 | r2 = luaK_exp2anyreg(fs, e2); |
| 1511 | } |
| 1512 | freeexps(fs, e1, e2); |
| 1513 | e1->u.info = condjump(fs, op, r1, r2, isfloat, 1); |
| 1514 | e1->k = VJMP; |
| 1515 | } |
| 1516 | |
| 1517 | |
| 1518 | /* |
no test coverage detected