MCPcopy Create free account
hub / github.com/DFHack/dfhack / lua_load

Function lua_load

depends/lua/src/lapi.c:992–1013  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

990
991
992LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
993 const char *chunkname, const char *mode) {
994 ZIO z;
995 int status;
996 lua_lock(L);
997 if (!chunkname) chunkname = "?";
998 luaZ_init(L, &z, reader, data);
999 status = luaD_protectedparser(L, &z, chunkname, mode);
1000 if (status == LUA_OK) { /* no errors? */
1001 LClosure *f = clLvalue(L->top - 1); /* get newly created function */
1002 if (f->nupvalues >= 1) { /* does it have an upvalue? */
1003 /* get global table from registry */
1004 Table *reg = hvalue(&G(L)->l_registry);
1005 const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
1006 /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
1007 setobj(L, f->upvals[0]->v, gt);
1008 luaC_upvalbarrier(L, f->upvals[0]);
1009 }
1010 }
1011 lua_unlock(L);
1012 return status;
1013}
1014
1015
1016LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip) {

Callers 4

luaB_loadFunction · 0.85
luaL_loadfilexFunction · 0.85
luaL_loadbufferxFunction · 0.85
combineFunction · 0.85

Calls 3

luaZ_initFunction · 0.85
luaD_protectedparserFunction · 0.85
luaH_getintFunction · 0.85

Tested by

no test coverage detected