MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / codecommutative

Function codecommutative

third-party/lua-5.4.6/src/lcode.c:1517–1528  ·  view source on GitHub ↗

** Code commutative operators ('+', '*'). If first operand is a ** numeric constant, change order of operands to try to use an ** immediate or K operator. */

Source from the content-addressed store, hash-verified

1515** immediate or K operator.
1516*/
1517static void codecommutative (FuncState *fs, BinOpr op,
1518 expdesc *e1, expdesc *e2, int line) {
1519 int flip = 0;
1520 if (tonumeral(e1, NULL)) { /* is first operand a numeric constant? */
1521 swapexps(e1, e2); /* change order */
1522 flip = 1;
1523 }
1524 if (op == OPR_ADD && isSCint(e2)) /* immediate operand? */
1525 codebini(fs, OP_ADDI, e1, e2, flip, line, TM_ADD);
1526 else
1527 codearith(fs, op, e1, e2, flip, line);
1528}
1529
1530
1531/*

Callers 1

luaK_posfixFunction · 0.70

Calls 5

tonumeralFunction · 0.70
swapexpsFunction · 0.70
isSCintFunction · 0.70
codebiniFunction · 0.70
codearithFunction · 0.70

Tested by

no test coverage detected