MCPcopy Create free account
hub / github.com/DFHack/dfhack / leaveblock

Function leaveblock

depends/lua/src/lparser.c:473–493  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

471
472
473static void leaveblock (FuncState *fs) {
474 BlockCnt *bl = fs->bl;
475 LexState *ls = fs->ls;
476 if (bl->previous && bl->upval) {
477 /* create a 'jump to here' to close upvalues */
478 int j = luaK_jump(fs);
479 luaK_patchclose(fs, j, bl->nactvar);
480 luaK_patchtohere(fs, j);
481 }
482 if (bl->isloop)
483 breaklabel(ls); /* close pending breaks */
484 fs->bl = bl->previous;
485 removevars(fs, bl->nactvar);
486 lua_assert(bl->nactvar == fs->nactvar);
487 fs->freereg = fs->nactvar; /* free registers */
488 ls->dyd->label.n = bl->firstlabel; /* remove local labels */
489 if (bl->previous) /* inner block? */
490 movegotosout(fs, bl); /* update pending gotos to outer block */
491 else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */
492 undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */
493}
494
495
496/*

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 7

luaK_jumpFunction · 0.85
luaK_patchcloseFunction · 0.85
luaK_patchtohereFunction · 0.85
breaklabelFunction · 0.85
removevarsFunction · 0.85
movegotosoutFunction · 0.85
undefgotoFunction · 0.85

Tested by 1

test_then_blockFunction · 0.68