diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-05 17:47:02 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-05-05 17:47:02 -0300 |
| commit | 1ab2b93462753b5f500ada31353acc444d4e7b7c (patch) | |
| tree | 0934f3891707f446c3b0d57ba7827243bc1f6e22 | |
| parent | 6cf85dcc900c71687678bc316164142e76df7385 (diff) | |
| download | lua-1ab2b93462753b5f500ada31353acc444d4e7b7c.tar.gz lua-1ab2b93462753b5f500ada31353acc444d4e7b7c.tar.bz2 lua-1ab2b93462753b5f500ada31353acc444d4e7b7c.zip | |
debug information for last line of a function definition
| -rw-r--r-- | ldblib.c | 3 | ||||
| -rw-r--r-- | ldebug.c | 5 | ||||
| -rw-r--r-- | ldump.c | 5 | ||||
| -rw-r--r-- | lfunc.c | 5 | ||||
| -rw-r--r-- | lobject.h | 5 | ||||
| -rw-r--r-- | lparser.c | 9 | ||||
| -rw-r--r-- | lua.h | 3 | ||||
| -rw-r--r-- | lundump.c | 5 |
8 files changed, 24 insertions, 16 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldblib.c,v 1.93 2005/02/18 12:40:02 roberto Exp roberto $ | 2 | ** $Id: ldblib.c,v 1.94 2005/03/08 20:10:05 roberto Exp roberto $ |
| 3 | ** Interface from Lua to its debug API | 3 | ** Interface from Lua to its debug API |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -105,6 +105,7 @@ static int db_getinfo (lua_State *L) { | |||
| 105 | settabss(L, "source", ar.source); | 105 | settabss(L, "source", ar.source); |
| 106 | settabss(L, "short_src", ar.short_src); | 106 | settabss(L, "short_src", ar.short_src); |
| 107 | settabsi(L, "linedefined", ar.linedefined); | 107 | settabsi(L, "linedefined", ar.linedefined); |
| 108 | settabsi(L, "lastlinedefined", ar.lastlinedefined); | ||
| 108 | settabss(L, "what", ar.what); | 109 | settabss(L, "what", ar.what); |
| 109 | break; | 110 | break; |
| 110 | case 'l': | 111 | case 'l': |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 2.15 2005/04/14 13:30:47 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.16 2005/05/04 20:42:28 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 | */ |
| @@ -157,7 +157,8 @@ static void funcinfo (lua_Debug *ar, StkId func) { | |||
| 157 | } | 157 | } |
| 158 | else { | 158 | else { |
| 159 | ar->source = getstr(cl->l.p->source); | 159 | ar->source = getstr(cl->l.p->source); |
| 160 | ar->linedefined = cl->l.p->lineDefined; | 160 | ar->linedefined = cl->l.p->linedefined; |
| 161 | ar->lastlinedefined = cl->l.p->lastlinedefined; | ||
| 161 | ar->what = (ar->linedefined == 0) ? "main" : "Lua"; | 162 | ar->what = (ar->linedefined == 0) ? "main" : "Lua"; |
| 162 | } | 163 | } |
| 163 | luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); | 164 | luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldump.c,v 2.3 2004/07/09 18:24:41 roberto Exp $ | 2 | ** $Id: ldump.c,v 2.4 2004/10/04 19:01:12 roberto Exp roberto $ |
| 3 | ** save pre-compiled Lua chunks | 3 | ** save pre-compiled Lua chunks |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -136,7 +136,8 @@ static void DumpConstants(const Proto* f, DumpState* D) | |||
| 136 | static void DumpFunction(const Proto* f, const TString* p, DumpState* D) | 136 | static void DumpFunction(const Proto* f, const TString* p, DumpState* D) |
| 137 | { | 137 | { |
| 138 | DumpString((f->source==p) ? NULL : f->source,D); | 138 | DumpString((f->source==p) ? NULL : f->source,D); |
| 139 | DumpInt(f->lineDefined,D); | 139 | DumpInt(f->linedefined,D); |
| 140 | DumpInt(f->lastlinedefined,D); | ||
| 140 | DumpByte(f->nups,D); | 141 | DumpByte(f->nups,D); |
| 141 | DumpByte(f->numparams,D); | 142 | DumpByte(f->numparams,D); |
| 142 | DumpByte(f->is_vararg,D); | 143 | DumpByte(f->is_vararg,D); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lfunc.c,v 2.9 2005/02/18 12:40:02 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 2.10 2005/04/29 13:54:05 roberto Exp roberto $ |
| 3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -131,7 +131,8 @@ Proto *luaF_newproto (lua_State *L) { | |||
| 131 | f->lineinfo = NULL; | 131 | f->lineinfo = NULL; |
| 132 | f->sizelocvars = 0; | 132 | f->sizelocvars = 0; |
| 133 | f->locvars = NULL; | 133 | f->locvars = NULL; |
| 134 | f->lineDefined = 0; | 134 | f->linedefined = 0; |
| 135 | f->lastlinedefined = 0; | ||
| 135 | f->source = NULL; | 136 | f->source = NULL; |
| 136 | return f; | 137 | return f; |
| 137 | } | 138 | } |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lobject.h,v 2.11 2005/02/18 12:40:02 roberto Exp roberto $ | 2 | ** $Id: lobject.h,v 2.12 2005/04/25 19:24:10 roberto Exp roberto $ |
| 3 | ** Type definitions for Lua objects | 3 | ** Type definitions for Lua objects |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -244,7 +244,8 @@ typedef struct Proto { | |||
| 244 | int sizelineinfo; | 244 | int sizelineinfo; |
| 245 | int sizep; /* size of `p' */ | 245 | int sizep; /* size of `p' */ |
| 246 | int sizelocvars; | 246 | int sizelocvars; |
| 247 | int lineDefined; | 247 | int linedefined; |
| 248 | int lastlinedefined; | ||
| 248 | GCObject *gclist; | 249 | GCObject *gclist; |
| 249 | lu_byte nups; /* number of upvalues */ | 250 | lu_byte nups; /* number of upvalues */ |
| 250 | lu_byte numparams; | 251 | lu_byte numparams; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.c,v 2.23 2005/05/04 16:36:23 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.24 2005/05/04 20:42:28 roberto Exp roberto $ |
| 3 | ** Lua Parser | 3 | ** Lua Parser |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -87,10 +87,10 @@ static void error_expected (LexState *ls, int token) { | |||
| 87 | 87 | ||
| 88 | 88 | ||
| 89 | static void errorlimit (FuncState *fs, int limit, const char *what) { | 89 | static void errorlimit (FuncState *fs, int limit, const char *what) { |
| 90 | const char *msg = (fs->f->lineDefined == 0) ? | 90 | const char *msg = (fs->f->linedefined == 0) ? |
| 91 | luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : | 91 | luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) : |
| 92 | luaO_pushfstring(fs->L, "function at line %d has more than %d %s", | 92 | luaO_pushfstring(fs->L, "function at line %d has more than %d %s", |
| 93 | fs->f->lineDefined, limit, what); | 93 | fs->f->linedefined, limit, what); |
| 94 | luaX_lexerror(fs->ls, msg, 0); | 94 | luaX_lexerror(fs->ls, msg, 0); |
| 95 | } | 95 | } |
| 96 | 96 | ||
| @@ -591,7 +591,7 @@ static void body (LexState *ls, expdesc *e, int needself, int line) { | |||
| 591 | /* body -> `(' parlist `)' chunk END */ | 591 | /* body -> `(' parlist `)' chunk END */ |
| 592 | FuncState new_fs; | 592 | FuncState new_fs; |
| 593 | open_func(ls, &new_fs); | 593 | open_func(ls, &new_fs); |
| 594 | new_fs.f->lineDefined = line; | 594 | new_fs.f->linedefined = line; |
| 595 | checknext(ls, '('); | 595 | checknext(ls, '('); |
| 596 | if (needself) { | 596 | if (needself) { |
| 597 | new_localvarliteral(ls, "self", 0); | 597 | new_localvarliteral(ls, "self", 0); |
| @@ -600,6 +600,7 @@ static void body (LexState *ls, expdesc *e, int needself, int line) { | |||
| 600 | parlist(ls); | 600 | parlist(ls); |
| 601 | checknext(ls, ')'); | 601 | checknext(ls, ')'); |
| 602 | chunk(ls); | 602 | chunk(ls); |
| 603 | new_fs.f->lastlinedefined = ls->linenumber; | ||
| 603 | check_match(ls, TK_END, TK_FUNCTION, line); | 604 | check_match(ls, TK_END, TK_FUNCTION, line); |
| 604 | close_func(ls); | 605 | close_func(ls); |
| 605 | pushclosure(ls, &new_fs, e); | 606 | pushclosure(ls, &new_fs, e); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lua.h,v 1.204 2005/03/23 17:51:11 roberto Exp roberto $ | 2 | ** $Id: lua.h,v 1.205 2005/03/28 17:17:53 roberto Exp roberto $ |
| 3 | ** Lua - An Extensible Extension Language | 3 | ** Lua - An Extensible Extension Language |
| 4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil | 4 | ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil |
| 5 | ** http://www.lua.org mailto:info@lua.org | 5 | ** http://www.lua.org mailto:info@lua.org |
| @@ -345,6 +345,7 @@ struct lua_Debug { | |||
| 345 | int currentline; /* (l) */ | 345 | int currentline; /* (l) */ |
| 346 | int nups; /* (u) number of upvalues */ | 346 | int nups; /* (u) number of upvalues */ |
| 347 | int linedefined; /* (S) */ | 347 | int linedefined; /* (S) */ |
| 348 | int lastlinedefined; /* (S) */ | ||
| 348 | char short_src[LUA_IDSIZE]; /* (S) */ | 349 | char short_src[LUA_IDSIZE]; /* (S) */ |
| 349 | /* private part */ | 350 | /* private part */ |
| 350 | int i_ci; /* active function */ | 351 | int i_ci; /* active function */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lundump.c,v 2.2 2004/04/30 20:13:38 roberto Exp $ | 2 | ** $Id: lundump.c,v 2.3 2004/10/04 19:01:12 roberto Exp roberto $ |
| 3 | ** load pre-compiled Lua chunks | 3 | ** load pre-compiled Lua chunks |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -201,7 +201,8 @@ static Proto* LoadFunction (LoadState* S, TString* p) | |||
| 201 | setptvalue2s(L, L->top, f); | 201 | setptvalue2s(L, L->top, f); |
| 202 | incr_top(L); | 202 | incr_top(L); |
| 203 | f->source=LoadString(S); if (f->source==NULL) f->source=p; | 203 | f->source=LoadString(S); if (f->source==NULL) f->source=p; |
| 204 | f->lineDefined=LoadInt(S); | 204 | f->linedefined=LoadInt(S); |
| 205 | f->lastlinedefined=LoadInt(S); | ||
| 205 | f->nups=LoadByte(S); | 206 | f->nups=LoadByte(S); |
| 206 | f->numparams=LoadByte(S); | 207 | f->numparams=LoadByte(S); |
| 207 | f->is_vararg=LoadByte(S); | 208 | f->is_vararg=LoadByte(S); |
