| 1310 | |
| 1311 | |
| 1312 | static const char *aux_upvalue (TValue *fi, int n, TValue **val, |
| 1313 | GCObject **owner) { |
| 1314 | switch (ttypetag(fi)) { |
| 1315 | case LUA_VCCL: { /* C closure */ |
| 1316 | CClosure *f = clCvalue(fi); |
| 1317 | if (!(cast_uint(n) - 1u < cast_uint(f->nupvalues))) |
| 1318 | return NULL; /* 'n' not in [1, f->nupvalues] */ |
| 1319 | *val = &f->upvalue[n-1]; |
| 1320 | if (owner) *owner = obj2gco(f); |
| 1321 | return ""; |
| 1322 | } |
| 1323 | case LUA_VLCL: { /* Lua closure */ |
| 1324 | LClosure *f = clLvalue(fi); |
| 1325 | TString *name; |
| 1326 | Proto *p = f->p; |
| 1327 | if (!(cast_uint(n) - 1u < cast_uint(p->sizeupvalues))) |
| 1328 | return NULL; /* 'n' not in [1, p->sizeupvalues] */ |
| 1329 | *val = f->upvals[n-1]->v; |
| 1330 | if (owner) *owner = obj2gco(f->upvals[n - 1]); |
| 1331 | name = p->upvalues[n-1].name; |
| 1332 | return (name == NULL) ? "(no name)" : getstr(name); |
| 1333 | } |
| 1334 | default: return NULL; /* not a closure */ |
| 1335 | } |
| 1336 | } |
| 1337 | |
| 1338 | |
| 1339 | LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { |
no outgoing calls
no test coverage detected