MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_then_block

Function test_then_block

freebsd/contrib/openzfs/module/lua/lparser.c:1378–1411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

ifstatFunction · 0.70

Calls 14

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

Tested by

no test coverage detected