name "_ENV" configurable through 'luaconf.h'

This commit is contained in:
Roberto Ierusalimschy
2010-09-07 16:21:39 -03:00
parent 6828f6d427
commit 0df2238063
7 changed files with 23 additions and 15 deletions

View File

@@ -1,5 +1,5 @@
/*
** $Id: lparser.c,v 2.90 2010/07/07 16:27:29 roberto Exp roberto $
** $Id: lparser.c,v 2.91 2010/08/23 17:32:34 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -289,7 +289,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, ls->envn, var, 1); /* get _ENV variable */
singlevaraux(fs, ls->envn, var, 1); /* get environment variable */
lua_assert(var->k == VLOCAL || var->k == VUPVAL);
codestring(ls, &key, varname); /* key is variable name */
luaK_indexed(fs, var, &key); /* env[varname] */
@@ -433,14 +433,14 @@ static void close_func (LexState *ls) {
/*
** opens the main function, which is a regular vararg function with an
** upvalue named '_ENV'
** upvalue named LUA_ENV
*/
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, ls->envn, &v); /* create '_ENV' upvalue */
newupvalue(fs, ls->envn, &v); /* create environment upvalue */
}