MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / lua_load

Function lua_load

extlibs/lua/src/lapi.c:1046–1067  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1044
1045
1046LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
1047 const char *chunkname, const char *mode) {
1048 ZIO z;
1049 int status;
1050 lua_lock(L);
1051 if (!chunkname) chunkname = "?";
1052 luaZ_init(L, &z, reader, data);
1053 status = luaD_protectedparser(L, &z, chunkname, mode);
1054 if (status == LUA_OK) { /* no errors? */
1055 LClosure *f = clLvalue(s2v(L->top - 1)); /* get newly created function */
1056 if (f->nupvalues >= 1) { /* does it have an upvalue? */
1057 /* get global table from registry */
1058 Table *reg = hvalue(&G(L)->l_registry);
1059 const TValue *gt = luaH_getint(reg, LUA_RIDX_GLOBALS);
1060 /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
1061 setobj(L, f->upvals[0]->v, gt);
1062 luaC_barrier(L, f->upvals[0], gt);
1063 }
1064 }
1065 lua_unlock(L);
1066 return status;
1067}
1068
1069
1070LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip) {

Callers 4

luaB_loadFunction · 0.70
luaL_loadfilexFunction · 0.70
luaL_loadbufferxFunction · 0.70
combineFunction · 0.70

Calls 3

luaZ_initFunction · 0.85
luaD_protectedparserFunction · 0.85
luaH_getintFunction · 0.85

Tested by

no test coverage detected