mirror of https://github.com/rusefi/lua.git
registry._LOADED created "on demand" and baselib created as module _G
This commit is contained in:
parent
6dd0c6ccbc
commit
5fc92cce12
13
lbaselib.c
13
lbaselib.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: lbaselib.c,v 1.182 2005/08/26 17:36:32 roberto Exp roberto $
|
** $Id: lbaselib.c,v 1.183 2005/09/16 18:22:48 roberto Exp roberto $
|
||||||
** Basic library
|
** Basic library
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -602,8 +602,11 @@ static void auxopen (lua_State *L, const char *name,
|
||||||
|
|
||||||
|
|
||||||
static void base_open (lua_State *L) {
|
static void base_open (lua_State *L) {
|
||||||
|
/* set global _G */
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||||
luaL_register(L, NULL, base_funcs); /* open lib into global table */
|
lua_setglobal(L, "_G");
|
||||||
|
/* open lib into global table */
|
||||||
|
luaL_register(L, "_G", base_funcs);
|
||||||
lua_pushliteral(L, LUA_VERSION);
|
lua_pushliteral(L, LUA_VERSION);
|
||||||
lua_setglobal(L, "_VERSION"); /* set global _VERSION */
|
lua_setglobal(L, "_VERSION"); /* set global _VERSION */
|
||||||
/* `ipairs' and `pairs' need auxiliary functions as upvalues */
|
/* `ipairs' and `pairs' need auxiliary functions as upvalues */
|
||||||
|
@ -617,12 +620,6 @@ static void base_open (lua_State *L) {
|
||||||
lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */
|
lua_setfield(L, -2, "__mode"); /* metatable(w).__mode = "kv" */
|
||||||
lua_pushcclosure(L, luaB_newproxy, 1);
|
lua_pushcclosure(L, luaB_newproxy, 1);
|
||||||
lua_setglobal(L, "newproxy"); /* set global `newproxy' */
|
lua_setglobal(L, "newproxy"); /* set global `newproxy' */
|
||||||
/* create register._LOADED to track loaded modules */
|
|
||||||
lua_newtable(L);
|
|
||||||
lua_setfield(L, LUA_REGISTRYINDEX, "_LOADED");
|
|
||||||
/* set global _G */
|
|
||||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
|
||||||
lua_setglobal(L, "_G");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue