MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / ll_module

Function ll_module

deps/lua/src/loadlib.c:544–569  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

542
543
544static int ll_module (lua_State *L) {
545 const char *modname = luaL_checkstring(L, 1);
546 int loaded = lua_gettop(L) + 1; /* index of _LOADED table */
547 lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
548 lua_getfield(L, loaded, modname); /* get _LOADED[modname] */
549 if (!lua_istable(L, -1)) { /* not found? */
550 lua_pop(L, 1); /* remove previous result */
551 /* try global variable (and create one if it does not exist) */
552 if (luaL_findtable(L, LUA_GLOBALSINDEX, modname, 1) != NULL)
553 return luaL_error(L, "name conflict for module " LUA_QS, modname);
554 lua_pushvalue(L, -1);
555 lua_setfield(L, loaded, modname); /* _LOADED[modname] = new table */
556 }
557 /* check whether table already has a _NAME field */
558 lua_getfield(L, -1, "_NAME");
559 if (!lua_isnil(L, -1)) /* is table an initialized module? */
560 lua_pop(L, 1);
561 else { /* no; initialize it */
562 lua_pop(L, 1);
563 modinit(L, modname);
564 }
565 lua_pushvalue(L, -1);
566 setfenv(L);
567 dooptions(L, loaded - 1);
568 return 0;
569}
570
571
572static int ll_seeall (lua_State *L) {

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected