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