| 1085 | |
| 1086 | |
| 1087 | LUA_API int lua_load (lua_State *L, lua_Reader reader, void *data, |
| 1088 | const char *chunkname, const char *mode) { |
| 1089 | ZIO z; |
| 1090 | int status; |
| 1091 | lua_lock(L); |
| 1092 | if (!chunkname) chunkname = "?"; |
| 1093 | luaZ_init(L, &z, reader, data); |
| 1094 | status = luaD_protectedparser(L, &z, chunkname, mode); |
| 1095 | if (status == LUA_OK) { /* no errors? */ |
| 1096 | LClosure *f = clLvalue(s2v(L->top.p - 1)); /* get new function */ |
| 1097 | if (f->nupvalues >= 1) { /* does it have an upvalue? */ |
| 1098 | /* get global table from registry */ |
| 1099 | const TValue *gt = getGtable(L); |
| 1100 | /* set global table as 1st upvalue of 'f' (may be LUA_ENV) */ |
| 1101 | setobj(L, f->upvals[0]->v.p, gt); |
| 1102 | luaC_barrier(L, f->upvals[0], gt); |
| 1103 | } |
| 1104 | } |
| 1105 | lua_unlock(L); |
| 1106 | return status; |
| 1107 | } |
| 1108 | |
| 1109 | |
| 1110 | LUA_API int lua_dump (lua_State *L, lua_Writer writer, void *data, int strip) { |
no test coverage detected