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

Function localstat

third-party/lua-5.5.0/src/lparser.c:1818–1859  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1816
1817
1818static void localstat (LexState *ls) {
1819 /* stat -> LOCAL NAME attrib { ',' NAME attrib } ['=' explist] */
1820 FuncState *fs = ls->fs;
1821 int toclose = -1; /* index of to-be-closed variable (if any) */
1822 Vardesc *var; /* last variable */
1823 int vidx; /* index of last variable */
1824 int nvars = 0;
1825 int nexps;
1826 expdesc e;
1827 /* get prefixed attribute (if any); default is regular local variable */
1828 lu_byte defkind = getvarattribute(ls, VDKREG);
1829 do { /* for each variable */
1830 TString *vname = str_checkname(ls); /* get its name */
1831 lu_byte kind = getvarattribute(ls, defkind); /* postfixed attribute */
1832 vidx = new_varkind(ls, vname, kind); /* predeclare it */
1833 if (kind == RDKTOCLOSE) { /* to-be-closed? */
1834 if (toclose != -1) /* one already present? */
1835 luaK_semerror(ls, "multiple to-be-closed variables in local list");
1836 toclose = fs->nactvar + nvars;
1837 }
1838 nvars++;
1839 } while (testnext(ls, ','));
1840 if (testnext(ls, '=')) /* initialization? */
1841 nexps = explist(ls, &e);
1842 else {
1843 e.k = VVOID;
1844 nexps = 0;
1845 }
1846 var = getlocalvardesc(fs, vidx); /* retrieve last variable */
1847 if (nvars == nexps && /* no adjustments? */
1848 var->vd.kind == RDKCONST && /* last variable is const? */
1849 luaK_exp2const(fs, &e, &var->k)) { /* compile-time constant? */
1850 var->vd.kind = RDKCTC; /* variable is a compile-time constant */
1851 adjustlocalvars(ls, nvars - 1); /* exclude last variable */
1852 fs->nactvar++; /* but count it */
1853 }
1854 else {
1855 adjust_assign(ls, nvars, nexps, &e);
1856 adjustlocalvars(ls, nvars);
1857 }
1858 checktoclose(fs, toclose);
1859}
1860
1861
1862static lu_byte getglobalattribute (LexState *ls, lu_byte df) {

Callers 1

statementFunction · 0.70

Calls 11

getvarattributeFunction · 0.85
new_varkindFunction · 0.85
str_checknameFunction · 0.70
luaK_semerrorFunction · 0.70
testnextFunction · 0.70
explistFunction · 0.70
getlocalvardescFunction · 0.70
luaK_exp2constFunction · 0.70
adjustlocalvarsFunction · 0.70
adjust_assignFunction · 0.70
checktocloseFunction · 0.70

Tested by

no test coverage detected