mirror of https://github.com/rusefi/lua.git
parser/scanner keep GC running
This commit is contained in:
parent
b51d76ce8d
commit
35fa276099
3
ldo.c
3
ldo.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ldo.c,v 2.69 2009/10/11 20:02:19 roberto Exp roberto $
|
** $Id: ldo.c,v 2.70 2009/10/23 19:12:19 roberto Exp roberto $
|
||||||
** Stack and Call structure of Lua
|
** Stack and Call structure of Lua
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -573,7 +573,6 @@ static void f_parser (lua_State *L, void *ud) {
|
||||||
Closure *cl;
|
Closure *cl;
|
||||||
struct SParser *p = cast(struct SParser *, ud);
|
struct SParser *p = cast(struct SParser *, ud);
|
||||||
int c = luaZ_lookahead(p->z);
|
int c = luaZ_lookahead(p->z);
|
||||||
luaC_checkGC(L);
|
|
||||||
tf = (c == LUA_SIGNATURE[0])
|
tf = (c == LUA_SIGNATURE[0])
|
||||||
? luaU_undump(L, p->z, &p->buff, p->name)
|
? luaU_undump(L, p->z, &p->buff, p->name)
|
||||||
: luaY_parser(L, p->z, &p->buff, &p->varl, p->name);
|
: luaY_parser(L, p->z, &p->buff, &p->varl, p->name);
|
||||||
|
|
6
llex.c
6
llex.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: llex.c,v 2.32 2009/03/11 13:27:32 roberto Exp roberto $
|
** $Id: llex.c,v 2.33 2009/05/18 17:28:04 roberto Exp roberto $
|
||||||
** Lexical Analyzer
|
** Lexical Analyzer
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -123,8 +123,10 @@ TString *luaX_newstring (LexState *ls, const char *str, size_t l) {
|
||||||
TString *ts = luaS_newlstr(L, str, l);
|
TString *ts = luaS_newlstr(L, str, l);
|
||||||
setsvalue2s(L, L->top++, ts); /* anchor string */
|
setsvalue2s(L, L->top++, ts); /* anchor string */
|
||||||
o = luaH_setstr(L, ls->fs->h, ts);
|
o = luaH_setstr(L, ls->fs->h, ts);
|
||||||
if (ttisnil(o))
|
if (ttisnil(o)) {
|
||||||
setbvalue(o, 1); /* make sure `str' will not be collected */
|
setbvalue(o, 1); /* make sure `str' will not be collected */
|
||||||
|
luaC_checkGC(L);
|
||||||
|
}
|
||||||
L->top--;
|
L->top--;
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|
20
lparser.c
20
lparser.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lparser.c,v 2.70 2009/10/13 19:35:42 roberto Exp roberto $
|
** $Id: lparser.c,v 2.71 2009/10/14 16:43:11 roberto Exp roberto $
|
||||||
** Lua Parser
|
** Lua Parser
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -370,10 +370,6 @@ static void open_func (LexState *ls, FuncState *fs) {
|
||||||
fs->firstlocal = ls->varl->nactvar;
|
fs->firstlocal = ls->varl->nactvar;
|
||||||
fs->envreg = NO_REG;
|
fs->envreg = NO_REG;
|
||||||
fs->bl = NULL;
|
fs->bl = NULL;
|
||||||
fs->h = luaH_new(L);
|
|
||||||
/* anchor table of constants (to avoid being collected) */
|
|
||||||
sethvalue2s(L, L->top, fs->h);
|
|
||||||
incr_top(L);
|
|
||||||
f = luaF_newproto(L);
|
f = luaF_newproto(L);
|
||||||
fs->f = f;
|
fs->f = f;
|
||||||
f->source = ls->source;
|
f->source = ls->source;
|
||||||
|
@ -381,6 +377,10 @@ static void open_func (LexState *ls, FuncState *fs) {
|
||||||
/* anchor prototype (to avoid being collected) */
|
/* anchor prototype (to avoid being collected) */
|
||||||
setptvalue2s(L, L->top, f);
|
setptvalue2s(L, L->top, f);
|
||||||
incr_top(L);
|
incr_top(L);
|
||||||
|
fs->h = luaH_new(L);
|
||||||
|
/* anchor table of constants (to avoid being collected) */
|
||||||
|
sethvalue2s(L, L->top, fs->h);
|
||||||
|
incr_top(L);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -404,9 +404,11 @@ static void close_func (LexState *ls) {
|
||||||
f->sizeupvalues = fs->nups;
|
f->sizeupvalues = fs->nups;
|
||||||
lua_assert(fs->bl == NULL);
|
lua_assert(fs->bl == NULL);
|
||||||
ls->fs = fs->prev;
|
ls->fs = fs->prev;
|
||||||
L->top -= 2; /* remove table and prototype from the stack */
|
|
||||||
/* last token read was anchored in defunct function; must reanchor it */
|
/* last token read was anchored in defunct function; must reanchor it */
|
||||||
anchor_token(ls);
|
anchor_token(ls);
|
||||||
|
L->top--; /* pop table of constants */
|
||||||
|
luaC_checkGC(L);
|
||||||
|
L->top--; /* pop prototype (after possible collection) */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -415,18 +417,18 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, Varlist *varl,
|
||||||
struct LexState lexstate;
|
struct LexState lexstate;
|
||||||
struct FuncState funcstate;
|
struct FuncState funcstate;
|
||||||
TString *tname = luaS_new(L, name);
|
TString *tname = luaS_new(L, name);
|
||||||
setsvalue2s(L, L->top, tname); /* protect name */
|
setsvalue2s(L, L->top, tname); /* push name to protect it */
|
||||||
incr_top(L);
|
incr_top(L);
|
||||||
lexstate.buff = buff;
|
lexstate.buff = buff;
|
||||||
lexstate.varl = varl;
|
lexstate.varl = varl;
|
||||||
luaX_setinput(L, &lexstate, z, tname);
|
luaX_setinput(L, &lexstate, z, tname);
|
||||||
open_func(&lexstate, &funcstate);
|
open_func(&lexstate, &funcstate);
|
||||||
funcstate.f->is_vararg = 1; /* main func. is always vararg */
|
funcstate.f->is_vararg = 1; /* main function is always vararg */
|
||||||
luaX_next(&lexstate); /* read first token */
|
luaX_next(&lexstate); /* read first token */
|
||||||
chunk(&lexstate);
|
chunk(&lexstate);
|
||||||
check(&lexstate, TK_EOS);
|
check(&lexstate, TK_EOS);
|
||||||
close_func(&lexstate);
|
close_func(&lexstate);
|
||||||
L->top--;
|
L->top--; /* pop name */
|
||||||
lua_assert(funcstate.prev == NULL);
|
lua_assert(funcstate.prev == NULL);
|
||||||
lua_assert(funcstate.nups == 0);
|
lua_assert(funcstate.nups == 0);
|
||||||
lua_assert(lexstate.fs == NULL);
|
lua_assert(lexstate.fs == NULL);
|
||||||
|
|
Loading…
Reference in New Issue