diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-07-09 17:11:30 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2003-07-09 17:11:30 -0300 |
commit | 265530478bf4db5c1404a60acede1befb7fc48f8 (patch) | |
tree | b2e63431763a9b1d7e9d97e3c6eb3570d2bee282 | |
parent | 00180bb133ef9a0c68efff6b396b255120fd7304 (diff) | |
download | lua-265530478bf4db5c1404a60acede1befb7fc48f8.tar.gz lua-265530478bf4db5c1404a60acede1befb7fc48f8.tar.bz2 lua-265530478bf4db5c1404a60acede1befb7fc48f8.zip |
more changes to reduce stack usage by the parser
-rw-r--r-- | lparser.c | 12 | ||||
-rw-r--r-- | lparser.h | 8 |
2 files changed, 11 insertions, 9 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.211 2003/05/14 21:02:39 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.212 2003/07/09 15:36:38 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -139,7 +139,7 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) { | |||
139 | FuncState *fs = ls->fs; | 139 | FuncState *fs = ls->fs; |
140 | Proto *f = fs->f; | 140 | Proto *f = fs->f; |
141 | luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, | 141 | luaM_growvector(ls->L, f->locvars, fs->nlocvars, f->sizelocvars, |
142 | LocVar, MAX_INT, ""); | 142 | LocVar, USHRT_MAX, "too many local variables"); |
143 | f->locvars[fs->nlocvars].varname = varname; | 143 | f->locvars[fs->nlocvars].varname = varname; |
144 | return fs->nlocvars++; | 144 | return fs->nlocvars++; |
145 | } | 145 | } |
@@ -148,7 +148,8 @@ static int luaI_registerlocalvar (LexState *ls, TString *varname) { | |||
148 | static void new_localvar (LexState *ls, TString *name, int n) { | 148 | static void new_localvar (LexState *ls, TString *name, int n) { |
149 | FuncState *fs = ls->fs; | 149 | FuncState *fs = ls->fs; |
150 | luaX_checklimit(ls, fs->nactvar+n+1, MAXVARS, "local variables"); | 150 | luaX_checklimit(ls, fs->nactvar+n+1, MAXVARS, "local variables"); |
151 | fs->actvar[fs->nactvar+n] = luaI_registerlocalvar(ls, name); | 151 | fs->actvar[fs->nactvar+n] = cast(unsigned short, |
152 | luaI_registerlocalvar(ls, name)); | ||
152 | } | 153 | } |
153 | 154 | ||
154 | 155 | ||
@@ -187,8 +188,9 @@ static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { | |||
187 | luaM_growvector(fs->L, fs->f->upvalues, f->nups, fs->f->sizeupvalues, | 188 | luaM_growvector(fs->L, fs->f->upvalues, f->nups, fs->f->sizeupvalues, |
188 | TString *, MAX_INT, ""); | 189 | TString *, MAX_INT, ""); |
189 | fs->f->upvalues[f->nups] = name; | 190 | fs->f->upvalues[f->nups] = name; |
190 | fs->upvalues[f->nups].k = v->k; | 191 | lua_assert(v->k == VLOCAL || v->k == VUPVAL); |
191 | fs->upvalues[f->nups].info = v->info; | 192 | fs->upvalues[f->nups].k = cast(lu_byte, v->k); |
193 | fs->upvalues[f->nups].info = cast(lu_byte, v->info); | ||
192 | return f->nups++; | 194 | return f->nups++; |
193 | } | 195 | } |
194 | 196 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.h,v 1.47 2003/02/11 10:46:24 roberto Exp roberto $ | 2 | ** $Id: lparser.h,v 1.48 2003/07/09 15:36:38 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -42,8 +42,8 @@ typedef struct expdesc { | |||
42 | 42 | ||
43 | 43 | ||
44 | typedef struct upvaldesc { | 44 | typedef struct upvaldesc { |
45 | expkind k; | 45 | lu_byte k; |
46 | int info; | 46 | lu_byte info; |
47 | } upvaldesc; | 47 | } upvaldesc; |
48 | 48 | ||
49 | 49 | ||
@@ -67,7 +67,7 @@ typedef struct FuncState { | |||
67 | int nlocvars; /* number of elements in `locvars' */ | 67 | int nlocvars; /* number of elements in `locvars' */ |
68 | lu_byte nactvar; /* number of active local variables */ | 68 | lu_byte nactvar; /* number of active local variables */ |
69 | upvaldesc upvalues[MAXUPVALUES]; /* upvalues */ | 69 | upvaldesc upvalues[MAXUPVALUES]; /* upvalues */ |
70 | int actvar[MAXVARS]; /* declared-variable stack */ | 70 | unsigned short actvar[MAXVARS]; /* declared-variable stack */ |
71 | } FuncState; | 71 | } FuncState; |
72 | 72 | ||
73 | 73 | ||