MCPcopy Create free account
hub / github.com/DFHack/dfhack / findlabel

Function findlabel

depends/lua/src/lparser.c:365–382  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

363** try to close a goto with existing labels; this solves backward jumps
364*/
365static 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
385static int newlabelentry (LexState *ls, Labellist *l, TString *name,

Callers 2

movegotosoutFunction · 0.85
gotostatFunction · 0.85

Calls 2

luaK_patchcloseFunction · 0.85
closegotoFunction · 0.85

Tested by

no test coverage detected