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

Function ll_require

ThirdParty/lua/lua/loadlib.c:557–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

555
556
557static int ll_require (lua_State *L) {
558 const char *name = luaL_checkstring(L, 1);
559 lua_settop(L, 1); /* _LOADED table will be at index 2 */
560 lua_getfield(L, LUA_REGISTRYINDEX, "_LOADED");
561 lua_getfield(L, 2, name); /* _LOADED[name] */
562 if (lua_toboolean(L, -1)) /* is it there? */
563 return 1; /* package is already loaded */
564 /* else must load package */
565 lua_pop(L, 1); /* remove 'getfield' result */
566 findloader(L, name);
567 lua_pushstring(L, name); /* pass name as argument to module loader */
568 lua_insert(L, -2); /* name is 1st argument (before search data) */
569 lua_call(L, 2, 1); /* run loader to load module */
570 if (!lua_isnil(L, -1)) /* non-nil return? */
571 lua_setfield(L, 2, name); /* _LOADED[name] = returned value */
572 if (lua_getfield(L, 2, name) == LUA_TNIL) { /* module set no value? */
573 lua_pushboolean(L, 1); /* use true as result */
574 lua_pushvalue(L, -1); /* extra copy to be returned */
575 lua_setfield(L, 2, name); /* _LOADED[name] = true */
576 }
577 return 1;
578}
579
580/* }====================================================== */
581

Callers

nothing calls this directly

Calls 8

lua_settopFunction · 0.85
lua_getfieldFunction · 0.85
lua_tobooleanFunction · 0.85
findloaderFunction · 0.85
lua_pushstringFunction · 0.85
lua_setfieldFunction · 0.85
lua_pushbooleanFunction · 0.85
lua_pushvalueFunction · 0.85

Tested by

no test coverage detected