MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / findlabel

Function findlabel

third-party/lua-5.2.4/src/lparser.c:364–381  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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

Callers 2

movegotosoutFunction · 0.70
gotostatFunction · 0.70

Calls 3

luaS_eqstrFunction · 0.70
luaK_patchcloseFunction · 0.70
closegotoFunction · 0.70

Tested by

no test coverage detected