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