Use LineInfo instead of raw FilePos objects. Most information in the object

files does now have lists of LineInfos attached. Compiles but UNTESTED!


git-svn-id: svn://svn.cc65.org/cc65/trunk@4921 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2011-01-26 19:42:17 +00:00
parent 25c13a4f54
commit 733e832b5d
19 changed files with 349 additions and 295 deletions

View File

@@ -1,6 +1,6 @@
/*****************************************************************************/
/* */
/* lineinfo.h */
/* lineinfo.h */
/* */
/* Source file line info structure */
/* */
@@ -38,11 +38,13 @@
#include "xmalloc.h"
/* ld65 */
#include "error.h"
#include "fileinfo.h"
#include "fileio.h"
#include "fragment.h"
#include "lineinfo.h"
#include "objdata.h"
#include "segments.h"
#include "lineinfo.h"
@@ -69,20 +71,19 @@ static CodeRange* NewCodeRange (Segment* Seg, unsigned long Offs, unsigned long
static LineInfo* NewLineInfo (ObjData* O, const FilePos* Pos)
/* Create and return a new LineInfo struct */
static LineInfo* NewLineInfo (void)
/* Create and return a new LineInfo struct with mostly empty fields */
{
/* Allocate memory */
LineInfo* LI = xmalloc (sizeof (LineInfo));
/* Make sure the name index is valid */
CHECK (Pos->Name < CollCount (&O->Files));
/* Initialize the fields */
LI->File = CollAt (&O->Files, Pos->Name);
LI->Pos = *Pos;
InitCollection (&LI->Fragments);
InitCollection (&LI->CodeRanges);
LI->Pos.Name = INVALID_STRING_ID;
LI->Pos.Line = 0;
LI->Pos.Col = 0;
LI->File = 0;
LI->Fragments = EmptyCollection;
LI->CodeRanges = EmptyCollection;
/* Return the new struct */
return LI;
@@ -90,15 +91,35 @@ static LineInfo* NewLineInfo (ObjData* O, const FilePos* Pos)
LineInfo* GenLineInfo (const FilePos* Pos)
/* Generate a new (internally used) line info with the given information */
{
/* Create a new LineInfo struct */
LineInfo* LI = NewLineInfo ();
/* Initialize the fields in the new LineInfo */
LI->Pos = *Pos;
/* Return the struct read */
return LI;
}
LineInfo* ReadLineInfo (FILE* F, ObjData* O)
/* Read a line info from a file and return it */
{
/* Read the file position */
FilePos Pos;
ReadFilePos (F, &Pos);
/* Create a new LineInfo struct */
LineInfo* LI = NewLineInfo ();
/* Allocate a new LineInfo struct, initialize and return it */
return NewLineInfo (O, &Pos);
/* Read/fill the fields in the new LineInfo */
LI->Pos.Line = ReadVar (F);
LI->Pos.Col = ReadVar (F);
LI->File = CollAt (&O->Files, ReadVar (F));
LI->Pos.Name = LI->File->Name;
/* Return the struct read */
return LI;
}
@@ -221,3 +242,4 @@ void RelocLineInfo (Segment* S)