/*****************************************************************************/
/* */
-/* lineinfo.c */
+/* lineinfo.c */
/* */
-/* Source file line info structure */
+/* Source file line info structure */
/* */
/* */
/* */
+#include <stdio.h>
#include <string.h>
/* common */
#include "xmalloc.h"
/* ca65 */
+#include "filetab.h"
#include "global.h"
#include "lineinfo.h"
#include "objfile.h"
/*****************************************************************************/
-/* Data */
+/* Data */
/*****************************************************************************/
/*****************************************************************************/
-/* 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 */
{
/* 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.
}
/* 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);
{
unsigned I;
- Collection EmptySpans = STATIC_COLLECTION_INITIALIZER;
-
/* Tell the object file module that we're about to write line infos */
ObjStartLineInfos ();
/* 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);
}