MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / test_then_block

Function test_then_block

third-party/lua-5.3.5/src/lparser.c:1382–1414  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1380
1381
1382static void test_then_block (LexState *ls, int *escapelist) {
1383 /* test_then_block -> [IF | ELSEIF] cond THEN block */
1384 BlockCnt bl;
1385 FuncState *fs = ls->fs;
1386 expdesc v;
1387 int jf; /* instruction to skip 'then' code (if condition is false) */
1388 luaX_next(ls); /* skip IF or ELSEIF */
1389 expr(ls, &v); /* read condition */
1390 checknext(ls, TK_THEN);
1391 if (ls->t.token == TK_GOTO || ls->t.token == TK_BREAK) {
1392 luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */
1393 enterblock(fs, &bl, 0); /* must enter block before 'goto' */
1394 gotostat(ls, v.t); /* handle goto/break */
1395 while (testnext(ls, ';')) {} /* skip colons */
1396 if (block_follow(ls, 0)) { /* 'goto' is the entire block? */
1397 leaveblock(fs);
1398 return; /* and that is it */
1399 }
1400 else /* must skip over 'then' part if condition is false */
1401 jf = luaK_jump(fs);
1402 }
1403 else { /* regular case (not goto/break) */
1404 luaK_goiftrue(ls->fs, &v); /* skip over block if condition is false */
1405 enterblock(fs, &bl, 0);
1406 jf = v.f;
1407 }
1408 statlist(ls); /* 'then' part */
1409 leaveblock(fs);
1410 if (ls->t.token == TK_ELSE ||
1411 ls->t.token == TK_ELSEIF) /* followed by 'else'/'elseif'? */
1412 luaK_concat(fs, escapelist, luaK_jump(fs)); /* must jump over it */
1413 luaK_patchtohere(fs, jf);
1414}
1415
1416
1417static void ifstat (LexState *ls, int line) {

Callers 1

ifstatFunction · 0.70

Calls 14

luaX_nextFunction · 0.70
exprFunction · 0.70
checknextFunction · 0.70
luaK_goiffalseFunction · 0.70
enterblockFunction · 0.70
gotostatFunction · 0.70
testnextFunction · 0.70
block_followFunction · 0.70
leaveblockFunction · 0.70
luaK_jumpFunction · 0.70
luaK_goiftrueFunction · 0.70
statlistFunction · 0.70

Tested by

no test coverage detected