diff options
Diffstat (limited to 'ldebug.c')
-rw-r--r-- | ldebug.c | 37 |
1 files changed, 25 insertions, 12 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 1.26 2000/06/30 14:29:35 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.27 2000/06/30 14:35:17 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 | */ |
@@ -172,25 +172,38 @@ static void lua_funcinfo (lua_Debug *ar, StkId func) { | |||
172 | } | 172 | } |
173 | 173 | ||
174 | 174 | ||
175 | static int checkfunc (lua_State *L, TObject *o) { | 175 | static const char *travtagmethods (lua_State *L, const TObject *o) { |
176 | return luaO_equalObj(o, L->top); | 176 | int e; |
177 | for (e=0; e<IM_N; e++) { | ||
178 | int t; | ||
179 | for (t=0; t<=L->last_tag; t++) | ||
180 | if (luaO_equalObj(o, luaT_getim(L, t,e))) | ||
181 | return luaT_eventname[e]; | ||
182 | } | ||
183 | return NULL; | ||
177 | } | 184 | } |
178 | 185 | ||
179 | 186 | ||
180 | static void lua_getobjname (lua_State *L, StkId f, lua_Debug *ar) { | 187 | static const char *travglobals (lua_State *L, const TObject *o) { |
181 | Hash *g = L->gt; | 188 | Hash *g = L->gt; |
182 | int i; | 189 | int i; |
183 | /* try to find a name for given function */ | ||
184 | setnormalized(L->top, f); /* to be used by `checkfunc' */ | ||
185 | for (i=0; i<=g->size; i++) { | 190 | for (i=0; i<=g->size; i++) { |
186 | if (ttype(key(node(g,i))) == TAG_STRING && checkfunc(L, val(node(g,i)))) { | 191 | if (luaO_equalObj(o, val(node(g, i))) && |
187 | ar->name = tsvalue(key(node(g,i)))->str; | 192 | ttype(key(node(g, i))) == TAG_STRING) |
188 | ar->namewhat = "global"; | 193 | return tsvalue(key(node(g, i)))->str; |
189 | return; | ||
190 | } | ||
191 | } | 194 | } |
195 | return NULL; | ||
196 | } | ||
197 | |||
198 | |||
199 | static void lua_getobjname (lua_State *L, StkId f, lua_Debug *ar) { | ||
200 | TObject o; | ||
201 | setnormalized(&o, f); | ||
202 | /* try to find a name for given function */ | ||
203 | if ((ar->name = travglobals(L, &o)) != NULL) | ||
204 | ar->namewhat = "global"; | ||
192 | /* not found: try tag methods */ | 205 | /* not found: try tag methods */ |
193 | if ((ar->name = luaT_travtagmethods(L, checkfunc)) != NULL) | 206 | else if ((ar->name = travtagmethods(L, &o)) != NULL) |
194 | ar->namewhat = "tag-method"; | 207 | ar->namewhat = "tag-method"; |
195 | else ar->namewhat = ""; /* not found at all */ | 208 | else ar->namewhat = ""; /* not found at all */ |
196 | } | 209 | } |