MCPcopy Create free account
hub / github.com/axmolengine/axmol / jumponcond

Function jumponcond

3rdparty/lua/plainlua/lcode.c:1117–1129  ·  view source on GitHub ↗

** Emit instruction to jump if 'e' is 'cond' (that is, if 'cond' ** is true, code will jump if 'e' is true.) Return jump position. ** Optimize when 'e' is 'not' something, inverting the condition ** and removing the 'not'. */

Source from the content-addressed store, hash-verified

1115** and removing the 'not'.
1116*/
1117static int jumponcond (FuncState *fs, expdesc *e, int cond) {
1118 if (e->k == VRELOC) {
1119 Instruction ie = getinstruction(fs, e);
1120 if (GET_OPCODE(ie) == OP_NOT) {
1121 removelastinstruction(fs); /* remove previous OP_NOT */
1122 return condjump(fs, OP_TEST, GETARG_B(ie), 0, 0, !cond);
1123 }
1124 /* else go through */
1125 }
1126 discharge2anyreg(fs, e);
1127 freeexp(fs, e);
1128 return condjump(fs, OP_TESTSET, NO_REG, e->u.info, 0, cond);
1129}
1130
1131
1132/*

Callers 2

luaK_goiftrueFunction · 0.85
luaK_goiffalseFunction · 0.85

Calls 4

removelastinstructionFunction · 0.85
condjumpFunction · 0.85
discharge2anyregFunction · 0.85
freeexpFunction · 0.85

Tested by

no test coverage detected