MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / luaK_infix

Function luaK_infix

3rd/lua-5.4.3/src/lcode.c:1574–1615  ·  view source on GitHub ↗

** Process 1st operand 'v' of binary operation 'op' before reading ** 2nd operand. */

Source from the content-addressed store, hash-verified

1572** 2nd operand.
1573*/
1574void luaK_infix (FuncState *fs, BinOpr op, expdesc *v) {
1575 luaK_dischargevars(fs, v);
1576 switch (op) {
1577 case OPR_AND: {
1578 luaK_goiftrue(fs, v); /* go ahead only if 'v' is true */
1579 break;
1580 }
1581 case OPR_OR: {
1582 luaK_goiffalse(fs, v); /* go ahead only if 'v' is false */
1583 break;
1584 }
1585 case OPR_CONCAT: {
1586 luaK_exp2nextreg(fs, v); /* operand must be on the stack */
1587 break;
1588 }
1589 case OPR_ADD: case OPR_SUB:
1590 case OPR_MUL: case OPR_DIV: case OPR_IDIV:
1591 case OPR_MOD: case OPR_POW:
1592 case OPR_BAND: case OPR_BOR: case OPR_BXOR:
1593 case OPR_SHL: case OPR_SHR: {
1594 if (!tonumeral(v, NULL))
1595 luaK_exp2anyreg(fs, v);
1596 /* else keep numeral, which may be folded with 2nd operand */
1597 break;
1598 }
1599 case OPR_EQ: case OPR_NE: {
1600 if (!tonumeral(v, NULL))
1601 luaK_exp2RK(fs, v);
1602 /* else keep numeral, which may be an immediate operand */
1603 break;
1604 }
1605 case OPR_LT: case OPR_LE:
1606 case OPR_GT: case OPR_GE: {
1607 int dummy, dummy2;
1608 if (!isSCnumber(v, &dummy, &dummy2))
1609 luaK_exp2anyreg(fs, v);
1610 /* else keep numeral, which may be an immediate operand */
1611 break;
1612 }
1613 default: lua_assert(0);
1614 }
1615}
1616
1617/*
1618** Create code for '(e1 .. e2)'.

Callers 1

subexprFunction · 0.85

Calls 8

luaK_dischargevarsFunction · 0.85
luaK_goiftrueFunction · 0.85
luaK_goiffalseFunction · 0.85
luaK_exp2nextregFunction · 0.85
tonumeralFunction · 0.85
luaK_exp2anyregFunction · 0.85
luaK_exp2RKFunction · 0.85
isSCnumberFunction · 0.85

Tested by

no test coverage detected