MCPcopy Create free account
hub / github.com/DFHack/dfhack / jumponcond

Function jumponcond

depends/lua/src/lcode.c:839–851  ·  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

837** and removing the 'not'.
838*/
839static int jumponcond (FuncState *fs, expdesc *e, int cond) {
840 if (e->k == VRELOCABLE) {
841 Instruction ie = getinstruction(fs, e);
842 if (GET_OPCODE(ie) == OP_NOT) {
843 fs->pc--; /* remove previous OP_NOT */
844 return condjump(fs, OP_TEST, GETARG_B(ie), 0, !cond);
845 }
846 /* else go through */
847 }
848 discharge2anyreg(fs, e);
849 freeexp(fs, e);
850 return condjump(fs, OP_TESTSET, NO_REG, e->u.info, cond);
851}
852
853
854/*

Callers 2

luaK_goiftrueFunction · 0.85
luaK_goiffalseFunction · 0.85

Calls 3

condjumpFunction · 0.85
discharge2anyregFunction · 0.85
freeexpFunction · 0.85

Tested by

no test coverage detected