Pārlūkot izejas kodu

debug information for last line of a function definition

Roberto Ierusalimschy 20 gadi atpakaļ
vecāks
revīzija
1ab2b93462
8 mainītis faili ar 24 papildinājumiem un 16 dzēšanām
  1. 2 1
      ldblib.c
  2. 3 2
      ldebug.c
  3. 3 2
      ldump.c
  4. 3 2
      lfunc.c
  5. 3 2
      lobject.h
  6. 5 4
      lparser.c
  7. 2 1
      lua.h
  8. 3 2
      lundump.c

+ 2 - 1
ldblib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldblib.c,v 1.93 2005/02/18 12:40:02 roberto Exp roberto $
+** $Id: ldblib.c,v 1.94 2005/03/08 20:10:05 roberto Exp roberto $
 ** Interface from Lua to its debug API
 ** See Copyright Notice in lua.h
 */
@@ -105,6 +105,7 @@ static int db_getinfo (lua_State *L) {
         settabss(L, "source", ar.source);
         settabss(L, "short_src", ar.short_src);
         settabsi(L, "linedefined", ar.linedefined);
+        settabsi(L, "lastlinedefined", ar.lastlinedefined);
         settabss(L, "what", ar.what);
         break;
       case 'l':

+ 3 - 2
ldebug.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldebug.c,v 2.15 2005/04/14 13:30:47 roberto Exp roberto $
+** $Id: ldebug.c,v 2.16 2005/05/04 20:42:28 roberto Exp roberto $
 ** Debug Interface
 ** See Copyright Notice in lua.h
 */
@@ -157,7 +157,8 @@ static void funcinfo (lua_Debug *ar, StkId func) {
   }
   else {
     ar->source = getstr(cl->l.p->source);
-    ar->linedefined = cl->l.p->lineDefined;
+    ar->linedefined = cl->l.p->linedefined;
+    ar->lastlinedefined = cl->l.p->lastlinedefined;
     ar->what = (ar->linedefined == 0) ? "main" : "Lua";
   }
   luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE);

+ 3 - 2
ldump.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ldump.c,v 2.3 2004/07/09 18:24:41 roberto Exp $
+** $Id: ldump.c,v 2.4 2004/10/04 19:01:12 roberto Exp roberto $
 ** save pre-compiled Lua chunks
 ** See Copyright Notice in lua.h
 */
@@ -136,7 +136,8 @@ static void DumpConstants(const Proto* f, DumpState* D)
 static void DumpFunction(const Proto* f, const TString* p, DumpState* D)
 {
  DumpString((f->source==p) ? NULL : f->source,D);
- DumpInt(f->lineDefined,D);
+ DumpInt(f->linedefined,D);
+ DumpInt(f->lastlinedefined,D);
  DumpByte(f->nups,D);
  DumpByte(f->numparams,D);
  DumpByte(f->is_vararg,D);

+ 3 - 2
lfunc.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lfunc.c,v 2.9 2005/02/18 12:40:02 roberto Exp roberto $
+** $Id: lfunc.c,v 2.10 2005/04/29 13:54:05 roberto Exp roberto $
 ** Auxiliary functions to manipulate prototypes and closures
 ** See Copyright Notice in lua.h
 */
@@ -131,7 +131,8 @@ Proto *luaF_newproto (lua_State *L) {
   f->lineinfo = NULL;
   f->sizelocvars = 0;
   f->locvars = NULL;
-  f->lineDefined = 0;
+  f->linedefined = 0;
+  f->lastlinedefined = 0;
   f->source = NULL;
   return f;
 }

+ 3 - 2
lobject.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lobject.h,v 2.11 2005/02/18 12:40:02 roberto Exp roberto $
+** $Id: lobject.h,v 2.12 2005/04/25 19:24:10 roberto Exp roberto $
 ** Type definitions for Lua objects
 ** See Copyright Notice in lua.h
 */
@@ -244,7 +244,8 @@ typedef struct Proto {
   int sizelineinfo;
   int sizep;  /* size of `p' */
   int sizelocvars;
-  int lineDefined;
+  int linedefined;
+  int lastlinedefined;
   GCObject *gclist;
   lu_byte nups;  /* number of upvalues */
   lu_byte numparams;

+ 5 - 4
lparser.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lparser.c,v 2.23 2005/05/04 16:36:23 roberto Exp roberto $
+** $Id: lparser.c,v 2.24 2005/05/04 20:42:28 roberto Exp roberto $
 ** Lua Parser
 ** See Copyright Notice in lua.h
 */
@@ -87,10 +87,10 @@ static void error_expected (LexState *ls, int token) {
 
 
 static void errorlimit (FuncState *fs, int limit, const char *what) {
-  const char *msg = (fs->f->lineDefined == 0) ?
+  const char *msg = (fs->f->linedefined == 0) ?
     luaO_pushfstring(fs->L, "main function has more than %d %s", limit, what) :
     luaO_pushfstring(fs->L, "function at line %d has more than %d %s",
-                            fs->f->lineDefined, limit, what);
+                            fs->f->linedefined, limit, what);
   luaX_lexerror(fs->ls, msg, 0);
 }
 
@@ -591,7 +591,7 @@ static void body (LexState *ls, expdesc *e, int needself, int line) {
   /* body ->  `(' parlist `)' chunk END */
   FuncState new_fs;
   open_func(ls, &new_fs);
-  new_fs.f->lineDefined = line;
+  new_fs.f->linedefined = line;
   checknext(ls, '(');
   if (needself) {
     new_localvarliteral(ls, "self", 0);
@@ -600,6 +600,7 @@ static void body (LexState *ls, expdesc *e, int needself, int line) {
   parlist(ls);
   checknext(ls, ')');
   chunk(ls);
+  new_fs.f->lastlinedefined = ls->linenumber;
   check_match(ls, TK_END, TK_FUNCTION, line);
   close_func(ls);
   pushclosure(ls, &new_fs, e);

+ 2 - 1
lua.h

@@ -1,5 +1,5 @@
 /*
-** $Id: lua.h,v 1.204 2005/03/23 17:51:11 roberto Exp roberto $
+** $Id: lua.h,v 1.205 2005/03/28 17:17:53 roberto Exp roberto $
 ** Lua - An Extensible Extension Language
 ** Tecgraf: Computer Graphics Technology Group, PUC-Rio, Brazil
 ** http://www.lua.org	mailto:[email protected]
@@ -345,6 +345,7 @@ struct lua_Debug {
   int currentline;	/* (l) */
   int nups;		/* (u) number of upvalues */
   int linedefined;	/* (S) */
+  int lastlinedefined;	/* (S) */
   char short_src[LUA_IDSIZE]; /* (S) */
   /* private part */
   int i_ci;  /* active function */

+ 3 - 2
lundump.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lundump.c,v 2.2 2004/04/30 20:13:38 roberto Exp $
+** $Id: lundump.c,v 2.3 2004/10/04 19:01:12 roberto Exp roberto $
 ** load pre-compiled Lua chunks
 ** See Copyright Notice in lua.h
 */
@@ -201,7 +201,8 @@ static Proto* LoadFunction (LoadState* S, TString* p)
  setptvalue2s(L, L->top, f);
  incr_top(L);
  f->source=LoadString(S); if (f->source==NULL) f->source=p;
- f->lineDefined=LoadInt(S);
+ f->linedefined=LoadInt(S);
+ f->lastlinedefined=LoadInt(S);
  f->nups=LoadByte(S);
  f->numparams=LoadByte(S);
  f->is_vararg=LoadByte(S);