MCPcopy Create free account
hub / github.com/CppCXY/EmmyLuaCodeStyle / luaK_goiftrue

Function luaK_goiftrue

3rd/lua-5.4.3/src/lcode.c:1115–1136  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

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