| 1347 | |
| 1348 | |
| 1349 | static const char *aux_upvalue (TValue *fi, int n, TValue **val, |
| 1350 | GCObject **owner) { |
| 1351 | switch (ttypetag(fi)) { |
| 1352 | case LUA_VCCL: { /* C closure */ |
| 1353 | CClosure *f = clCvalue(fi); |
| 1354 | if (!(cast_uint(n) - 1u < cast_uint(f->nupvalues))) |
| 1355 | return NULL; /* 'n' not in [1, f->nupvalues] */ |
| 1356 | *val = &f->upvalue[n-1]; |
| 1357 | if (owner) *owner = obj2gco(f); |
| 1358 | return ""; |
| 1359 | } |
| 1360 | case LUA_VLCL: { /* Lua closure */ |
| 1361 | LClosure *f = clLvalue(fi); |
| 1362 | TString *name; |
| 1363 | Proto *p = f->p; |
| 1364 | if (!(cast_uint(n) - 1u < cast_uint(p->sizeupvalues))) |
| 1365 | return NULL; /* 'n' not in [1, p->sizeupvalues] */ |
| 1366 | *val = f->upvals[n-1]->v; |
| 1367 | if (owner) *owner = obj2gco(f->upvals[n - 1]); |
| 1368 | name = p->upvalues[n-1].name; |
| 1369 | return (name == NULL) ? "(no name)" : getstr(name); |
| 1370 | } |
| 1371 | default: return NULL; /* not a closure */ |
| 1372 | } |
| 1373 | } |
| 1374 | |
| 1375 | |
| 1376 | LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { |
no outgoing calls
no test coverage detected