diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-03-13 12:55:42 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2010-03-13 12:55:42 -0300 |
commit | 22ef84b6c8d980eb869f414610f8ff5f25568ca7 (patch) | |
tree | 150de147a765e98015bfd4e8cd67f8bf3f157ef3 /lparser.c | |
parent | 63a2b62468d2aabb1086a8c88d32ff96c658c96b (diff) | |
download | lua-22ef84b6c8d980eb869f414610f8ff5f25568ca7.tar.gz lua-22ef84b6c8d980eb869f414610f8ff5f25568ca7.tar.bz2 lua-22ef84b6c8d980eb869f414610f8ff5f25568ca7.zip |
'_ENV' name permanently stored in global state for easier access
Diffstat (limited to 'lparser.c')
-rw-r--r-- | lparser.c | 9 |
1 files changed, 3 insertions, 6 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.78 2010/03/08 16:55:52 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.79 2010/03/12 19:14:06 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 | */ |
@@ -288,7 +288,7 @@ static void singlevar (LexState *ls, expdesc *var) { | |||
288 | FuncState *fs = ls->fs; | 288 | FuncState *fs = ls->fs; |
289 | if (singlevaraux(fs, varname, var, 1) == VVOID) { /* global name? */ | 289 | if (singlevaraux(fs, varname, var, 1) == VVOID) { /* global name? */ |
290 | expdesc key; | 290 | expdesc key; |
291 | singlevaraux(fs, ls->envn, var, 1); /* get _ENV variable */ | 291 | singlevaraux(fs, G(ls->L)->envn, var, 1); /* get _ENV variable */ |
292 | lua_assert(var->k == VLOCAL || var->k == VUPVAL); | 292 | lua_assert(var->k == VLOCAL || var->k == VUPVAL); |
293 | codestring(ls, &key, varname); /* key is variable name */ | 293 | codestring(ls, &key, varname); /* key is variable name */ |
294 | luaK_indexed(fs, var, &key); /* env[varname] */ | 294 | luaK_indexed(fs, var, &key); /* env[varname] */ |
@@ -433,11 +433,8 @@ static void open_mainfunc (lua_State *L, LexState *ls, FuncState *fs) { | |||
433 | expdesc v; | 433 | expdesc v; |
434 | open_func(ls, fs); | 434 | open_func(ls, fs); |
435 | fs->f->is_vararg = 1; /* main function is always vararg */ | 435 | fs->f->is_vararg = 1; /* main function is always vararg */ |
436 | ls->envn = luaS_new(L, "_ENV"); /* create '_ENV' string */ | ||
437 | setsvalue2s(L, L->top++, ls->envn); /* anchor it */ | ||
438 | init_exp(&v, VLOCAL, 0); | 436 | init_exp(&v, VLOCAL, 0); |
439 | newupvalue(fs, ls->envn, &v); /* create '_ENV' upvalue */ | 437 | newupvalue(fs, G(L)->envn, &v); /* create '_ENV' upvalue */ |
440 | L->top--; /* now string is anchored as an upvalue name */ | ||
441 | } | 438 | } |
442 | 439 | ||
443 | 440 | ||