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