aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ldo.c3
-rw-r--r--llex.c6
-rw-r--r--lparser.c20
3 files changed, 16 insertions, 13 deletions
diff --git a/ldo.c b/ldo.c
index 1af502ff..9193cb0e 100644
--- a/ldo.c
+++ b/ldo.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: ldo.c,v 2.69 2009/10/11 20:02:19 roberto Exp roberto $ 2** $Id: ldo.c,v 2.70 2009/10/23 19:12:19 roberto Exp roberto $
3** Stack and Call structure of Lua 3** Stack and Call structure of Lua
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -573,7 +573,6 @@ static void f_parser (lua_State *L, void *ud) {
573 Closure *cl; 573 Closure *cl;
574 struct SParser *p = cast(struct SParser *, ud); 574 struct SParser *p = cast(struct SParser *, ud);
575 int c = luaZ_lookahead(p->z); 575 int c = luaZ_lookahead(p->z);
576 luaC_checkGC(L);
577 tf = (c == LUA_SIGNATURE[0]) 576 tf = (c == LUA_SIGNATURE[0])
578 ? luaU_undump(L, p->z, &p->buff, p->name) 577 ? luaU_undump(L, p->z, &p->buff, p->name)
579 : luaY_parser(L, p->z, &p->buff, &p->varl, p->name); 578 : luaY_parser(L, p->z, &p->buff, &p->varl, p->name);
diff --git a/llex.c b/llex.c
index 4d1146ce..1f09f265 100644
--- a/llex.c
+++ b/llex.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: llex.c,v 2.32 2009/03/11 13:27:32 roberto Exp roberto $ 2** $Id: llex.c,v 2.33 2009/05/18 17:28:04 roberto Exp roberto $
3** Lexical Analyzer 3** Lexical Analyzer
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -123,8 +123,10 @@ TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
123 TString *ts = luaS_newlstr(L, str, l); 123 TString *ts = luaS_newlstr(L, str, l);
124 setsvalue2s(L, L->top++, ts); /* anchor string */ 124 setsvalue2s(L, L->top++, ts); /* anchor string */
125 o = luaH_setstr(L, ls->fs->h, ts); 125 o = luaH_setstr(L, ls->fs->h, ts);
126 if (ttisnil(o)) 126 if (ttisnil(o)) {
127 setbvalue(o, 1); /* make sure `str' will not be collected */ 127 setbvalue(o, 1); /* make sure `str' will not be collected */
128 luaC_checkGC(L);
129 }
128 L->top--; 130 L->top--;
129 return ts; 131 return ts;
130} 132}
diff --git a/lparser.c b/lparser.c
index 96aecfb8..6aa2b20c 100644
--- a/lparser.c
+++ b/lparser.c
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lparser.c,v 2.70 2009/10/13 19:35:42 roberto Exp roberto $ 2** $Id: lparser.c,v 2.71 2009/10/14 16:43:11 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*/
@@ -370,10 +370,6 @@ static void open_func (LexState *ls, FuncState *fs) {
370 fs->firstlocal = ls->varl->nactvar; 370 fs->firstlocal = ls->varl->nactvar;
371 fs->envreg = NO_REG; 371 fs->envreg = NO_REG;
372 fs->bl = NULL; 372 fs->bl = NULL;
373 fs->h = luaH_new(L);
374 /* anchor table of constants (to avoid being collected) */
375 sethvalue2s(L, L->top, fs->h);
376 incr_top(L);
377 f = luaF_newproto(L); 373 f = luaF_newproto(L);
378 fs->f = f; 374 fs->f = f;
379 f->source = ls->source; 375 f->source = ls->source;
@@ -381,6 +377,10 @@ static void open_func (LexState *ls, FuncState *fs) {
381 /* anchor prototype (to avoid being collected) */ 377 /* anchor prototype (to avoid being collected) */
382 setptvalue2s(L, L->top, f); 378 setptvalue2s(L, L->top, f);
383 incr_top(L); 379 incr_top(L);
380 fs->h = luaH_new(L);
381 /* anchor table of constants (to avoid being collected) */
382 sethvalue2s(L, L->top, fs->h);
383 incr_top(L);
384} 384}
385 385
386 386
@@ -404,9 +404,11 @@ static void close_func (LexState *ls) {
404 f->sizeupvalues = fs->nups; 404 f->sizeupvalues = fs->nups;
405 lua_assert(fs->bl == NULL); 405 lua_assert(fs->bl == NULL);
406 ls->fs = fs->prev; 406 ls->fs = fs->prev;
407 L->top -= 2; /* remove table and prototype from the stack */
408 /* last token read was anchored in defunct function; must reanchor it */ 407 /* last token read was anchored in defunct function; must reanchor it */
409 anchor_token(ls); 408 anchor_token(ls);
409 L->top--; /* pop table of constants */
410 luaC_checkGC(L);
411 L->top--; /* pop prototype (after possible collection) */
410} 412}
411 413
412 414
@@ -415,18 +417,18 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, Varlist *varl,
415 struct LexState lexstate; 417 struct LexState lexstate;
416 struct FuncState funcstate; 418 struct FuncState funcstate;
417 TString *tname = luaS_new(L, name); 419 TString *tname = luaS_new(L, name);
418 setsvalue2s(L, L->top, tname); /* protect name */ 420 setsvalue2s(L, L->top, tname); /* push name to protect it */
419 incr_top(L); 421 incr_top(L);
420 lexstate.buff = buff; 422 lexstate.buff = buff;
421 lexstate.varl = varl; 423 lexstate.varl = varl;
422 luaX_setinput(L, &lexstate, z, tname); 424 luaX_setinput(L, &lexstate, z, tname);
423 open_func(&lexstate, &funcstate); 425 open_func(&lexstate, &funcstate);
424 funcstate.f->is_vararg = 1; /* main func. is always vararg */ 426 funcstate.f->is_vararg = 1; /* main function is always vararg */
425 luaX_next(&lexstate); /* read first token */ 427 luaX_next(&lexstate); /* read first token */
426 chunk(&lexstate); 428 chunk(&lexstate);
427 check(&lexstate, TK_EOS); 429 check(&lexstate, TK_EOS);
428 close_func(&lexstate); 430 close_func(&lexstate);
429 L->top--; 431 L->top--; /* pop name */
430 lua_assert(funcstate.prev == NULL); 432 lua_assert(funcstate.prev == NULL);
431 lua_assert(funcstate.nups == 0); 433 lua_assert(funcstate.nups == 0);
432 lua_assert(lexstate.fs == NULL); 434 lua_assert(lexstate.fs == NULL);