MCPcopy Create free account
hub / github.com/EmmyLua/EmmyLuaDebugger / lua_load

Function lua_load

third-party/lua-5.5.0/src/lapi.c:1120–1141  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1118
1119
1120LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data,
1121 const char *chunkname, const char *mode) {
1122 ZIO z;
1123 TStatus status;
1124 lua_lock(L);
1125 if (!chunkname) chunkname = "?";
1126 luaZ_init(L, &z, reader, data);
1127 status = luaD_protectedparser(L, &z, chunkname, mode);
1128 if (status == LUA_OK) { /* no errors? */
1129 LClosure *f = clLvalue(s2v(L->top.p - 1)); /* get new function */
1130 if (f->nupvalues >= 1) { /* does it have an upvalue? */
1131 /* get global table from registry */
1132 TValue gt;
1133 getGlobalTable(L, &gt);
1134 /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */
1135 setobj(L, f->upvals[0]->v.p, &gt);
1136 luaC_barrier(L, f->upvals[0], &gt);
1137 }
1138 }
1139 lua_unlock(L);
1140 return APIstatus(status);
1141}
1142
1143
1144/*

Callers 4

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

Calls 3

getGlobalTableFunction · 0.85
luaZ_initFunction · 0.70
luaD_protectedparserFunction · 0.70

Tested by

no test coverage detected