MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / registerlocalvar

Function registerlocalvar

src/Chain/libraries/glua/lparser.cpp:179–196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177
178
179static int registerlocalvar(LexState *ls, TString *varname) {
180 FuncState *fs = ls->fs;
181 Proto *f = fs->f;
182 int oldsize = f->sizelocvars;
183 luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
184 LocVar, SHRT_MAX, "local variables");
185 while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = nullptr;
186 f->locvars[fs->nlocvars].varname = varname;
187 if (testnext(ls, ':'))
188 {
189 TString *vartype = str_checkname(ls);
190 char *vartype_s = getstr(vartype);
191 f->locvars[fs->nlocvars].vartype = typename_to_int(vartype_s);
192 // TODO: store type info in bytecode, and check type when running
193 }
194 luaC_objbarrier(ls->L, f, varname);
195 return fs->nlocvars++;
196}
197
198
199static void new_localvar(LexState *ls, TString *name) {

Callers 1

new_localvarFunction · 0.85

Calls 3

testnextFunction · 0.85
str_checknameFunction · 0.85
typename_to_intFunction · 0.85

Tested by

no test coverage detected