MCPcopy Create free account
hub / github.com/BZFlag-Dev/bzflag / ll_module

Function ll_module

other_src/lua/src/loadlib.cpp:559–584  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

557
558
559static int ll_module (lua_State *L) {
560 const char *modname = luaL_checkstring(L, 1);
561 int loaded = lua_gettop(L) + 1; /* index of _LOADED table */
562 lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
563 lua_getfield(L, loaded, modname); /* get _LOADED[modname] */
564 if (!lua_istable(L, -1)) { /* not found? */
565 lua_pop(L, 1); /* remove previous result */
566 /* try global variable (and create one if it does not exist) */
567 if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL)
568 return luaL_error(L, "name conflict for module " LUA_QS, modname);
569 lua_pushvalue(L, -1);
570 lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */
571 }
572 /* check whether table already has a _NAME field */
573 lua_getfield(L, -1, "_NAME");
574 if (!lua_isnil(L, -1)) /* is table an initialized module? */
575 lua_pop(L, 1);
576 else { /* no; initialize it */
577 lua_pop(L, 1);
578 modinit(L, modname);
579 }
580 lua_pushvalue(L, -1);
581 setfenv(L);
582 dooptions(L, loaded - 1);
583 return 0;
584}
585
586
587static int ll_seeall (lua_State *L) {

Callers

nothing calls this directly

Calls 9

lua_gettopFunction · 0.70
lua_getfieldFunction · 0.70
luaL_findtableFunction · 0.70
luaL_errorFunction · 0.70
lua_pushvalueFunction · 0.70
lua_setfieldFunction · 0.70
modinitFunction · 0.70
setfenvFunction · 0.70
dooptionsFunction · 0.70

Tested by

no test coverage detected