| 1186 | |
| 1187 | |
| 1188 | static const char *aux_upvalue (StkId fi, int n, TValue **val, |
| 1189 | GCObject **owner) { |
| 1190 | switch (ttype(fi)) { |
| 1191 | case LUA_TCCL: { /* C closure */ |
| 1192 | CClosure *f = clCvalue(fi); |
| 1193 | if (!(1 <= n && n <= f->nupvalues)) return NULL; |
| 1194 | *val = &f->upvalue[n-1]; |
| 1195 | if (owner) *owner = obj2gco(f); |
| 1196 | return ""; |
| 1197 | } |
| 1198 | case LUA_TLCL: { /* Lua closure */ |
| 1199 | LClosure *f = clLvalue(fi); |
| 1200 | TString *name; |
| 1201 | Proto *p = f->p; |
| 1202 | if (!(1 <= n && n <= p->sizeupvalues)) return NULL; |
| 1203 | *val = f->upvals[n-1]->v; |
| 1204 | if (owner) *owner = obj2gco(f->upvals[n - 1]); |
| 1205 | name = p->upvalues[n-1].name; |
| 1206 | return (name == NULL) ? "" : getstr(name); |
| 1207 | } |
| 1208 | default: return NULL; /* not a closure */ |
| 1209 | } |
| 1210 | } |
| 1211 | |
| 1212 | |
| 1213 | LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { |
no outgoing calls
no test coverage detected