MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / finishbinexpneg

Function finishbinexpneg

3rd/lua-5.4.3/src/lcode.c:1398–1414  ·  view source on GitHub ↗

Try to code a binary operator negating its second operand. ** For the metamethod, 2nd operand must keep its original value. */

Source from the content-addressed store, hash-verified

1396** For the metamethod, 2nd operand must keep its original value.
1397*/
1398static int finishbinexpneg (FuncState *fs, expdesc *e1, expdesc *e2,
1399 OpCode op, int line, TMS event) {
1400 if (!luaK_isKint(e2))
1401 return 0; /* not an integer constant */
1402 else {
1403 lua_Integer i2 = e2->u.ival;
1404 if (!(fitsC(i2) && fitsC(-i2)))
1405 return 0; /* not in the proper range */
1406 else { /* operating a small integer constant */
1407 int v2 = cast_int(i2);
1408 finishbinexpval(fs, e1, e2, op, int2sC(-v2), 0, line, OP_MMBINI, event);
1409 /* correct metamethod argument */
1410 SETARG_B(fs->f->code[fs->pc - 1], int2sC(v2));
1411 return 1; /* successfully coded */
1412 }
1413 }
1414}
1415
1416
1417static void swapexps (expdesc *e1, expdesc *e2) {

Callers 1

luaK_posfixFunction · 0.85

Calls 3

luaK_isKintFunction · 0.85
fitsCFunction · 0.85
finishbinexpvalFunction · 0.85

Tested by

no test coverage detected