/*****************************************************************************/
/* */
-/* lineinfo.h */
+/* lineinfo.h */
/* */
-/* Source file line info structure */
+/* Source file line info management */
/* */
/* */
/* */
-/* (C) 2001 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@cc65.org */
+/* (C) 2001-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* 70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
-/* 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
/* common */
+#include "coll.h"
#include "filepos.h"
+#include "hashtab.h"
+#include "lidefs.h"
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
-/* The LineInfo structure is shared between several fragments, so we need a
- * reference counter.
- */
+/* Opaque structure used to handle line information */
typedef struct LineInfo LineInfo;
-struct LineInfo {
- LineInfo* Next; /* Pointer to next info in list */
- unsigned Usage; /* Usage counter */
- unsigned Index; /* Index */
- FilePos Pos; /* File position */
-};
-
-/* 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 */
+/* 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 InitLineInfo (void);
+/* Initialize the line infos */
+
+void DoneLineInfo (void);
+/* Close down line infos */
+
+void EndLine (LineInfo* LI);
+/* End a line that is tracked by the given LineInfo structure */
+
+LineInfo* StartLine (const FilePos* Pos, unsigned Type, unsigned Count);
+/* Start line info for a new line */
+
+void NewAsmLine (void);
+/* Start a new assembler input line. Use this function when generating new
+ * line of LI_TYPE_ASM. It will check if line and/or file have actually
+ * changed, end the old and start the new line as necessary.
*/
-void GenLineInfo (unsigned FileIndex, unsigned long LineNum);
-/* Generate a new line info */
+LineInfo* GetAsmLineInfo (void);
+/* Return the line info for the current assembler file. The function will
+ * bump the reference counter before returning the line info.
+ */
+
+void ReleaseLineInfo (LineInfo* LI);
+/* Decrease the reference count for a line info */
+
+void GetFullLineInfo (Collection* LineInfos);
+/* Return full line infos, that is line infos for currently active Slots. The
+ * infos will be added to the given collection, existing entries will be left
+ * intact. The reference count of all added entries will be increased.
+ */
+
+void ReleaseFullLineInfo (Collection* LineInfos);
+/* Decrease the reference count for a collection full of LineInfos, then clear
+ * the collection.
+ */
+
+const FilePos* GetSourcePos (const LineInfo* LI);
+/* Return the source file position from the given line info */
+
+unsigned GetLineInfoType (const LineInfo* LI);
+/* Return the type of a line info */
+
+void WriteLineInfo (const Collection* LineInfos);
+/* Write a list of line infos to the object file. */
+
+void WriteLineInfos (void);
+/* Write a list of all line infos to the object file. */
+