]> git.sur5r.net Git - cc65/commitdiff
Added new lineinfo module
authorcuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 23 May 2001 07:04:09 +0000 (07:04 +0000)
committercuz <cuz@b7a2c559-68d2-44c3-8de9-860c34a00d81>
Wed, 23 May 2001 07:04:09 +0000 (07:04 +0000)
git-svn-id: svn://svn.cc65.org/cc65/trunk@745 b7a2c559-68d2-44c3-8de9-860c34a00d81

src/ca65/dbginfo.c
src/ca65/dbginfo.h
src/ca65/filetab.h
src/ca65/lineinfo.c [new file with mode: 0644]
src/ca65/lineinfo.h [new file with mode: 0644]
src/ca65/make/gcc.mak

index b921f7af8ecb4928c7ab3e9078801e2757fbad96..ade483c15fa5330880ca594bce504125723d3edf 100644 (file)
@@ -1,15 +1,15 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                                dbginfo.c                                 */
+/*                                dbginfo.c                                 */
 /*                                                                           */
-/*                        Handle the .dbg commands                          */
+/*                        Handle the .dbg commands                          */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 2000-2001 Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
@@ -39,6 +39,7 @@
 #include "error.h"
 #include "expr.h"
 #include "filetab.h"
+#include "lineinfo.h"
 #include "nexttok.h"
 #include "dbginfo.h"
 
@@ -111,8 +112,8 @@ void DbgInfoLine (void)
        return;
     }
 
-    /* ## Remember the line info */
-
+    /* Remember the line info */
+    GenLineInfo (Index, LineNum);
 }
 
 
