|
@ -1,5 +1,5 @@ |
|
|
/*
|
|
|
/*
|
|
|
** $Id: lparser.c,v 2.148 2015/10/28 17:28:40 roberto Exp roberto $ |
|
|
** $Id: lparser.c,v 2.149 2015/11/02 16:09:30 roberto Exp roberto $ |
|
|
** Lua Parser |
|
|
** Lua Parser |
|
|
** See Copyright Notice in lua.h |
|
|
** See Copyright Notice in lua.h |
|
|
*/ |
|
|
*/ |
|
@ -164,7 +164,8 @@ static int registerlocalvar (LexState *ls, TString *varname) { |
|
|
int oldsize = f->sizelocvars; |
|
|
int oldsize = f->sizelocvars; |
|
|
luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, |
|
|
luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, |
|
|
LocVar, SHRT_MAX, "local variables"); |
|
|
LocVar, SHRT_MAX, "local variables"); |
|
|
while (oldsize < f->sizelocvars) f->locvars[oldsize++].varname = NULL; |
|
|
while (oldsize < f->sizelocvars) |
|
|
|
|
|
f->locvars[oldsize++].varname = NULL; |
|
|
f->locvars[fs->nlocvars].varname = varname; |
|
|
f->locvars[fs->nlocvars].varname = varname; |
|
|
luaC_objbarrier(ls->L, f, varname); |
|
|
luaC_objbarrier(ls->L, f, varname); |
|
|
return fs->nlocvars++; |
|
|
return fs->nlocvars++; |
|
@ -230,7 +231,8 @@ static int newupvalue (FuncState *fs, TString *name, expdesc *v) { |
|
|
checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues"); |
|
|
checklimit(fs, fs->nups + 1, MAXUPVAL, "upvalues"); |
|
|
luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues, |
|
|
luaM_growvector(fs->ls->L, f->upvalues, fs->nups, f->sizeupvalues, |
|
|
Upvaldesc, MAXUPVAL, "upvalues"); |
|
|
Upvaldesc, MAXUPVAL, "upvalues"); |
|
|
while (oldsize < f->sizeupvalues) f->upvalues[oldsize++].name = NULL; |
|
|
while (oldsize < f->sizeupvalues) |
|
|
|
|
|
f->upvalues[oldsize++].name = NULL; |
|
|
f->upvalues[fs->nups].instack = (v->k == VLOCAL); |
|
|
f->upvalues[fs->nups].instack = (v->k == VLOCAL); |
|
|
f->upvalues[fs->nups].idx = cast_byte(v->u.info); |
|
|
f->upvalues[fs->nups].idx = cast_byte(v->u.info); |
|
|
f->upvalues[fs->nups].name = name; |
|
|
f->upvalues[fs->nups].name = name; |
|
@ -255,7 +257,8 @@ static int searchvar (FuncState *fs, TString *n) { |
|
|
*/ |
|
|
*/ |
|
|
static void markupval (FuncState *fs, int level) { |
|
|
static void markupval (FuncState *fs, int level) { |
|
|
BlockCnt *bl = fs->bl; |
|
|
BlockCnt *bl = fs->bl; |
|
|
while (bl->nactvar > level) bl = bl->previous; |
|
|
while (bl->nactvar > level) |
|
|
|
|
|
bl = bl->previous; |
|
|
bl->upval = 1; |
|
|
bl->upval = 1; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -499,7 +502,8 @@ static Proto *addprototype (LexState *ls) { |
|
|
if (fs->np >= f->sizep) { |
|
|
if (fs->np >= f->sizep) { |
|
|
int oldsize = f->sizep; |
|
|
int oldsize = f->sizep; |
|
|
luaM_growvector(L, f->p, fs->np, f->sizep, Proto *, MAXARG_Bx, "functions"); |
|
|
luaM_growvector(L, f->p, fs->np, f->sizep, Proto *, MAXARG_Bx, "functions"); |
|
|
while (oldsize < f->sizep) f->p[oldsize++] = NULL; |
|
|
while (oldsize < f->sizep) |
|
|
|
|
|
f->p[oldsize++] = NULL; |
|
|
} |
|
|
} |
|
|
f->p[fs->np++] = clp = luaF_newproto(L); |
|
|
f->p[fs->np++] = clp = luaF_newproto(L); |
|
|
luaC_objbarrier(L, f, clp); |
|
|
luaC_objbarrier(L, f, clp); |
|
|