MCPcopy Create free account
hub / github.com/Achain-Dev/Achain / findloader

Function findloader

src/Chain/libraries/glua/loadlib.cpp:587–612  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

585
586
587static void findloader(lua_State *L, const char *name) {
588 int i;
589 luaL_Buffer msg; /* to build error message */
590 luaL_buffinit(L, &msg);
591 /* push 'package.searchers' to index 3 in the stack */
592 if (lua_getfield(L, lua_upvalueindex(1), "searchers") != LUA_TTABLE)
593 luaL_error(L, "'package.searchers' must be a table");
594 /* iterate over available searchers to find a loader */
595 for (i = 1;; i++) {
596 if (lua_rawgeti(L, 3, i) == LUA_TNIL) { /* no more searchers? */
597 lua_pop(L, 1); /* remove nil */
598 luaL_pushresult(&msg); /* create error message */
599 luaL_error(L, "module '%s' not found:%s", name, lua_tostring(L, -1));
600 }
601 lua_pushstring(L, name);
602 lua_call(L, 1, 2); /* call it */
603 if (lua_isfunction(L, -2)) /* did it find a loader? */
604 return; /* module loader found */
605 else if (lua_isstring(L, -2)) { /* searcher returned error message? */
606 lua_pop(L, 1); /* remove extra return */
607 luaL_addvalue(&msg); /* concatenate error message */
608 }
609 else
610 lua_pop(L, 2); /* remove both returns */
611 }
612}
613
614static void findloader_for_import_contract(lua_State *L, const char *name)
615{

Callers

nothing calls this directly

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