MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / luaK_goiftrue

Function luaK_goiftrue

extlibs/lua/src/lcode.c:1116–1137  ·  view source on GitHub ↗

** Emit code to go through if 'e' is true, jump otherwise. */

Source from the content-addressed store, hash-verified

1114** Emit code to go through if 'e' is true, jump otherwise.
1115*/
1116void luaK_goiftrue (FuncState *fs, expdesc *e) {
1117 int pc; /* pc of new jump */
1118 luaK_dischargevars(fs, e);
1119 switch (e->k) {
1120 case VJMP: { /* condition? */
1121 negatecondition(fs, e); /* jump when it is false */
1122 pc = e->u.info; /* save jump position */
1123 break;
1124 }
1125 case VK: case VKFLT: case VKINT: case VKSTR: case VTRUE: {
1126 pc = NO_JUMP; /* always true; do nothing */
1127 break;
1128 }
1129 default: {
1130 pc = jumponcond(fs, e, 0); /* jump when false */
1131 break;
1132 }
1133 }
1134 luaK_concat(fs, &e->f, pc); /* insert new jump in false list */
1135 luaK_patchtohere(fs, e->t); /* true list jumps to here (to go through) */
1136 e->t = NO_JUMP;
1137}
1138
1139
1140/*

Callers 3

condFunction · 0.85
test_then_blockFunction · 0.85
luaK_infixFunction · 0.85

Calls 5

luaK_dischargevarsFunction · 0.85
negateconditionFunction · 0.85
jumponcondFunction · 0.85
luaK_concatFunction · 0.85
luaK_patchtohereFunction · 0.85

Tested by 1

test_then_blockFunction · 0.68