diff --git a/llex.c b/llex.c index 9fe16c1c..69bc8bc9 100644 --- a/llex.c +++ b/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.34 2009/11/17 16:33:38 roberto Exp roberto $ +** $Id: llex.c,v 2.35 2010/02/27 21:16:24 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -152,6 +152,8 @@ void luaX_setinput (lua_State *L, LexState *ls, ZIO *z, TString *source) { ls->linenumber = 1; ls->lastline = 1; ls->source = source; + ls->envn = luaS_new(L, "_ENV"); + luaS_fix(ls->envn); /* never collect this name */ luaZ_resizebuffer(ls->L, ls->buff, LUA_MINBUFFER); /* initialize buffer */ next(ls); /* read first char */ } diff --git a/llex.h b/llex.h index 276802e0..33aa714a 100644 --- a/llex.h +++ b/llex.h @@ -1,5 +1,5 @@ /* -** $Id: llex.h,v 1.63 2010/03/08 16:55:52 roberto Exp roberto $ +** $Id: llex.h,v 1.64 2010/03/13 15:55:42 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -60,6 +60,7 @@ typedef struct LexState { Mbuffer *buff; /* buffer for tokens */ struct Varlist *varl; /* list of all active local variables */ TString *source; /* current source name */ + TString *envn; /* environment variable name */ char decpoint; /* locale decimal point */ } LexState; diff --git a/lparser.c b/lparser.c index ced9c6c0..62c88fdb 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.80 2010/03/13 15:55:42 roberto Exp roberto $ +** $Id: lparser.c,v 2.81 2010/04/05 16:26:37 roberto Exp roberto $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -288,7 +288,7 @@ static void singlevar (LexState *ls, expdesc *var) { FuncState *fs = ls->fs; if (singlevaraux(fs, varname, var, 1) == VVOID) { /* global name? */ expdesc key; - singlevaraux(fs, G(ls->L)->envn, var, 1); /* get _ENV variable */ + singlevaraux(fs, ls->envn, var, 1); /* get _ENV variable */ lua_assert(var->k == VLOCAL || var->k == VUPVAL); codestring(ls, &key, varname); /* key is variable name */ luaK_indexed(fs, var, &key); /* env[varname] */ @@ -429,12 +429,12 @@ static void close_func (LexState *ls) { ** opens the main function, which is a regular vararg function with an ** upvalue named '_ENV' */ -static void open_mainfunc (lua_State *L, LexState *ls, FuncState *fs) { +static void open_mainfunc (LexState *ls, FuncState *fs) { expdesc v; open_func(ls, fs); fs->f->is_vararg = 1; /* main function is always vararg */ init_exp(&v, VLOCAL, 0); - newupvalue(fs, G(L)->envn, &v); /* create '_ENV' upvalue */ + newupvalue(fs, ls->envn, &v); /* create '_ENV' upvalue */ } @@ -448,7 +448,7 @@ Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, Varlist *varl, lexstate.buff = buff; lexstate.varl = varl; luaX_setinput(L, &lexstate, z, tname); - open_mainfunc(L, &lexstate, &funcstate); + open_mainfunc(&lexstate, &funcstate); luaX_next(&lexstate); /* read first token */ chunk(&lexstate); /* read main chunk */ check(&lexstate, TK_EOS); diff --git a/lstate.c b/lstate.c index aad526c2..51272622 100644 --- a/lstate.c +++ b/lstate.c @@ -1,5 +1,5 @@ /* -** $Id: lstate.c,v 2.75 2010/03/26 20:58:11 roberto Exp roberto $ +** $Id: lstate.c,v 2.76 2010/03/29 17:43:14 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -157,8 +157,6 @@ static void f_luaopen (lua_State *L, void *ud) { luaS_resize(L, MINSTRTABSIZE); /* initial size of string table */ luaT_init(L); luaX_init(L); - g->envn = luaS_new(L, "_ENV"); - luaS_fix(g->envn); /* never collect this name */ luaS_fix(luaS_newliteral(L, MEMERRMSG)); g->GCthreshold = 4*g->totalbytes; } diff --git a/lstate.h b/lstate.h index caaa70ec..1c70aca8 100644 --- a/lstate.h +++ b/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 2.58 2010/03/26 20:58:11 roberto Exp roberto $ +** $Id: lstate.h,v 2.59 2010/03/29 17:43:14 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -142,7 +142,6 @@ typedef struct global_State { lua_CFunction panic; /* to be called in unprotected errors */ struct lua_State *mainthread; const lua_Number *version; /* pointer to version number */ - TString *envn; /* environment variable name */ TString *tmname[TM_N]; /* array with tag-method names */ struct Table *mt[NUM_TAGS]; /* metatables for basic types */ } global_State;