MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / leaveblock

Function leaveblock

lib/lua/src/lparser.c:672–692  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

670
671
672static void leaveblock (FuncState *fs) {
673 BlockCnt *bl = fs->bl;
674 LexState *ls = fs->ls;
675 int hasclose = 0;
676 int stklevel = reglevel(fs, bl->nactvar); /* level outside the block */
677 removevars(fs, bl->nactvar); /* remove block locals */
678 lua_assert(bl->nactvar == fs->nactvar); /* back to level on entry */
679 if (bl->isloop) /* has to fix pending breaks? */
680 hasclose = createlabel(ls, luaS_newliteral(ls->L, "break"), 0, 0);
681 if (!hasclose && bl->previous && bl->upval) /* still need a 'close'? */
682 luaK_codeABC(fs, OP_CLOSE, stklevel, 0, 0);
683 fs->freereg = stklevel; /* free registers */
684 ls->dyd->label.n = bl->firstlabel; /* remove local labels */
685 fs->bl = bl->previous; /* current block now is previous one */
686 if (bl->previous) /* was it a nested block? */
687 movegotosout(fs, bl); /* update pending gotos to enclosing block */
688 else {
689 if (bl->firstgoto < ls->dyd->gt.n) /* still pending gotos? */
690 undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */
691 }
692}
693
694
695/*

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
removevarsFunction · 0.85
createlabelFunction · 0.85
movegotosoutFunction · 0.85
undefgotoFunction · 0.85

Tested by 1

test_then_blockFunction · 0.68