MCPcopy Create free account
hub / github.com/F-Stack/f-stack / findlabel

Function findlabel

freebsd/contrib/openzfs/module/lua/lparser.c:362–379  ·  view source on GitHub ↗

** try to close a goto with existing labels; this solves backward jumps */

Source from the content-addressed store, hash-verified

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

Callers 2

movegotosoutFunction · 0.85
gotostatFunction · 0.85

Calls 3

luaS_eqstrFunction · 0.85
luaK_patchcloseFunction · 0.85
closegotoFunction · 0.85

Tested by

no test coverage detected