diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-12-26 16:46:09 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-12-26 16:46:09 -0200 |
commit | 8c49e198654567f770a7d5081b886a7c35201d81 (patch) | |
tree | 8c1de3e885ef138574e51a8868f175feeaab71e2 /lparser.c | |
parent | 6af005ec20323defd2a5ead01e2d389462884d04 (diff) | |
download | lua-8c49e198654567f770a7d5081b886a7c35201d81.tar.gz lua-8c49e198654567f770a7d5081b886a7c35201d81.tar.bz2 lua-8c49e198654567f770a7d5081b886a7c35201d81.zip |
explicit control of size for growing vectors
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 31 |
1 files changed, 19 insertions, 12 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.118 2000/11/30 18:50:47 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.119 2000/12/04 18:33:40 roberto Exp roberto $ |
3 | ** LL(1) Parser and code generator for Lua | 3 | ** LL(1) Parser and code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -121,8 +121,8 @@ static int string_constant (FuncState *fs, TString *s) { | |||
121 | Proto *f = fs->f; | 121 | Proto *f = fs->f; |
122 | int c = s->u.s.constindex; | 122 | int c = s->u.s.constindex; |
123 | if (c >= f->nkstr || f->kstr[c] != s) { | 123 | if (c >= f->nkstr || f->kstr[c] != s) { |
124 | luaM_growvector(fs->L, f->kstr, f->nkstr, 1, TString *, | 124 | luaM_growvector(fs->L, f->kstr, f->nkstr, fs->sizekstr, TString *, |
125 | "constant table overflow", MAXARG_U); | 125 | MAXARG_U, "constant table overflow"); |
126 | c = f->nkstr++; | 126 | c = f->nkstr++; |
127 | f->kstr[c] = s; | 127 | f->kstr[c] = s; |
128 | s->u.s.constindex = c; /* hint for next time */ | 128 | s->u.s.constindex = c; /* hint for next time */ |
@@ -152,7 +152,8 @@ static int checkname (LexState *ls) { | |||
152 | 152 | ||
153 | static int luaI_registerlocalvar (LexState *ls, TString *varname) { | 153 | static int luaI_registerlocalvar (LexState *ls, TString *varname) { |
154 | Proto *f = ls->fs->f; | 154 | Proto *f = ls->fs->f; |
155 | luaM_growvector(ls->L, f->locvars, f->nlocvars, 1, LocVar, "", MAX_INT); | 155 | luaM_growvector(ls->L, f->locvars, f->nlocvars, ls->fs->sizelocvars, |
156 | LocVar, MAX_INT, ""); | ||
156 | f->locvars[f->nlocvars].varname = varname; | 157 | f->locvars[f->nlocvars].varname = varname; |
157 | return f->nlocvars++; | 158 | return f->nlocvars++; |
158 | } | 159 | } |
@@ -294,8 +295,8 @@ static void pushclosure (LexState *ls, FuncState *func) { | |||
294 | int i; | 295 | int i; |
295 | for (i=0; i<func->nupvalues; i++) | 296 | for (i=0; i<func->nupvalues; i++) |
296 | luaK_tostack(ls, &func->upvalues[i], 1); | 297 | luaK_tostack(ls, &func->upvalues[i], 1); |
297 | luaM_growvector(ls->L, f->kproto, f->nkproto, 1, Proto *, | 298 | luaM_growvector(ls->L, f->kproto, f->nkproto, fs->sizekproto, Proto *, |
298 | "constant table overflow", MAXARG_A); | 299 | MAXARG_A, "constant table overflow"); |
299 | f->kproto[f->nkproto++] = func->f; | 300 | f->kproto[f->nkproto++] = func->f; |
300 | luaK_code2(fs, OP_CLOSURE, f->nkproto-1, func->nupvalues); | 301 | luaK_code2(fs, OP_CLOSURE, f->nkproto-1, func->nupvalues); |
301 | } | 302 | } |
@@ -303,21 +304,27 @@ static void pushclosure (LexState *ls, FuncState *func) { | |||
303 | 304 | ||
304 | static void open_func (LexState *ls, FuncState *fs) { | 305 | static void open_func (LexState *ls, FuncState *fs) { |
305 | Proto *f = luaF_newproto(ls->L); | 306 | Proto *f = luaF_newproto(ls->L); |
307 | fs->f = f; | ||
306 | fs->prev = ls->fs; /* linked list of funcstates */ | 308 | fs->prev = ls->fs; /* linked list of funcstates */ |
307 | fs->ls = ls; | 309 | fs->ls = ls; |
308 | fs->L = ls->L; | 310 | fs->L = ls->L; |
309 | ls->fs = fs; | 311 | ls->fs = fs; |
312 | fs->pc = 0; | ||
313 | fs->lasttarget = 0; | ||
314 | fs->jlt = NO_JUMP; | ||
310 | fs->stacklevel = 0; | 315 | fs->stacklevel = 0; |
316 | fs->sizekstr = 0; | ||
317 | fs->sizekproto = 0; | ||
318 | fs->sizeknum = 0; | ||
319 | fs->sizelineinfo = 0; | ||
320 | fs->sizecode = 0; | ||
321 | fs->sizelocvars = 0; | ||
311 | fs->nactloc = 0; | 322 | fs->nactloc = 0; |
312 | fs->nupvalues = 0; | 323 | fs->nupvalues = 0; |
313 | fs->bl = NULL; | ||
314 | fs->f = f; | ||
315 | f->source = ls->source; | ||
316 | fs->pc = 0; | ||
317 | fs->lasttarget = 0; | ||
318 | fs->lastline = 0; | 324 | fs->lastline = 0; |
319 | fs->jlt = NO_JUMP; | 325 | fs->bl = NULL; |
320 | f->code = NULL; | 326 | f->code = NULL; |
327 | f->source = ls->source; | ||
321 | f->maxstacksize = 0; | 328 | f->maxstacksize = 0; |
322 | f->numparams = 0; /* default for main chunk */ | 329 | f->numparams = 0; /* default for main chunk */ |
323 | f->is_vararg = 0; /* default for main chunk */ | 330 | f->is_vararg = 0; /* default for main chunk */ |