]> git.sur5r.net Git - cc65/blobdiff - src/ld65/lineinfo.h
Removed unneeded include files.
[cc65] / src / ld65 / lineinfo.h
index 8a40126f328e695fc4e3d4d704249f37838cadc5..db4f84f4a615f1f9a0fd4ce7aaf51aa61a2d4f06 100644 (file)
@@ -6,10 +6,10 @@
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
-/* (C) 2001      Ullrich von Bassewitz                                       */
-/*               Wacholderweg 14                                             */
-/*               D-70597 Stuttgart                                           */
-/* EMail:        uz@cc65.org                                                 */
+/* (C) 2001-2011, Ullrich von Bassewitz                                      */
+/*                Roemerstrasse 52                                           */
+/*                D-70794 Filderstadt                                        */
+/* EMail:         uz@cc65.org                                                */
 /*                                                                           */
 /*                                                                           */
 /* This software is provided 'as-is', without any expressed or implied       */
 
 
 
+#include <stdio.h>
+
 /* common */
 #include "coll.h"
 #include "filepos.h"
 
 /* ld65 */
-#include "objdata.h"
+#include "span.h"
+#include "spool.h"
 
 
 
 /*****************************************************************************/
-/*                                  Data                                    */
+/*                                Forwards                                  */
 /*****************************************************************************/
 
 
 
+struct ObjData;
+struct Segment;
+
+
+
+/*****************************************************************************/
+/*                                  Data                                    */
+/*****************************************************************************/
+
+
+
+/* Structure holding line information. The Pos.Name field is always the
+ * global string id of the file name. If the line info was read from the
+ * object file, the File pointer is valid, otherwise it is NULL.
+ */
 typedef struct LineInfo LineInfo;
 struct LineInfo {
-    struct FileInfo*    File;                /* File struct for this line */
-    FilePos             Pos;                  /* File position */
-    Collection          Fragments;            /* Fragments for this line */
+    unsigned            Id;             /* Line info id */
+    struct FileInfo*    File;          /* File struct for this line if any */
+    unsigned            Type;           /* Type of line info */
+    FilePos             Pos;            /* Position in file */
+    unsigned*           Spans;          /* Spans for this line */
 };
 
 
@@ -68,9 +88,98 @@ struct LineInfo {
 
 
 
-LineInfo* ReadLineInfo (FILE* F, ObjData* O);
+LineInfo* GenLineInfo (const FilePos* Pos);
+/* Generate a new (internally used) line info with the given information */
+
+LineInfo* ReadLineInfo (FILE* F, struct ObjData* O);
 /* Read a line info from a file and return it */
 
+void FreeLineInfo (LineInfo* LI);
+/* Free a LineInfo structure. */
+
+void ReadLineInfoList (FILE* F, struct ObjData* O, Collection* LineInfos);
+/* Read a list of line infos stored as a list of indices in the object file,
+ * make real line infos from them and place them into the passed collection.
+ */
+
+const LineInfo* GetAsmLineInfo (const Collection* LineInfos);
+/* Find a line info of type LI_TYPE_ASM in the given collection and return it.
+ * Return NULL if no such line info was found.
+ */
+
+#if defined(HAVE_INLINE)
+INLINE const FilePos* GetSourcePos (const LineInfo* LI)
+/* Return the source file position from the given line info */
+{
+    return &LI->Pos;
+}
+#else
+#  define GetSourcePos(LI)      (&(LI)->Pos)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE const char* GetSourceName (const LineInfo* LI)
+/* Return the name of a source file from the given line info */
+{
+    return GetString (LI->Pos.Name);
+}
+#else
+#  define GetSourceName(LI)     (GetString ((LI)->Pos.Name))
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE unsigned GetSourceLine (const LineInfo* LI)
+/* Return the source file line from the given line info */
+{
+    return LI->Pos.Line;
+}
+#else
+#  define GetSourceLine(LI)     ((LI)->Pos.Line)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE unsigned GetSourceCol (const LineInfo* LI)
+/* Return the source file column from the given line info */
+{
+    return LI->Pos.Col;
+}
+#else
+#  define GetSourceCol(LI)      ((LI)->Pos.Col)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE const char* GetSourceNameFromList (const Collection* LineInfos)
+/* Return the name of a source file from a list of line infos */
+{
+    /* The relevant entry is in slot zero */
+    return GetSourceName (CollConstAt (LineInfos, 0));
+}
+#else
+#  define GetSourceNameFromList(LineInfos)      \
+        GetSourceName ((const LineInfo*) CollConstAt ((LineInfos), 0))
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE unsigned GetSourceLineFromList (const Collection* LineInfos)
+/* Return the source file line from a list of line infos */
+{
+    /* The relevant entry is in slot zero */
+    return GetSourceLine (CollConstAt (LineInfos, 0));
+}
+#else
+#  define GetSourceLineFromList(LineInfos)      \
+        GetSourceLine ((const LineInfo*) CollConstAt ((LineInfos), 0))
+#endif
+
+unsigned LineInfoCount (void);
+/* Return the total number of line infos */
+
+void AssignLineInfoIds (void);
+/* Assign the ids to the line infos */
+
+void PrintDbgLineInfo (FILE* F);
+/* Output the line infos to a debug info file */
+
 
 
 /* End of lineinfo.h */