diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-05-12 16:49:18 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-05-12 16:49:18 -0300 |
commit | 8714cc02d6367039d3d76279f024d30326371277 (patch) | |
tree | ea60817bdf1507fe44678f2363ed15e35194119e /ldebug.c | |
parent | 69b45bb4e9b08469e9fe2148d0aebf49ec54c6d2 (diff) | |
download | lua-8714cc02d6367039d3d76279f024d30326371277.tar.gz lua-8714cc02d6367039d3d76279f024d30326371277.tar.bz2 lua-8714cc02d6367039d3d76279f024d30326371277.zip |
`getinfo' gets information about non-active functions, too.
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 18 |
1 files changed, 11 insertions, 7 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.17 2000/05/08 19:32:53 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.18 2000/05/08 20:49:05 roberto Exp roberto $ |
3 | ** Debug Interface | 3 | ** Debug Interface |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -132,8 +132,7 @@ int lua_setlocal (lua_State *L, const lua_Debug *ar, lua_Localvar *v) { | |||
132 | } | 132 | } |
133 | 133 | ||
134 | 134 | ||
135 | static void lua_funcinfo (lua_Debug *ar) { | 135 | static void lua_funcinfo (lua_Debug *ar, StkId func) { |
136 | StkId func = ar->_func; | ||
137 | switch (ttype(func)) { | 136 | switch (ttype(func)) { |
138 | case TAG_LCLOSURE: case TAG_LMARK: | 137 | case TAG_LCLOSURE: case TAG_LMARK: |
139 | ar->source = clvalue(func)->f.l->source->str; | 138 | ar->source = clvalue(func)->f.l->source->str; |
@@ -164,7 +163,7 @@ static void lua_getobjname (lua_State *L, StkId f, lua_Debug *ar) { | |||
164 | /* try to find a name for given function */ | 163 | /* try to find a name for given function */ |
165 | setnormalized(L->top, f); /* to be used by `checkfunc' */ | 164 | setnormalized(L->top, f); /* to be used by `checkfunc' */ |
166 | for (i=0; i<=g->size; i++) { | 165 | for (i=0; i<=g->size; i++) { |
167 | if (checkfunc(L, val(node(g,i))) && ttype(key(node(g,i))) == TAG_STRING) { | 166 | if (ttype(key(node(g,i))) == TAG_STRING && checkfunc(L, val(node(g,i)))) { |
168 | ar->name = tsvalue(key(node(g,i)))->str; | 167 | ar->name = tsvalue(key(node(g,i)))->str; |
169 | ar->namewhat = "global"; | 168 | ar->namewhat = "global"; |
170 | return; | 169 | return; |
@@ -178,12 +177,17 @@ static void lua_getobjname (lua_State *L, StkId f, lua_Debug *ar) { | |||
178 | 177 | ||
179 | 178 | ||
180 | int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | 179 | int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { |
181 | StkId func = ar->_func; | 180 | StkId func; |
182 | LUA_ASSERT(L, is_T_MARK(ttype(func)), "invalid activation record"); | 181 | if (*what != '>') |
182 | func = ar->_func; | ||
183 | else { | ||
184 | what++; /* skip the '>' */ | ||
185 | func = ar->func; | ||
186 | } | ||
183 | for (; *what; what++) { | 187 | for (; *what; what++) { |
184 | switch (*what) { | 188 | switch (*what) { |
185 | case 'S': | 189 | case 'S': |
186 | lua_funcinfo(ar); | 190 | lua_funcinfo(ar, func); |
187 | break; | 191 | break; |
188 | case 'l': | 192 | case 'l': |
189 | ar->currentline = lua_currentline(L, func); | 193 | ar->currentline = lua_currentline(L, func); |