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

Function jumponcond

3rd/lua-5.4.3/src/lcode.c:1097–1109  ·  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

1095** and removing the 'not'.
1096*/
1097static int jumponcond (FuncState *fs, expdesc *e, int cond) {
1098 if (e->k == VRELOC) {
1099 Instruction ie = getinstruction(fs, e);
1100 if (GET_OPCODE(ie) == OP_NOT) {
1101 removelastinstruction(fs); /* remove previous OP_NOT */
1102 return condjump(fs, OP_TEST, GETARG_B(ie), 0, 0, !cond);
1103 }
1104 /* else go through */
1105 }
1106 discharge2anyreg(fs, e);
1107 freeexp(fs, e);
1108 return condjump(fs, OP_TESTSET, NO_REG, e->u.info, 0, cond);
1109}
1110
1111
1112/*

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