MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / findloader

Function findloader

third-party/lua-5.2.4/src/loadlib.c:478–505  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

476
477
478static void findloader (lua_State *L, const char *name) {
479 int i;
480 luaL_Buffer msg; /* to build error message */
481 luaL_buffinit(L, &msg);
482 lua_getfield(L, lua_upvalueindex(1), "searchers"); /* will be at index 3 */
483 if (!lua_istable(L, 3))
484 luaL_error(L, LUA_QL("package.searchers") " must be a table");
485 /* iterate over available searchers to find a loader */
486 for (i = 1; ; i++) {
487 lua_rawgeti(L, 3, i); /* get a searcher */
488 if (lua_isnil(L, -1)) { /* no more searchers? */
489 lua_pop(L, 1); /* remove nil */
490 luaL_pushresult(&msg); /* create error message */
491 luaL_error(L, "module " LUA_QS " not found:%s",
492 name, lua_tostring(L, -1));
493 }
494 lua_pushstring(L, name);
495 lua_call(L, 1, 2); /* call it */
496 if (lua_isfunction(L, -2)) /* did it find a loader? */
497 return; /* module loader found */
498 else if (lua_isstring(L, -2)) { /* searcher returned error message? */
499 lua_pop(L, 1); /* remove extra return */
500 luaL_addvalue(&msg); /* concatenate error message */
501 }
502 else
503 lua_pop(L, 2); /* remove both returns */
504 }
505}
506
507
508static int ll_require (lua_State *L) {

Callers 1

ll_requireFunction · 0.70

Calls 10

lua_upvalueindexFunction · 0.85
luaL_buffinitFunction · 0.70
lua_getfieldFunction · 0.70
luaL_errorFunction · 0.70
lua_rawgetiFunction · 0.70
luaL_pushresultFunction · 0.70
lua_pushstringFunction · 0.70
lua_isstringFunction · 0.70
luaL_addvalueFunction · 0.70
lua_callFunction · 0.50

Tested by

no test coverage detected