MCPcopy Create free account
hub / github.com/danomatika/ofxLua / luaK_posfix

Function luaK_posfix

libs/lua/lcode.c:1702–1776  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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