MCPcopy Create free account
hub / github.com/DFHack/dfhack / aux_upvalue

Function aux_upvalue

depends/lua/src/lapi.c:1197–1219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1195
1196
1197static const char *aux_upvalue (StkId fi, int n, TValue **val,
1198 CClosure **owner, UpVal **uv) {
1199 switch (ttype(fi)) {
1200 case LUA_TCCL: { /* C closure */
1201 CClosure *f = clCvalue(fi);
1202 if (!(1 <= n && n <= f->nupvalues)) return NULL;
1203 *val = &f->upvalue[n-1];
1204 if (owner) *owner = f;
1205 return "";
1206 }
1207 case LUA_TLCL: { /* Lua closure */
1208 LClosure *f = clLvalue(fi);
1209 TString *name;
1210 Proto *p = f->p;
1211 if (!(1 <= n && n <= p->sizeupvalues)) return NULL;
1212 *val = f->upvals[n-1]->v;
1213 if (uv) *uv = f->upvals[n - 1];
1214 name = p->upvalues[n-1].name;
1215 return (name == NULL) ? "(*no name)" : getstr(name);
1216 }
1217 default: return NULL; /* not a closure */
1218 }
1219}
1220
1221
1222LUA_API const char *lua_getupvalue (lua_State *L, int funcindex, int n) {

Callers 2

lua_getupvalueFunction · 0.85
lua_setupvalueFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected