** try to close a goto with existing labels; this solves backward jumps */
| 363 | ** try to close a goto with existing labels; this solves backward jumps |
| 364 | */ |
| 365 | static int findlabel (LexState *ls, int g) { |
| 366 | int i; |
| 367 | BlockCnt *bl = ls->fs->bl; |
| 368 | Dyndata *dyd = ls->dyd; |
| 369 | Labeldesc *gt = &dyd->gt.arr[g]; |
| 370 | /* check labels in current block for a match */ |
| 371 | for (i = bl->firstlabel; i < dyd->label.n; i++) { |
| 372 | Labeldesc *lb = &dyd->label.arr[i]; |
| 373 | if (eqstr(lb->name, gt->name)) { /* correct label? */ |
| 374 | if (gt->nactvar > lb->nactvar && |
| 375 | (bl->upval || dyd->label.n > bl->firstlabel)) |
| 376 | luaK_patchclose(ls->fs, gt->pc, lb->nactvar); |
| 377 | closegoto(ls, g, lb); /* close it */ |
| 378 | return 1; |
| 379 | } |
| 380 | } |
| 381 | return 0; /* label not found; cannot close goto */ |
| 382 | } |
| 383 | |
| 384 | |
| 385 | static int newlabelentry (LexState *ls, Labellist *l, TString *name, |
no test coverage detected