2001-05-23 19:03:40 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
|
|
|
/* lineinfo.h */
|
|
|
|
/* */
|
|
|
|
/* Source file line info structure */
|
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2011-01-24 22:39:07 +00:00
|
|
|
/* (C) 2001-2011, Ullrich von Bassewitz */
|
2010-07-30 22:44:09 +00:00
|
|
|
/* Roemerstrasse 52 */
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2001-05-23 19:03:40 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef LINEINFO_H
|
|
|
|
#define LINEINFO_H
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-30 22:44:09 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2001-05-23 19:03:40 +00:00
|
|
|
/* common */
|
|
|
|
#include "coll.h"
|
|
|
|
#include "filepos.h"
|
|
|
|
|
2011-01-26 19:42:17 +00:00
|
|
|
/* ld65 */
|
|
|
|
#include "spool.h"
|
|
|
|
|
2001-05-23 19:03:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2010-07-30 22:44:09 +00:00
|
|
|
/* Forwards */
|
2001-05-23 19:03:40 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-07-30 22:44:09 +00:00
|
|
|
struct ObjData;
|
2001-05-29 07:39:46 +00:00
|
|
|
struct Segment;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Data */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct CodeRange CodeRange;
|
|
|
|
struct CodeRange {
|
2010-08-07 12:46:12 +00:00
|
|
|
struct Segment* Seg; /* Segment of this code range */
|
|
|
|
unsigned long Offs; /* Offset of code range */
|
|
|
|
unsigned long Size; /* Size of code range */
|
2001-05-29 07:39:46 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-26 19:42:17 +00:00
|
|
|
/* 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.
|
|
|
|
*/
|
2001-05-23 19:03:40 +00:00
|
|
|
typedef struct LineInfo LineInfo;
|
|
|
|
struct LineInfo {
|
2011-01-26 19:42:17 +00:00
|
|
|
struct FileInfo* File; /* File struct for this line if any */
|
2011-01-29 22:16:03 +00:00
|
|
|
unsigned Type; /* Type of line info */
|
2011-01-26 19:42:17 +00:00
|
|
|
FilePos Pos; /* Position in file */
|
2010-08-07 12:46:12 +00:00
|
|
|
Collection Fragments; /* Fragments for this line */
|
|
|
|
Collection CodeRanges; /* Code ranges for this line */
|
2001-05-23 19:03:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
|
|
|
/* Code */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2011-01-26 19:42:17 +00:00
|
|
|
LineInfo* GenLineInfo (const FilePos* Pos);
|
|
|
|
/* Generate a new (internally used) line info with the given information */
|
|
|
|
|
2010-07-30 22:44:09 +00:00
|
|
|
LineInfo* ReadLineInfo (FILE* F, struct ObjData* O);
|
2001-05-23 19:03:40 +00:00
|
|
|
/* Read a line info from a file and return it */
|
|
|
|
|
2011-01-24 22:39:07 +00:00
|
|
|
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.
|
|
|
|
*/
|
|
|
|
|
2001-05-29 07:39:46 +00:00
|
|
|
void RelocLineInfo (struct Segment* S);
|
|
|
|
/* Relocate the line info for a segment. */
|
|
|
|
|
2011-01-26 19:42:17 +00:00
|
|
|
#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 long 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 long 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
|
|
|
|
|
2001-05-23 19:03:40 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* End of lineinfo.h */
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|