index 77e21cdfd5f5a74b49f60763cb81d525c395c03a..9f0ce3ed571a5ad250fb074b18961c3682826dd4 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 2000-2001 Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
index 22f2554bf2b34335b1bd17cd1622c7df26fb3f04..47d4f754d3d7d1287fb4e4eade981664da1832bd 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2000     Ullrich von Bassewitz                                        */
-/*              Wacholderweg 14                                              */
-/*              D-70597 Stuttgart                                            */
-/* EMail:       uz@musoftware.de                                             */
+/* (C) 2000      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@cc65.org                                                 */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
diff --git a/src/ca65/lineinfo.c b/src/ca65/lineinfo.c
new file mode 100644 (file)
index 0000000..be70fd7
--- /dev/null
@@ -0,0 +1,135 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                               lineinfo.c                                 */
+/*                                                                           */
+/*                     Source file line info structure                      */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2001      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@cc65.org                                                 */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+/* common */
+#include "coll.h"
+#include "xmalloc.h"
+
+/* ca65 */
+#include "lineinfo.h"
+
+
+
+/*****************************************************************************/
+/*                                  Data                                    */
+/*****************************************************************************/
+
+
+
+/* Linked list of all line infos */
+LineInfo* LineInfoRoot  = 0;
+LineInfo* LineInfoLast  = 0;
+unsigned  LineInfoCount = 0;
+unsigned  LineInfoValid = 0;              /* Valid, that is, used entries */
+
+/* Static pointer to last line info or NULL if not active */
+LineInfo* CurLineInfo   = 0;
+
+
+
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
+
+
+
+static LineInfo* NewLineInfo (unsigned FileIndex, unsigned long LineNum)
+/* Create and return a new line info. Usage will be zero. */
+{
+    /* Allocate memory */
+    LineInfo* LI = xmalloc (sizeof (LineInfo));
+
+    /* Initialize the fields */
+    LI->Next      = 0;
+    LI->Usage     = 0;
+    LI->LineNum   = LineNum;
+    LI->FileIndex = FileIndex;
+    LI->Index     = 0;           /* Currently invalid */
+
+    /* Insert this structure into the line info list */
+    if (LineInfoLast == 0) {
+       LineInfoRoot = LI;
+    } else {
+       LineInfoLast->Next = LI;
+    }
+    LineInfoLast = LI;
+
+    /* Count the line infos */
+    ++LineInfoCount;
+
+    /* Return the new struct */
+    return LI;
+}
+
+
+
+LineInfo* UseLineInfo (LineInfo* LI)
+/* Increase the reference count of the given line info and return it. The
+ * function will gracefully accept NULL pointers and do nothing in this case.
+ */
+{
+    CHECK (LI != 0);
+    ++LI->Usage;
+    return LI;
+}
+
+
+
+void GenLineInfo (unsigned FileIndex, unsigned long LineNum)
+/* Generate a new line info */
+{
+    /* Create a new line info and make it current */
+    CurLineInfo = NewLineInfo (FileIndex, LineNum);
+}
+
+
+
+void MakeLineInfoIndex (void)
+/* Walk over the line info list and make an index of all entries ignoring
+ * those with a usage count of zero.
+ */
+{
+    LineInfo* LI  = LineInfoRoot;
+    LineInfoValid = 0;
+    while (LI) {
+       if (LI->Usage) {
+           LI->Index = LineInfoValid++;
+       }
+       LI = LI->Next;
+    }
+}
+
+
+
diff --git a/src/ca65/lineinfo.h b/src/ca65/lineinfo.h
new file mode 100644 (file)
index 0000000..4b26679
--- /dev/null
@@ -0,0 +1,90 @@
+/*****************************************************************************/
+/*                                                                           */
+/*                               lineinfo.h                                 */
+/*                                                                           */
+/*                     Source file line info structure                      */
+/*                                                                           */
+/*                                                                           */
+/*                                                                           */
+/* (C) 2001      Ullrich von Bassewitz                                       */
+/*               Wacholderweg 14                                             */
+/*               D-70597 Stuttgart                                           */
+/* EMail:        uz@cc65.org                                                 */
+/*                                                                           */
+/*                                                                           */
+/* This software is provided 'as-is', without any expressed or implied       */
+/* warranty.  In no event will the authors be held liable for any damages    */
+/* arising from the use of this software.                                    */
+/*                                                                           */
+/* Permission is granted to anyone to use this software for any purpose,     */
+/* including commercial applications, and to alter it and redistribute it    */
+/* freely, subject to the following restrictions:                            */
+/*                                                                           */
+/* 1. The origin of this software must not be misrepresented; you must not   */
+/*    claim that you wrote the original software. If you use this software   */
+/*    in a product, an acknowledgment in the product documentation would be  */
+/*    appreciated but is not required.                                       */
+/* 2. Altered source versions must be plainly marked as such, and must not   */
+/*    be misrepresented as being the original software.                      */
+/* 3. This notice may not be removed or altered from any source              */
+/*    distribution.                                                          */
+/*                                                                           */
+/*****************************************************************************/
+
+
+
+#ifndef LINEINFO_H
+#define LINEINFO_H
+
+
+
+/*****************************************************************************/
+/*                                  Data                                    */
+/*****************************************************************************/
+
+
+
+/* The LineInfo structure is shared between several fragments, so we need a
+ * reference counter.
+ */
+typedef struct LineInfo LineInfo;
+struct LineInfo {
+    LineInfo*       Next;                 /* Pointer to next info in list */
+    unsigned               Usage;                /* Usage counter */
+    unsigned long   LineNum;              /* Line number */
+    unsigned        FileIndex;            /* Index of input file */
+    unsigned        Index;                /* Index */
+};
+
+/* Linked list of all line infos */
+extern LineInfo* LineInfoRoot;
+extern LineInfo* LineInfoLast;
+extern unsigned  LineInfoCount;          
+extern unsigned  LineInfoValid;           /* Valid, that is, used entries */
+
+/* Global pointer to last line info or NULL if not active */
+extern LineInfo* CurLineInfo;
+
+
+
+/*****************************************************************************/
+/*                                          Code                                    */
+/*****************************************************************************/
+
+
+
+LineInfo* UseLineInfo (LineInfo* LI);
+/* Increase the reference count of the given line info and return it. The
+ * function will gracefully accept NULL pointers and do nothing in this case.
+ */
+
+void GenLineInfo (unsigned FileIndex, unsigned long LineNum);
+/* Generate a new line info */
+
+
+
+/* End of lineinfo.h */
+#endif
+
+
+
index f200e9a7049362dfee2d0c3eed4d870a87228d2f..60b9239cc430871918dd5d4e749d34a364a42b2c 100644 (file)
@@ -22,6 +22,7 @@ OBJS =  condasm.o     \
        incpath.o       \
         instr.o                \
        istack.o        \
+       lineinfo.o      \
        listing.o       \
        macpack.o       \
                macro.o         \