MCPcopy Create free account
hub / github.com/F-Stack/f-stack / lua_load

Function lua_load

freebsd/contrib/openzfs/module/lua/lapi.c:970–991  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

968
969
970LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
971 const char *chunkname, const char *mode) {
972 ZIO z;
973 int status;
974 lua_lock(L);
975 if (!chunkname) chunkname = "?";
976 luaZ_init(L, &z, reader, data);
977 status = luaD_protectedparser(L, &z, chunkname, mode);
978 if (status == LUA_OK) { /* no errors? */
979 LClosure *f = clLvalue(L->top - 1); /* get newly created function */
980 if (f->nupvalues == 1) { /* does it have one upvalue? */
981 /* get global table from registry */
982 Table *reg = hvalue(&G(L)->l_registry);
983 const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
984 /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
985 setobj(L, f->upvals[0]->v, gt);
986 luaC_barrier(L, f->upvals[0], gt);
987 }
988 }
989 lua_unlock(L);
990 return status;
991}
992
993#if defined(LUA_USE_DUMP)
994LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data) {

Callers 1

luaL_loadbufferxFunction · 0.70

Calls 3

luaH_getintFunction · 0.85
luaZ_initFunction · 0.70
luaD_protectedparserFunction · 0.70

Tested by

no test coverage detected