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

Function luaK_goiftrue

xrepo/packages/l/lua/port/lua/src/lcode.c:1133–1154  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

1131** Emit code to go through if 'e' is true, jump otherwise.
1132*/
1133void luaK_goiftrue (FuncState *fs, expdesc *e) {
1134 int pc; /* pc of new jump */
1135 luaK_dischargevars(fs, e);
1136 switch (e->k) {
1137 case VJMP: { /* condition? */
1138 negatecondition(fs, e); /* jump when it is false */
1139 pc = e->u.info; /* save jump position */
1140 break;
1141 }
1142 case VK: case VKFLT: case VKINT: case VKSTR: case VTRUE: {
1143 pc = NO_JUMP; /* always true; do nothing */
1144 break;
1145 }
1146 default: {
1147 pc = jumponcond(fs, e, 0); /* jump when false */
1148 break;
1149 }
1150 }
1151 luaK_concat(fs, &e->f, pc); /* insert new jump in false list */
1152 luaK_patchtohere(fs, e->t); /* true list jumps to here (to go through) */
1153 e->t = NO_JUMP;
1154}
1155
1156
1157/*

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