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

Function localstat

third-party/lua-5.4.6/src/lparser.c:1725–1764  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1723
1724
1725static void localstat (LexState *ls) {
1726 /* stat -> LOCAL NAME ATTRIB { ',' NAME ATTRIB } ['=' explist] */
1727 FuncState *fs = ls->fs;
1728 int toclose = -1; /* index of to-be-closed variable (if any) */
1729 Vardesc *var; /* last variable */
1730 int vidx, kind; /* index and kind of last variable */
1731 int nvars = 0;
1732 int nexps;
1733 expdesc e;
1734 do {
1735 vidx = new_localvar(ls, str_checkname(ls));
1736 kind = getlocalattribute(ls);
1737 getlocalvardesc(fs, vidx)->vd.kind = kind;
1738 if (kind == RDKTOCLOSE) { /* to-be-closed? */
1739 if (toclose != -1) /* one already present? */
1740 luaK_semerror(ls, "multiple to-be-closed variables in local list");
1741 toclose = fs->nactvar + nvars;
1742 }
1743 nvars++;
1744 } while (testnext(ls, ','));
1745 if (testnext(ls, '='))
1746 nexps = explist(ls, &e);
1747 else {
1748 e.k = VVOID;
1749 nexps = 0;
1750 }
1751 var = getlocalvardesc(fs, vidx); /* get last variable */
1752 if (nvars == nexps && /* no adjustments? */
1753 var->vd.kind == RDKCONST && /* last variable is const? */
1754 luaK_exp2const(fs, &e, &var->k)) { /* compile-time constant? */
1755 var->vd.kind = RDKCTC; /* variable is a compile-time constant */
1756 adjustlocalvars(ls, nvars - 1); /* exclude last variable */
1757 fs->nactvar++; /* but count it */
1758 }
1759 else {
1760 adjust_assign(ls, nvars, nexps, &e);
1761 adjustlocalvars(ls, nvars);
1762 }
1763 checktoclose(fs, toclose);
1764}
1765
1766
1767static int funcname (LexState *ls, expdesc *v) {

Callers 1

statementFunction · 0.70

Calls 11

getlocalattributeFunction · 0.85
new_localvarFunction · 0.70
str_checknameFunction · 0.70
getlocalvardescFunction · 0.70
luaK_semerrorFunction · 0.70
testnextFunction · 0.70
explistFunction · 0.70
luaK_exp2constFunction · 0.70
adjustlocalvarsFunction · 0.70
adjust_assignFunction · 0.70
checktocloseFunction · 0.70

Tested by

no test coverage detected