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

Function codecommutative

extlibs/lua/src/lcode.c:1448–1459  ·  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

1446** immediate or K operator.
1447*/
1448static void codecommutative (FuncState *fs, BinOpr op,
1449 expdesc *e1, expdesc *e2, int line) {
1450 int flip = 0;
1451 if (tonumeral(e1, NULL)) { /* is first operand a numeric constant? */
1452 swapexps(e1, e2); /* change order */
1453 flip = 1;
1454 }
1455 if (op == OPR_ADD && isSCint(e2)) /* immediate operand? */
1456 codebini(fs, cast(OpCode, OP_ADDI), e1, e2, flip, line, TM_ADD);
1457 else
1458 codearith(fs, op, e1, e2, flip, line);
1459}
1460
1461
1462/*

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