MCPcopy Create free account
hub / github.com/BigPig0/RelayLive / findloader

Function findloader

ThirdParty/lua/lua/loadlib.c:529–554  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

527
528
529static void findloader (lua_State *L, const char *name) {
530 int i;
531 luaL_Buffer msg; /* to build error message */
532 luaL_buffinit(L, &msg);
533 /* push 'package.searchers' to index 3 in the stack */
534 if (lua_getfield(L, lua_upvalueindex(1), "searchers") != LUA_TTABLE)
535 luaL_error(L, "'package.searchers' must be a table");
536 /* iterate over available searchers to find a loader */
537 for (i = 1; ; i++) {
538 if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */
539 lua_pop(L, 1); /* remove nil */
540 luaL_pushresult(&msg); /* create error message */
541 luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1));
542 }
543 lua_pushstring(L, name);
544 lua_call(L, 1, 2); /* call it */
545 if (lua_isfunction(L, -2)) /* did it find a loader? */
546 return; /* module loader found */
547 else if (lua_isstring(L, -2)) { /* searcher returned error message? */
548 lua_pop(L, 1); /* remove extra return */
549 luaL_addvalue(&msg); /* concatenate error message */
550 }
551 else
552 lua_pop(L, 2); /* remove both returns */
553 }
554}
555
556
557static int ll_require (lua_State *L) {

Callers 1

ll_requireFunction · 0.85

Calls 8

luaL_buffinitFunction · 0.85
lua_getfieldFunction · 0.85
luaL_errorFunction · 0.85
lua_rawgetiFunction · 0.85
luaL_pushresultFunction · 0.85
lua_pushstringFunction · 0.85
lua_isstringFunction · 0.85
luaL_addvalueFunction · 0.85

Tested by

no test coverage detected