MCPcopy Create free account
hub / github.com/bloomberg/comdb2 / ll_module

Function ll_module

lua/loadlib.c:549–574  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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