MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / localstat

Function localstat

lib/lua/src/lparser.c:1726–1765  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

statementFunction · 0.85

Calls 11

new_localvarFunction · 0.85
str_checknameFunction · 0.85
getlocalattributeFunction · 0.85
getlocalvardescFunction · 0.85
luaK_semerrorFunction · 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