MCPcopy Create free account
hub / github.com/PlutoLang/Pluto / codeorder

Function codeorder

src/lcode.cpp:1776–1801  ·  view source on GitHub ↗

** Emit code for order comparisons. When using an immediate operand, ** 'isfloat' tells whether the original value was a float. */

Source from the content-addressed store, hash-verified

1774** 'isfloat' tells whether the original value was a float.
1775*/
1776static void codeorder (FuncState *fs, BinOpr opr, expdesc *res, expdesc *e1, expdesc *e2) {
1777 int r1, r2;
1778 int im;
1779 int isfloat = 0;
1780 OpCode op;
1781 if (isSCnumber(e2, &im, &isfloat)) {
1782 /* use immediate operand */
1783 r1 = luaK_exp2anyreg(fs, e1);
1784 r2 = im;
1785 op = binopr2op(opr, OPR_LT, OP_LTI);
1786 }
1787 else if (isSCnumber(e1, &im, &isfloat)) {
1788 /* transform (A < B) to (B > A) and (A <= B) to (B >= A) */
1789 r1 = luaK_exp2anyreg(fs, e2);
1790 r2 = im;
1791 op = binopr2op(opr, OPR_LT, OP_GTI);
1792 }
1793 else { /* regular case, compare two registers */
1794 r1 = luaK_exp2anyreg(fs, e1);
1795 r2 = luaK_exp2anyreg(fs, e2);
1796 op = binopr2op(opr, OPR_LT, OP_LT);
1797 }
1798 freeexps(fs, e1, e2);
1799 res->u.pc = condjump(fs, op, r1, r2, isfloat, 1);
1800 res->k = VJMP;
1801}
1802
1803
1804/*

Callers 1

luaK_posfixFunction · 0.85

Calls 5

isSCnumberFunction · 0.85
luaK_exp2anyregFunction · 0.85
binopr2opFunction · 0.85
freeexpsFunction · 0.85
condjumpFunction · 0.85

Tested by

no test coverage detected