| 670 | |
| 671 | |
| 672 | static 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 | /* |