| 491 | |
| 492 | |
| 493 | static void leaveblock(FuncState *fs) { |
| 494 | BlockCnt *bl = fs->bl; |
| 495 | LexState *ls = fs->ls; |
| 496 | if (bl->previous && bl->upval) { |
| 497 | /* create a 'jump to here' to close upvalues */ |
| 498 | int j = luaK_jump(fs); |
| 499 | luaK_patchclose(fs, j, bl->nactvar); |
| 500 | luaK_patchtohere(fs, j); |
| 501 | } |
| 502 | if (bl->isloop) |
| 503 | breaklabel(ls); /* close pending breaks */ |
| 504 | fs->bl = bl->previous; |
| 505 | removevars(fs, bl->nactvar); |
| 506 | lua_assert(bl->nactvar == fs->nactvar); |
| 507 | fs->freereg = fs->nactvar; /* free registers */ |
| 508 | ls->dyd->label.n = bl->firstlabel; /* remove local labels */ |
| 509 | if (bl->previous) /* inner block? */ |
| 510 | movegotosout(fs, bl); /* update pending gotos to outer block */ |
| 511 | else if (bl->firstgoto < ls->dyd->gt.n) /* pending gotos in outer block? */ |
| 512 | undefgoto(ls, &ls->dyd->gt.arr[bl->firstgoto]); /* error */ |
| 513 | } |
| 514 | |
| 515 | |
| 516 | /* |