| 1365 | |
| 1366 | |
| 1367 | static const char *aux_upvalue (TValue *fi, int n, TValue **val, |
| 1368 | GCObject **owner) { |
| 1369 | switch (ttypetag(fi)) { |
| 1370 | case LUA_VCCL: { /* C closure */ |
| 1371 | CClosure *f = clCvalue(fi); |
| 1372 | if (!(cast_uint(n) - 1u < cast_uint(f->nupvalues))) |
| 1373 | return NULL; /* 'n' not in [1, f->nupvalues] */ |
| 1374 | *val = &f->upvalue[n-1]; |
| 1375 | if (owner) *owner = obj2gco(f); |
| 1376 | return ""; |
| 1377 | } |
| 1378 | case LUA_VLCL: { /* Lua closure */ |
| 1379 | LClosure *f = clLvalue(fi); |
| 1380 | TString *name; |
| 1381 | Proto *p = f->p; |
| 1382 | if (!(cast_uint(n) - 1u < cast_uint(p->sizeupvalues))) |
| 1383 | return NULL; /* 'n' not in [1, p->sizeupvalues] */ |
| 1384 | *val = f->upvals[n-1]->v.p; |
| 1385 | if (owner) *owner = obj2gco(f->upvals[n - 1]); |
| 1386 | name = p->upvalues[n-1].name; |
| 1387 | return (name == NULL) ? "(no name)" : getstr(name); |
| 1388 | } |
| 1389 | default: return NULL; /* not a closure */ |
| 1390 | } |
| 1391 | } |
| 1392 | |
| 1393 | |
| 1394 | LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) { |
no outgoing calls
no test coverage detected