Pass type of line info through the object files.

git-svn-id: svn://svn.cc65.org/cc65/trunk@4957 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2011-01-29 22:16:03 +00:00
parent 0e32325ca6
commit 299a0ed4cd
7 changed files with 48 additions and 26 deletions

View File

@@ -126,15 +126,15 @@ void InitLineInfo (void)
* generated without any input file open.
*/
UsedSlots = 2;
CurLineInfo[LI_SLOT_ASM].Type = LI_TYPE_ASM;
CurLineInfo[LI_SLOT_ASM].Type = LI_TYPE_ASM; /* Count = 0 */
CurLineInfo[LI_SLOT_ASM].Info = NewLineInfo (LI_TYPE_ASM, &DefaultPos);
CurLineInfo[LI_SLOT_EXT].Type = LI_TYPE_EXT;
CurLineInfo[LI_SLOT_EXT].Type = LI_TYPE_EXT; /* Count = 0 */
CurLineInfo[LI_SLOT_EXT].Info = 0;
}
unsigned AllocLineInfoSlot (unsigned Type)
unsigned AllocLineInfoSlot (unsigned Type, unsigned Count)
/* Allocate a line info slot of the given type and return the slot index */
{
/* Grow the array if necessary */
@@ -148,7 +148,7 @@ unsigned AllocLineInfoSlot (unsigned Type)
}
/* Array is now big enough, add the new data */
CurLineInfo[UsedSlots].Type = Type;
CurLineInfo[UsedSlots].Type = LI_MAKE_TYPE(Type, Count);
CurLineInfo[UsedSlots].Info = 0;
/* Increment the count and return the index of the new slot */
@@ -349,6 +349,10 @@ void WriteLineInfos (void)
for (I = 0; I < UsedLineInfoCount; ++I) {
/* Get a pointer to this line info */
LineInfo* LI = CollAt (&LineInfoColl, I);
/* Write the type and count of the line info */
ObjWriteVar (LI->Type);
/* Write the source file position */
ObjWritePos (&LI->Pos);
}

View File

@@ -41,6 +41,7 @@
/* common */
#include "coll.h"
#include "filepos.h"
#include "lidefs.h"
@@ -59,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_ASM = 0x0100, /* Normal assembler source */
LI_TYPE_EXT = 0x0200, /* Externally supplied line info */
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.
*/
@@ -93,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);
@@ -137,10 +126,10 @@ INLINE const FilePos* GetSourcePos (const LineInfo* LI)
INLINE unsigned GetLineInfoType (const LineInfo* LI)
/* Return the type of a line info */
{
return (LI->Type & LI_MASK_TYPE);
return LI_GET_TYPE (LI->Type);
}
#else
# define GetLineInfoType(LI) ((LI)->Type & LI_MASK_TYPE)
# define GetLineInfoType(LI) LI_GET_TYPE ((LI)->Type)
#endif
void WriteLineInfo (const Collection* LineInfos);

View File

@@ -267,7 +267,7 @@ static MacExp* NewMacExp (Macro* M)
for (I = 0; I < M->ParamCount; ++I) {
E->Params[I] = 0;
}
E->LISlot = AllocLineInfoSlot (LI_TYPE_MACRO | MacExpansions);
E->LISlot = AllocLineInfoSlot (LI_TYPE_MACRO, MacExpansions);
/* One macro expansion more */
++MacExpansions;