]> git.sur5r.net Git - cc65/blobdiff - src/ca65/lineinfo.c
Removed (pretty inconsistently used) tab chars from source code base.
[cc65] / src / ca65 / lineinfo.c
index 50419c60e8dda19cca18c9e29979ae95139a0e3f..dbc5b4d412c9de66846797ed7cfe855b5c002064 100644 (file)
@@ -1,8 +1,8 @@
 /*****************************************************************************/
 /*                                                                           */
-/*                               lineinfo.c                                 */
+/*                                lineinfo.c                                 */
 /*                                                                           */
-/*                     Source file line info structure                      */
+/*                      Source file line info structure                      */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
@@ -33,6 +33,7 @@
 
 
 
+#include <stdio.h>
 #include <string.h>
 
 /* common */
@@ -41,6 +42,7 @@
 #include "xmalloc.h"
 
 /* ca65 */
+#include "filetab.h"
 #include "global.h"
 #include "lineinfo.h"
 #include "objfile.h"
@@ -70,7 +72,7 @@ static int HT_Compare (const void* Key1, const void* Key2);
 
 
 /*****************************************************************************/
-/*                                  Data                                    */
+/*                                   Data                                    */
 /*****************************************************************************/
 
 
@@ -229,11 +231,38 @@ static int CheckLineInfo (void* Entry, void* Data attribute ((unused)))
 
 
 /*****************************************************************************/
-/*                                          Code                                    */
+/*                                   Code                                    */
 /*****************************************************************************/
 
 
 
+#if 0
+static void DumpLineInfos (const char* Title, const Collection* C)
+/* Dump line infos from the given collection */
+{
+    unsigned I;
+    fprintf (stderr, "%s:\n", Title);
+    for (I = 0; I < CollCount (C); ++I) {
+        const LineInfo* LI = CollConstAt (C, I);
+        const char* Type;
+        switch (GetLineInfoType (LI)) {
+            case LI_TYPE_ASM:           Type = "ASM";           break;
+            case LI_TYPE_EXT:           Type = "EXT";           break;
+            case LI_TYPE_MACRO:         Type = "MACRO";         break;
+            case LI_TYPE_MACPARAM:      Type = "MACPARAM";      break;
+            default:                    Type = "unknown";       break;
+        }
+        fprintf (stderr,
+                 "%2u: %-8s %2u %-16s %u/%u\n",
+                 I, Type, LI->Key.Pos.Name,
+                 SB_GetConstBuf (GetFileName (LI->Key.Pos.Name)),
+                 LI->Key.Pos.Line, LI->Key.Pos.Col);
+    }
+}
+#endif
+
+
+
 void InitLineInfo (void)
 /* Initialize the line infos */
 {
@@ -272,7 +301,7 @@ void EndLine (LineInfo* LI)
 /* End a line that is tracked by the given LineInfo structure */
 {
     /* Close the spans for the line */
-    CloseSpans (&LI->OpenSpans);
+    CloseSpanList (&LI->OpenSpans);
 
     /* Move the spans to the list of all spans for this line, then clear the
      * list of open spans.
@@ -308,7 +337,7 @@ LineInfo* StartLine (const FilePos* Pos, unsigned Type, unsigned Count)
     }
 
     /* Open the spans for this line info */
-    OpenSpans (&LI->OpenSpans);
+    OpenSpanList (&LI->OpenSpans);
 
     /* Add the line info to the list of current line infos */
     CollAppend (&CurLineInfo, LI);
@@ -447,8 +476,6 @@ void WriteLineInfos (void)
 {
     unsigned I;
 
-    Collection EmptySpans = STATIC_COLLECTION_INITIALIZER;
-
     /* Tell the object file module that we're about to write line infos */
     ObjStartLineInfos ();
 
@@ -467,22 +494,12 @@ void WriteLineInfos (void)
         /* Write the type and count of the line info */
         ObjWriteVar (LI->Key.Type);
 
-        /* Spans are only added to the debug file if debug information is
-         * requested. Otherwise we write an empty list.
-         */
-        if (DbgSyms) {
-            WriteSpans (&LI->Spans);
-        } else {
-            /* Write out an empty list */
-            WriteSpans (&EmptySpans);
-        }
+        /* Write the ids of the spans for this line */
+        WriteSpanList (&LI->Spans);
     }
 
     /* End of line infos */
     ObjEndLineInfos ();
-
-    /* For the sake of completeness, but not really necessary */
-    DoneCollection (&EmptySpans);
 }