diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-07 17:21:34 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2000-08-07 17:21:34 -0300 |
| commit | d9e61e8ceafe8c3f6ad936979719ca7c446ce228 (patch) | |
| tree | 0808ada3d7b7219022b9002503894c76c7253df6 /ldebug.c | |
| parent | 397905ef8694ec716a51acebc993bb625340d388 (diff) | |
| download | lua-d9e61e8ceafe8c3f6ad936979719ca7c446ce228.tar.gz lua-d9e61e8ceafe8c3f6ad936979719ca7c446ce228.tar.bz2 lua-d9e61e8ceafe8c3f6ad936979719ca7c446ce228.zip | |
new algorithm for traversing in GC to avoid deep recursion calls
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 | } |
