MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / jumponcond

Function jumponcond

third-party/lua-5.5.0/src/lcode.c:1160–1172  ·  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

1158** and removing the 'not'.
1159*/
1160static int jumponcond (FuncState *fs, expdesc *e, int cond) {
1161 if (e->k == VRELOC) {
1162 Instruction ie = getinstruction(fs, e);
1163 if (GET_OPCODE(ie) == OP_NOT) {
1164 removelastinstruction(fs); /* remove previous OP_NOT */
1165 return condjump(fs, OP_TEST, GETARG_B(ie), 0, 0, !cond);
1166 }
1167 /* else go through */
1168 }
1169 discharge2anyreg(fs, e);
1170 freeexp(fs, e);
1171 return condjump(fs, OP_TESTSET, NO_REG, e->u.info, 0, cond);
1172}
1173
1174
1175/*

Callers 2

luaK_goiftrueFunction · 0.70
luaK_goiffalseFunction · 0.70

Calls 4

removelastinstructionFunction · 0.70
condjumpFunction · 0.70
discharge2anyregFunction · 0.70
freeexpFunction · 0.70

Tested by

no test coverage detected