MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / localstat

Function localstat

extlibs/lua/src/lparser.c:1747–1786  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1745
1746
1747static void localstat (LexState *ls) {
1748 /* stat -> LOCAL ATTRIB NAME {',' ATTRIB NAME} ['=' explist] */
1749 FuncState *fs = ls->fs;
1750 int toclose = -1; /* index of to-be-closed variable (if any) */
1751 Vardesc *var; /* last variable */
1752 int ivar, kind; /* index and kind of last variable */
1753 int nvars = 0;
1754 int nexps;
1755 expdesc e;
1756 do {
1757 ivar = new_localvar(ls, str_checkname(ls));
1758 kind = getlocalattribute(ls);
1759 getlocalvardesc(fs, ivar)->vd.kind = kind;
1760 if (kind == RDKTOCLOSE) { /* to-be-closed? */
1761 if (toclose != -1) /* one already present? */
1762 luaK_semerror(ls, "multiple to-be-closed variables in local list");
1763 toclose = luaY_nvarstack(fs) + nvars;
1764 }
1765 nvars++;
1766 } while (testnext(ls, ','));
1767 if (testnext(ls, '='))
1768 nexps = explist(ls, &e);
1769 else {
1770 e.k = VVOID;
1771 nexps = 0;
1772 }
1773 var = getlocalvardesc(fs, ivar); /* get last variable */
1774 if (nvars == nexps && /* no adjustments? */
1775 var->vd.kind == RDKCONST && /* last variable is const? */
1776 luaK_exp2const(fs, &e, &var->k)) { /* compile-time constant? */
1777 var->vd.kind = RDKCTC; /* variable is a compile-time constant */
1778 adjustlocalvars(ls, nvars - 1); /* exclude last variable */
1779 fs->nactvar++; /* but count it */
1780 }
1781 else {
1782 adjust_assign(ls, nvars, nexps, &e);
1783 adjustlocalvars(ls, nvars);
1784 }
1785 checktoclose(ls, toclose);
1786}
1787
1788
1789static int funcname (LexState *ls, expdesc *v) {

Callers 1

statementFunction · 0.85

Calls 12

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

Tested by

no test coverage detected