** try to close a goto with existing labels; this solves backward jumps */
| 383 | ** try to close a goto with existing labels; this solves backward jumps |
| 384 | */ |
| 385 | static int findlabel(LexState *ls, int g) { |
| 386 | int i; |
| 387 | BlockCnt *bl = ls->fs->bl; |
| 388 | Dyndata *dyd = ls->dyd; |
| 389 | Labeldesc *gt = &dyd->gt.arr[g]; |
| 390 | /* check labels in current block for a match */ |
| 391 | for (i = bl->firstlabel; i < dyd->label.n; i++) { |
| 392 | Labeldesc *lb = &dyd->label.arr[i]; |
| 393 | if (eqstr(lb->name, gt->name)) { /* correct label? */ |
| 394 | if (gt->nactvar > lb->nactvar && |
| 395 | (bl->upval || dyd->label.n > bl->firstlabel)) |
| 396 | luaK_patchclose(ls->fs, gt->pc, lb->nactvar); |
| 397 | closegoto(ls, g, lb); /* close it */ |
| 398 | return 1; |
| 399 | } |
| 400 | } |
| 401 | return 0; /* label not found; cannot close goto */ |
| 402 | } |
| 403 | |
| 404 | |
| 405 | static int newlabelentry(LexState *ls, Labellist *l, TString *name, |
no test coverage detected