MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / codecommutative

Function codecommutative

lib/lua/src/lcode.c:1516–1527  ·  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

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

Callers 1

luaK_posfixFunction · 0.85

Calls 5

tonumeralFunction · 0.85
swapexpsFunction · 0.85
isSCintFunction · 0.85
codebiniFunction · 0.85
codearithFunction · 0.85

Tested by

no test coverage detected