| 177 | |
| 178 | |
| 179 | static 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 | |
| 199 | static void new_localvar(LexState *ls, TString *name) { |
no test coverage detected