| 1234 | |
| 1235 | |
| 1236 | LUA_API const char *lua_setupvalue (lua_State *L, int funcindex, int n) { |
| 1237 | const char *name; |
| 1238 | TValue *val = NULL; /* to avoid warnings */ |
| 1239 | CClosure *owner = NULL; |
| 1240 | UpVal *uv = NULL; |
| 1241 | StkId fi; |
| 1242 | lua_lock(L); |
| 1243 | fi = index2addr(L, funcindex); |
| 1244 | api_checknelems(L, 1); |
| 1245 | name = aux_upvalue(fi, n, &val, &owner, &uv); |
| 1246 | if (name) { |
| 1247 | L->top--; |
| 1248 | setobj(L, val, L->top); |
| 1249 | if (owner) { luaC_barrier(L, owner, L->top); } |
| 1250 | else if (uv) { luaC_upvalbarrier(L, uv); } |
| 1251 | } |
| 1252 | lua_unlock(L); |
| 1253 | return name; |
| 1254 | } |
| 1255 | |
| 1256 | |
| 1257 | static UpVal **getupvalref (lua_State *L, int fidx, int n) { |
no test coverage detected