commit 265530478bf4db5c1404a60acede1befb7fc48f8
parent 00180bb133ef9a0c68efff6b396b255120fd7304
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 9 Jul 2003 17:11:08 -0300
more changes to reduce stack usage by the parser
Diffstat:
2 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/lparser.c b/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 1.211 2003/05/14 21:02:39 roberto Exp roberto $
+** $Id: lparser.c,v 1.212 2003/07/09 15:36:38 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -139,7 +139,7 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) {
FuncState *fs = ls->fs;
Proto *f = fs->f;
luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars,
- LocVar, MAX_INT, "");
+ LocVar, USHRT_MAX, "too many local variables");
f->locvars[fs->nlocvars].varname = varname;
return fs->nlocvars++;
}
@@ -148,7 +148,8 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) {
static void new_localvar (LexState *ls, TString *name, int n) {
FuncState *fs = ls->fs;
luaX_checklimit(ls, fs->nactvar+n+1, MAXVARS, "local variables");
- fs->actvar[fs->nactvar+n] = luaI_registerlocalvar(ls, name);
+ fs->actvar[fs->nactvar+n] = cast(unsigned short,
+ luaI_registerlocalvar(ls, name));
}
@@ -187,8 +188,9 @@ static int indexupvalue (FuncState *fs, TString *name, expdesc *v) {
luaM_growvector(fs->L, fs->f->upvalues, f->nups, fs->f->sizeupvalues,
TString *, MAX_INT, "");
fs->f->upvalues[f->nups] = name;
- fs->upvalues[f->nups].k = v->k;
- fs->upvalues[f->nups].info = v->info;
+ lua_assert(v->k == VLOCAL || v->k == VUPVAL);
+ fs->upvalues[f->nups].k = cast(lu_byte, v->k);
+ fs->upvalues[f->nups].info = cast(lu_byte, v->info);
return f->nups++;
}
diff --git a/lparser.h b/lparser.h
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.h,v 1.47 2003/02/11 10:46:24 roberto Exp roberto $
+** $Id: lparser.h,v 1.48 2003/07/09 15:36:38 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -42,8 +42,8 @@ typedef struct expdesc {
typedef struct upvaldesc {
- expkind k;
- int info;
+ lu_byte k;
+ lu_byte info;
} upvaldesc;
@@ -67,7 +67,7 @@ typedef struct FuncState {
int nlocvars; /* number of elements in `locvars' */
lu_byte nactvar; /* number of active local variables */
upvaldesc upvalues[MAXUPVALUES]; /* upvalues */
- int actvar[MAXVARS]; /* declared-variable stack */
+ unsigned short actvar[MAXVARS]; /* declared-variable stack */
} FuncState;