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

Function leaveblock

3rd/lua-5.4.3/src/lparser.c:660–680  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

658
659
660static void leaveblock (FuncState *fs) {
661 BlockCnt *bl = fs->bl;
662 LexState *ls = fs->ls;
663 int hasclose = 0;
664 int stklevel = reglevel(fs, bl->nactvar); /* level outside the block */
665 if (bl->isloop) /* fix pending breaks? */
666 hasclose = createlabel(ls, luaS_newliteral(ls->L, "break"), 0, 0);
667 if (!hasclose && bl->previous && bl->upval)
668 luaK_codeABC(fs, OP_CLOSE, stklevel, 0, 0);
669 fs->bl = bl->previous;
670 removevars(fs, bl->nactvar);
671 lua_assert(bl->nactvar == fs->nactvar);
672 fs->freereg = stklevel; /* free registers */
673 ls->dyd->label.n = bl->firstlabel; /* remove local labels */
674 if (bl->previous) /* inner block? */
675 movegotosout(fs, bl); /* update pending gotos to outer block */
676 else {
677 if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */
678 undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */
679 }
680}
681
682
683/*

Callers 7

close_funcFunction · 0.85
blockFunction · 0.85
whilestatFunction · 0.85
repeatstatFunction · 0.85
forbodyFunction · 0.85
forstatFunction · 0.85
test_then_blockFunction · 0.85

Calls 5

reglevelFunction · 0.85
createlabelFunction · 0.85
removevarsFunction · 0.85
movegotosoutFunction · 0.85
undefgotoFunction · 0.85

Tested by 1

test_then_blockFunction · 0.68