MCPcopy Create free account
hub / github.com/axmolengine/axmol / luaK_posfix

Function luaK_posfix

3rdparty/lua/plainlua/lcode.c:1706–1780  ·  view source on GitHub ↗

** Finalize code for binary operation, after reading 2nd operand. */

Source from the content-addressed store, hash-verified

1704** Finalize code for binary operation, after reading 2nd operand.
1705*/
1706void luaK_posfix (FuncState *fs, BinOpr opr,
1707 expdesc *e1, expdesc *e2, int line) {
1708 luaK_dischargevars(fs, e2);
1709 if (foldbinop(opr) && constfolding(fs, opr + LUA_OPADD, e1, e2))
1710 return; /* done by folding */
1711 switch (opr) {
1712 case OPR_AND: {
1713 lua_assert(e1->t == NO_JUMP); /* list closed by 'luaK_infix' */
1714 luaK_concat(fs, &e2->f, e1->f);
1715 *e1 = *e2;
1716 break;
1717 }
1718 case OPR_OR: {
1719 lua_assert(e1->f == NO_JUMP); /* list closed by 'luaK_infix' */
1720 luaK_concat(fs, &e2->t, e1->t);
1721 *e1 = *e2;
1722 break;
1723 }
1724 case OPR_CONCAT: { /* e1 .. e2 */
1725 luaK_exp2nextreg(fs, e2);
1726 codeconcat(fs, e1, e2, line);
1727 break;
1728 }
1729 case OPR_ADD: case OPR_MUL: {
1730 codecommutative(fs, opr, e1, e2, line);
1731 break;
1732 }
1733 case OPR_SUB: {
1734 if (finishbinexpneg(fs, e1, e2, OP_ADDI, line, TM_SUB))
1735 break; /* coded as (r1 + -I) */
1736 /* ELSE */
1737 } /* FALLTHROUGH */
1738 case OPR_DIV: case OPR_IDIV: case OPR_MOD: case OPR_POW: {
1739 codearith(fs, opr, e1, e2, 0, line);
1740 break;
1741 }
1742 case OPR_BAND: case OPR_BOR: case OPR_BXOR: {
1743 codebitwise(fs, opr, e1, e2, line);
1744 break;
1745 }
1746 case OPR_SHL: {
1747 if (isSCint(e1)) {
1748 swapexps(e1, e2);
1749 codebini(fs, OP_SHLI, e1, e2, 1, line, TM_SHL); /* I << r2 */
1750 }
1751 else if (finishbinexpneg(fs, e1, e2, OP_SHRI, line, TM_SHL)) {
1752 /* coded as (r1 >> -I) */;
1753 }
1754 else /* regular case (two registers) */
1755 codebinexpval(fs, opr, e1, e2, line);
1756 break;
1757 }
1758 case OPR_SHR: {
1759 if (isSCint(e2))
1760 codebini(fs, OP_SHRI, e1, e2, 0, line, TM_SHR); /* r1 >> I */
1761 else /* regular case (two registers) */
1762 codebinexpval(fs, opr, e1, e2, line);
1763 break;

Callers 1

subexprFunction · 0.85

Calls 15

luaK_dischargevarsFunction · 0.85
constfoldingFunction · 0.85
luaK_concatFunction · 0.85
luaK_exp2nextregFunction · 0.85
codeconcatFunction · 0.85
codecommutativeFunction · 0.85
finishbinexpnegFunction · 0.85
codearithFunction · 0.85
codebitwiseFunction · 0.85
isSCintFunction · 0.85
swapexpsFunction · 0.85
codebiniFunction · 0.85

Tested by

no test coverage detected