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

Function test_then_block

third-party/lua-5.2.4/src/lparser.c:1374–1406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1372
1373
1374static void test_then_block (LexState *ls, int *escapelist) {
1375 /* test_then_block -> [IF | ELSEIF] cond THEN block */
1376 BlockCnt bl;
1377 FuncState *fs = ls->fs;
1378 expdesc v;
1379 int jf; /* instruction to skip 'then' code (if condition is false) */
1380 luaX_next(ls); /* skip IF or ELSEIF */
1381 expr(ls, &v); /* read condition */
1382 checknext(ls, TK_THEN);
1383 if (ls->t.token == TK_GOTO || ls->t.token == TK_BREAK) {
1384 luaK_goiffalse(ls->fs, &v); /* will jump to label if condition is true */
1385 enterblock(fs, &bl, 0); /* must enter block before 'goto' */
1386 gotostat(ls, v.t); /* handle goto/break */
1387 skipnoopstat(ls); /* skip other no-op statements */
1388 if (block_follow(ls, 0)) { /* 'goto' is the entire block? */
1389 leaveblock(fs);
1390 return; /* and that is it */
1391 }
1392 else /* must skip over 'then' part if condition is false */
1393 jf = luaK_jump(fs);
1394 }
1395 else { /* regular case (not goto/break) */
1396 luaK_goiftrue(ls->fs, &v); /* skip over block if condition is false */
1397 enterblock(fs, &bl, 0);
1398 jf = v.f;
1399 }
1400 statlist(ls); /* `then' part */
1401 leaveblock(fs);
1402 if (ls->t.token == TK_ELSE ||
1403 ls->t.token == TK_ELSEIF) /* followed by 'else'/'elseif'? */
1404 luaK_concat(fs, escapelist, luaK_jump(fs)); /* must jump over it */
1405 luaK_patchtohere(fs, jf);
1406}
1407
1408
1409static 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
skipnoopstatFunction · 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