'lua_[gs]etupvalue' may work even without debug information

(that is, without upvalue names)
This commit is contained in:
Roberto Ierusalimschy 2010-09-07 16:35:04 -03:00
parent 0df2238063
commit e3eabcf913
1 changed files with 6 additions and 2 deletions

8
lapi.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lapi.c,v 2.135 2010/09/03 14:14:01 roberto Exp roberto $ ** $Id: lapi.c,v 2.136 2010/09/07 19:21:39 roberto Exp roberto $
** Lua API ** Lua API
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -1107,11 +1107,15 @@ static const char *aux_upvalue (StkId fi, int n, TValue **val,
return ""; return "";
} }
else { else {
const char *name;
Proto *p = f->l.p; Proto *p = f->l.p;
if (!(1 <= n && n <= p->sizeupvalues)) return NULL; if (!(1 <= n && n <= p->sizeupvalues)) return NULL;
*val = f->l.upvals[n-1]->v; *val = f->l.upvals[n-1]->v;
if (owner) *owner = obj2gco(f->l.upvals[n - 1]); if (owner) *owner = obj2gco(f->l.upvals[n - 1]);
return getstr(p->upvalues[n-1].name); name = getstr(p->upvalues[n-1].name);
if (name == NULL) /* no debug information? */
name = "";
return name;
} }
} }