MCPcopy Create free account
hub / github.com/Cubitect/cubiomes-viewer / luaK_posfix

Function luaK_posfix

lua/src/lcode.c:1660–1737  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1658** Finalize code for binary operation, after reading 2nd operand.
1659*/
1660void luaK_posfix (FuncState *fs, BinOpr opr,
1661 expdesc *e1, expdesc *e2, int line) {
1662 luaK_dischargevars(fs, e2);
1663 if (foldbinop(opr) && constfolding(fs, opr + LUA_OPADD, e1, e2))
1664 return; /* done by folding */
1665 switch (opr) {
1666 case OPR_AND: {
1667 lua_assert(e1->t == NO_JUMP); /* list closed by 'luaK_infix' */
1668 luaK_concat(fs, &e2->f, e1->f);
1669 *e1 = *e2;
1670 break;
1671 }
1672 case OPR_OR: {
1673 lua_assert(e1->f == NO_JUMP); /* list closed by 'luaK_infix' */
1674 luaK_concat(fs, &e2->t, e1->t);
1675 *e1 = *e2;
1676 break;
1677 }
1678 case OPR_CONCAT: { /* e1 .. e2 */
1679 luaK_exp2nextreg(fs, e2);
1680 codeconcat(fs, e1, e2, line);
1681 break;
1682 }
1683 case OPR_ADD: case OPR_MUL: {
1684 codecommutative(fs, opr, e1, e2, line);
1685 break;
1686 }
1687 case OPR_SUB: {
1688 if (finishbinexpneg(fs, e1, e2, OP_ADDI, line, TM_SUB))
1689 break; /* coded as (r1 + -I) */
1690 /* ELSE */
1691 } /* FALLTHROUGH */
1692 case OPR_DIV: case OPR_IDIV: case OPR_MOD: case OPR_POW: {
1693 codearith(fs, opr, e1, e2, 0, line);
1694 break;
1695 }
1696 case OPR_BAND: case OPR_BOR: case OPR_BXOR: {
1697 codebitwise(fs, opr, e1, e2, line);
1698 break;
1699 }
1700 case OPR_SHL: {
1701 if (isSCint(e1)) {
1702 swapexps(e1, e2);
1703 codebini(fs, OP_SHLI, e1, e2, 1, line, TM_SHL); /* I << r2 */
1704 }
1705 else if (finishbinexpneg(fs, e1, e2, OP_SHRI, line, TM_SHL)) {
1706 /* coded as (r1 >> -I) */;
1707 }
1708 else /* regular case (two registers) */
1709 codebinexpval(fs, OP_SHL, e1, e2, line);
1710 break;
1711 }
1712 case OPR_SHR: {
1713 if (isSCint(e2))
1714 codebini(fs, OP_SHRI, e1, e2, 0, line, TM_SHR); /* r1 >> I */
1715 else /* regular case (two registers) */
1716 codebinexpval(fs, OP_SHR, e1, e2, line);
1717 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