MCPcopy Create free account
hub / github.com/SakuraEngine/SakuraEngine / codecommutative

Function codecommutative

xrepo/packages/l/lua/port/lua/src/lcode.c:1466–1477  ·  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

1464** immediate or K operator.
1465*/
1466static void codecommutative (FuncState *fs, BinOpr op,
1467 expdesc *e1, expdesc *e2, int line) {
1468 int flip = 0;
1469 if (tonumeral(e1, NULL)) { /* is first operand a numeric constant? */
1470 swapexps(e1, e2); /* change order */
1471 flip = 1;
1472 }
1473 if (op == OPR_ADD && isSCint(e2)) /* immediate operand? */
1474 codebini(fs, cast(OpCode, OP_ADDI), e1, e2, flip, line, TM_ADD);
1475 else
1476 codearith(fs, op, e1, e2, flip, line);
1477}
1478
1479
1480/*

Callers 1

luaK_posfixFunction · 0.85

Calls 6

tonumeralFunction · 0.85
swapexpsFunction · 0.85
isSCintFunction · 0.85
codebiniFunction · 0.85
codearithFunction · 0.85
castFunction · 0.50

Tested by

no test coverage detected