MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / luaK_goiftrue

Function luaK_goiftrue

lib/lua/src/lcode.c:1134–1155  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

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