diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-02-26 12:48:55 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 1999-02-26 12:48:55 -0300 |
commit | 72d675aba78d59e22ebfadbe447f4f51ddab5a5c (patch) | |
tree | 2f43006cba58bcfc97f01ecdd6f00e35e92aa673 /lparser.c | |
parent | ba57f7d946bc0b600996f7a982b2fb644df76a98 (diff) | |
download | lua-72d675aba78d59e22ebfadbe447f4f51ddab5a5c.tar.gz lua-72d675aba78d59e22ebfadbe447f4f51ddab5a5c.tar.bz2 lua-72d675aba78d59e22ebfadbe447f4f51ddab5a5c.zip |
macros "growvector" and "reallocvector" more compact
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.23 1999/02/25 15:16:26 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.24 1999/02/25 19:13:56 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 | */ |
@@ -131,7 +131,7 @@ static void var_or_func_tail (LexState *ls, vardesc *v); | |||
131 | 131 | ||
132 | 132 | ||
133 | static void check_pc (FuncState *fs, int n) { | 133 | static void check_pc (FuncState *fs, int n) { |
134 | fs->f->code = luaM_growvector(fs->f->code, fs->pc, n, Byte, codeEM, MAX_INT); | 134 | luaM_growvector(fs->f->code, fs->pc, n, Byte, codeEM, MAX_INT); |
135 | } | 135 | } |
136 | 136 | ||
137 | 137 | ||
@@ -216,8 +216,7 @@ static void code_constant (LexState *ls, int c) { | |||
216 | 216 | ||
217 | static int next_constant (FuncState *fs) { | 217 | static int next_constant (FuncState *fs) { |
218 | TProtoFunc *f = fs->f; | 218 | TProtoFunc *f = fs->f; |
219 | f->consts = luaM_growvector(f->consts, f->nconsts, 1, TObject, | 219 | luaM_growvector(f->consts, f->nconsts, 1, TObject, constantEM, MAX_ARG); |
220 | constantEM, MAX_ARG); | ||
221 | return f->nconsts++; | 220 | return f->nconsts++; |
222 | } | 221 | } |
223 | 222 | ||
@@ -289,7 +288,7 @@ static void luaI_registerlocalvar (FuncState *fs, TaggedString *varname, | |||
289 | int line) { | 288 | int line) { |
290 | if (fs->nvars != -1) { /* debug information? */ | 289 | if (fs->nvars != -1) { /* debug information? */ |
291 | TProtoFunc *f = fs->f; | 290 | TProtoFunc *f = fs->f; |
292 | f->locvars = luaM_growvector(f->locvars, fs->nvars, 1, LocVar, "", MAX_INT); | 291 | luaM_growvector(f->locvars, fs->nvars, 1, LocVar, "", MAX_INT); |
293 | f->locvars[fs->nvars].varname = varname; | 292 | f->locvars[fs->nvars].varname = varname; |
294 | f->locvars[fs->nvars].line = line; | 293 | f->locvars[fs->nvars].line = line; |
295 | fs->nvars++; | 294 | fs->nvars++; |
@@ -562,11 +561,11 @@ static void close_func (LexState *ls) { | |||
562 | TProtoFunc *f = fs->f; | 561 | TProtoFunc *f = fs->f; |
563 | code_opcode(ls, ENDCODE, 0); | 562 | code_opcode(ls, ENDCODE, 0); |
564 | f->code[0] = (Byte)fs->maxstacksize; | 563 | f->code[0] = (Byte)fs->maxstacksize; |
565 | f->code = luaM_reallocvector(f->code, fs->pc, Byte); | 564 | luaM_reallocvector(f->code, fs->pc, Byte); |
566 | f->consts = luaM_reallocvector(f->consts, f->nconsts, TObject); | 565 | luaM_reallocvector(f->consts, f->nconsts, TObject); |
567 | if (fs->nvars != -1) { /* debug information? */ | 566 | if (fs->nvars != -1) { /* debug information? */ |
568 | luaI_registerlocalvar(fs, NULL, -1); /* flag end of vector */ | 567 | luaI_registerlocalvar(fs, NULL, -1); /* flag end of vector */ |
569 | f->locvars = luaM_reallocvector(f->locvars, fs->nvars, LocVar); | 568 | luaM_reallocvector(f->locvars, fs->nvars, LocVar); |
570 | } | 569 | } |
571 | ls->fs = fs->prev; | 570 | ls->fs = fs->prev; |
572 | L->stack.top--; /* pop function */ | 571 | L->stack.top--; /* pop function */ |