]> git.sur5r.net Git - cc65/blobdiff - src/ca65/lineinfo.h
Finished implemenation of commands to delete macros. Added the new commands to
[cc65] / src / ca65 / lineinfo.h
index ec654118ecc75a3287f528c8d08114aef95b3df3..7aa4d1a2fc385f6789448efb4de7b2f6fa7e1961 100644 (file)
@@ -2,7 +2,7 @@
 /*                                                                           */
 /*                               lineinfo.h                                 */
 /*                                                                           */
-/*                     Source file line info structure                      */
+/*                     Source file line info management                      */
 /*                                                                           */
 /*                                                                           */
 /*                                                                           */
 
 
 
-/* Note: The line infos kept here are additional line infos supplied by the
- * ".dbg line" command. The native line infos are always kept in the fragments
- * itself (because one fragment always originates from one line). The
- * additional line infos (which may not exist if none are supplied in the
- * source) may have several fragments attached (as is the case with sources
- * generated by the C compiler).
- */
-
-
-
 #ifndef LINEINFO_H
 #define LINEINFO_H
 
@@ -51,6 +41,7 @@
 /* common */
 #include "coll.h"
 #include "filepos.h"
+#include "lidefs.h"
 
 
 
@@ -69,18 +60,6 @@ enum {
     LI_SLOT_EXT         = 1,            /* Externally supplied line info */
 };
 
-/* Types of line infos. The low byte may be used for some sort of depth
- * counter.
- */
-enum {
-    LI_MASK_COUNT       = 0x00FF,       /* Mask to extract the count */
-
-    LI_TYPE_EXT         = 0x0100,       /* Externally supplied line info */
-    LI_TYPE_ASM         = 0x0200,       /* Normal assembler source */
-    LI_TYPE_MACRO       = 0x0300,       /* Macro expansion */
-    LI_MASK_TYPE        = 0x7F00,       /* Mask to extract the type */
-};
-
 /* The LineInfo structure is shared between several fragments, so we need a
  * reference counter.
  */
@@ -103,7 +82,7 @@ struct LineInfo {
 void InitLineInfo (void);
 /* Initialize the line infos */
 
-unsigned AllocLineInfoSlot (unsigned Type);
+unsigned AllocLineInfoSlot (unsigned Type, unsigned Count);
 /* Allocate a line info slot of the given type and return the slot index */
 
 void FreeLineInfoSlot (unsigned Slot);
@@ -111,18 +90,16 @@ void FreeLineInfoSlot (unsigned Slot);
  * FIFO order.
  */
 
-void GenLineInfo (unsigned Slot, unsigned File, unsigned long Line, unsigned Col);
+void GenLineInfo (unsigned Slot, const FilePos* Pos);
 /* Generate a new line info in the given slot */
 
 void ClearLineInfo (unsigned Slot);
 /* Clear the line info in the given slot */
 
-LineInfo* GetLineInfo (unsigned Slot);
-/* Get the line info from the given slot */
-
-void GetFullLineInfo (Collection* LineInfos);
+void GetFullLineInfo (Collection* LineInfos, unsigned IncUsage);
 /* Return full line infos, that is line infos for all slots in LineInfos. The
- * function does also increase the usage counter for all line infos returned.
+ * function will clear LineInfos before usage and will increment the usage
+ * counter by IncUsage for all line infos returned.
  */
 
 LineInfo* UseLineInfo (LineInfo* LI);
@@ -135,6 +112,26 @@ LineInfo* ReleaseLineInfo (LineInfo* LI);
  * function will gracefully accept NULL pointers and do nothing in this case.
  */
 
+#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 unsigned GetLineInfoType (const LineInfo* LI)
+/* Return the type of a line info */
+{
+    return LI_GET_TYPE (LI->Type);
+}
+#else
+#  define GetLineInfoType(LI)     LI_GET_TYPE ((LI)->Type)
+#endif
+
 void WriteLineInfo (const Collection* LineInfos);
 /* Write a list of line infos to the object file. MakeLineInfoIndex has to
  * be called before!