MCPcopy Create free account
hub / github.com/Cubitect/cubiomes-viewer / codearith

Function codearith

lua/src/lcode.c:1444–1458  ·  view source on GitHub ↗

** Code arithmetic operators ('+', '-', ...). If second operand is a ** constant in the proper range, use variant opcodes with K operands. */

Source from the content-addressed store, hash-verified

1442** constant in the proper range, use variant opcodes with K operands.
1443*/
1444static void codearith (FuncState *fs, BinOpr opr,
1445 expdesc *e1, expdesc *e2, int flip, int line) {
1446 TMS event = cast(TMS, opr + TM_ADD);
1447 if (tonumeral(e2, NULL) && luaK_exp2K(fs, e2)) { /* K operand? */
1448 int v2 = e2->u.info; /* K index */
1449 OpCode op = cast(OpCode, opr + OP_ADDK);
1450 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINK, event);
1451 }
1452 else { /* 'e2' is neither an immediate nor a K operand */
1453 OpCode op = cast(OpCode, opr + OP_ADD);
1454 if (flip)
1455 swapexps(e1, e2); /* back to original order */
1456 codebinexpval(fs, op, e1, e2, line); /* use standard operators */
1457 }
1458}
1459
1460
1461/*

Callers 2

codecommutativeFunction · 0.85
luaK_posfixFunction · 0.85

Calls 5

tonumeralFunction · 0.85
luaK_exp2KFunction · 0.85
finishbinexpvalFunction · 0.85
swapexpsFunction · 0.85
codebinexpvalFunction · 0.85

Tested by

no test coverage detected