MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / findlabel

Function findlabel

src/Chain/libraries/glua/lparser.cpp:385–402  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

383** try to close a goto with existing labels; this solves backward jumps
384*/
385static 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
405static 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