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

Function findloader

third-party/lua-5.5.0/src/loadlib.c:618–647  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

616
617
618static void findloader (lua_State *L, const char *name) {
619 int i;
620 luaL_Buffer msg; /* to build error message */
621 /* push 'package.searchers' to index 3 in the stack */
622 if (l_unlikely(lua_getfield(L, lua_upvalueindex(1), "searchers")
623 != LUA_TTABLE))
624 luaL_error(L, "'package.searchers' must be a table");
625 luaL_buffinit(L, &msg);
626 luaL_addstring(&msg, "\n\t"); /* error-message prefix for first message */
627 /* iterate over available searchers to find a loader */
628 for (i = 1; ; i++) {
629 if (l_unlikely(lua_rawgeti(L, 3, i) == LUA_TNIL)) { /* no more searchers? */
630 lua_pop(L, 1); /* remove nil */
631 luaL_buffsub(&msg, 2); /* remove last prefix */
632 luaL_pushresult(&msg); /* create error message */
633 luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1));
634 }
635 lua_pushstring(L, name);
636 lua_call(L, 1, 2); /* call it */
637 if (lua_isfunction(L, -2)) /* did it find a loader? */
638 return; /* module loader found */
639 else if (lua_isstring(L, -2)) { /* searcher returned error message? */
640 lua_pop(L, 1); /* remove extra return */
641 luaL_addvalue(&msg); /* concatenate error message */
642 luaL_addstring(&msg, "\n\t"); /* prefix for next message */
643 }
644 else /* no error message */
645 lua_pop(L, 2); /* remove both returns */
646 }
647}
648
649
650static int ll_require (lua_State *L) {

Callers 1

ll_requireFunction · 0.70

Calls 11

lua_upvalueindexFunction · 0.85
lua_getfieldFunction · 0.70
luaL_errorFunction · 0.70
luaL_buffinitFunction · 0.70
luaL_addstringFunction · 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