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

Function codearith

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

1424** constant in the proper range, use variant opcodes with K operands.
1425*/
1426static void codearith (FuncState *fs, BinOpr opr,
1427 expdesc *e1, expdesc *e2, int flip, int line) {
1428 TMS event = cast(TMS, opr + TM_ADD);
1429 if (tonumeral(e2, NULL) && luaK_exp2K(fs, e2)) { /* K operand? */
1430 int v2 = e2->u.info; /* K index */
1431 OpCode op = cast(OpCode, opr + OP_ADDK);
1432 finishbinexpval(fs, e1, e2, op, v2, flip, line, OP_MMBINK, event);
1433 }
1434 else { /* 'e2' is neither an immediate nor a K operand */
1435 OpCode op = cast(OpCode, opr + OP_ADD);
1436 if (flip)
1437 swapexps(e1, e2); /* back to original order */
1438 codebinexpval(fs, op, e1, e2, line); /* use standard operators */
1439 }
1440}
1441
1442
1443/*

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