diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-08-27 12:16:28 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-08-27 12:16:28 -0300 |
commit | c3d72096c4841ebc04a0615917d71f22aaa5e5ff (patch) | |
tree | 45b143ed4284ba9b30fdae965aef0a047aab6deb /lparser.c | |
parent | 7afc74ff07907294a2162600023a9c61a64cdbd5 (diff) | |
download | lua-c3d72096c4841ebc04a0615917d71f22aaa5e5ff.tar.gz lua-c3d72096c4841ebc04a0615917d71f22aaa5e5ff.tar.bz2 lua-c3d72096c4841ebc04a0615917d71f22aaa5e5ff.zip |
use a table to find (and reuse) constants when parsing
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 6 |
1 files changed, 5 insertions, 1 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 1.152 2001/07/10 20:02:22 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 1.153 2001/08/10 20:53:03 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 | */ |
@@ -318,6 +318,7 @@ static void open_func (LexState *ls, FuncState *fs) { | |||
318 | fs->jlt = NO_JUMP; | 318 | fs->jlt = NO_JUMP; |
319 | fs->freereg = 0; | 319 | fs->freereg = 0; |
320 | fs->nk = 0; | 320 | fs->nk = 0; |
321 | fs->h = luaH_new(ls->L, 0); | ||
321 | fs->np = 0; | 322 | fs->np = 0; |
322 | fs->nlineinfo = 0; | 323 | fs->nlineinfo = 0; |
323 | fs->nlocvars = 0; | 324 | fs->nlocvars = 0; |
@@ -339,6 +340,9 @@ static void close_func (LexState *ls) { | |||
339 | luaK_codeABC(fs, OP_RETURN, 0, 0, 0); /* final return */ | 340 | luaK_codeABC(fs, OP_RETURN, 0, 0, 0); /* final return */ |
340 | luaK_getlabel(fs); /* close eventual list of pending jumps */ | 341 | luaK_getlabel(fs); /* close eventual list of pending jumps */ |
341 | removelocalvars(ls, fs->nactloc); | 342 | removelocalvars(ls, fs->nactloc); |
343 | lua_assert(G(L)->roottable == fs->h); | ||
344 | G(L)->roottable = fs->h->next; | ||
345 | luaH_free(L, fs->h); | ||
342 | luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); | 346 | luaM_reallocvector(L, f->code, f->sizecode, fs->pc, Instruction); |
343 | f->sizecode = fs->pc; | 347 | f->sizecode = fs->pc; |
344 | luaM_reallocvector(L, f->k, f->sizek, fs->nk, TObject); | 348 | luaM_reallocvector(L, f->k, f->sizek, fs->nk, TObject); |