diff --git a/src/ca65/lineinfo.c b/src/ca65/lineinfo.c index c3808cca2..355fdfc75 100644 --- a/src/ca65/lineinfo.c +++ b/src/ca65/lineinfo.c @@ -134,7 +134,7 @@ void InitLineInfo (void) -unsigned AllocLineInfoSlot (unsigned Type, unsigned Count) +int AllocLineInfoSlot (unsigned Type, unsigned Count) /* Allocate a line info slot of the given type and return the slot index */ { /* Grow the array if necessary */ @@ -152,18 +152,18 @@ unsigned AllocLineInfoSlot (unsigned Type, unsigned Count) CurLineInfo[UsedSlots].Info = 0; /* Increment the count and return the index of the new slot */ - return UsedSlots++; + return (int) UsedSlots++; } -void FreeLineInfoSlot (unsigned Slot) +void FreeLineInfoSlot (int Slot) /* Free the line info in the given slot. Note: Alloc/Free must be used in * FIFO order. */ { /* Check the parameter */ - PRECONDITION (Slot == UsedSlots - 1); + PRECONDITION (Slot == (int) UsedSlots - 1); /* Free the last entry */ CurLineInfo[Slot].Info = 0; @@ -172,7 +172,7 @@ void FreeLineInfoSlot (unsigned Slot) -void GenLineInfo (unsigned Slot, const FilePos* Pos) +void GenLineInfo (int Slot, const FilePos* Pos) /* Generate a new line info in the given slot */ { /* Get a pointer to the slot */ @@ -190,7 +190,7 @@ void GenLineInfo (unsigned Slot, const FilePos* Pos) -void ClearLineInfo (unsigned Slot) +void ClearLineInfo (int Slot) /* Clear the line info in the given slot */ { /* Zero the pointer */ diff --git a/src/ca65/lineinfo.h b/src/ca65/lineinfo.h index 7aa4d1a2f..801a86994 100644 --- a/src/ca65/lineinfo.h +++ b/src/ca65/lineinfo.h @@ -56,6 +56,7 @@ * standard line info. It is assumed to be always there. */ enum { + LI_SLOT_INV = -1, /* Use to mark invalid slots */ LI_SLOT_ASM = 0, /* Normal assembler source */ LI_SLOT_EXT = 1, /* Externally supplied line info */ }; @@ -82,18 +83,18 @@ struct LineInfo { void InitLineInfo (void); /* Initialize the line infos */ -unsigned AllocLineInfoSlot (unsigned Type, unsigned Count); +int AllocLineInfoSlot (unsigned Type, unsigned Count); /* Allocate a line info slot of the given type and return the slot index */ -void FreeLineInfoSlot (unsigned Slot); +void FreeLineInfoSlot (int Slot); /* Free the line info in the given slot. Note: Alloc/Free must be used in * FIFO order. */ -void GenLineInfo (unsigned Slot, const FilePos* Pos); +void GenLineInfo (int Slot, const FilePos* Pos); /* Generate a new line info in the given slot */ -void ClearLineInfo (unsigned Slot); +void ClearLineInfo (int Slot); /* Clear the line info in the given slot */ void GetFullLineInfo (Collection* LineInfos, unsigned IncUsage); @@ -150,3 +151,4 @@ void WriteLineInfos (void); + diff --git a/src/ca65/macro.c b/src/ca65/macro.c index a5c86e9ad..bb5774b19 100644 --- a/src/ca65/macro.c +++ b/src/ca65/macro.c @@ -135,7 +135,7 @@ struct MacExp { unsigned ParamCount; /* Number of actual parameters */ TokNode** Params; /* List of actual parameters */ TokNode* ParamExp; /* Node for expanding parameters */ - unsigned LISlot; /* Slot for additional line infos */ + int LISlot; /* Slot for additional line infos */ }; /* Maximum number of nested macro expansions */ @@ -235,7 +235,7 @@ static void FreeIdDescList (IdDesc* ID) /* Free a complete list of IdDesc structures */ { while (ID) { - IdDesc* This = ID; + IdDesc* This = ID; ID = ID->Next; FreeIdDesc (This); } @@ -656,8 +656,8 @@ static int MacExpand (void* Data) */ if (Mac->ParamExp) { - /* Ok, use token from parameter list */ - TokSet (Mac->ParamExp, Mac->LISlot); + /* Ok, use token from parameter list, but don't use its line info */ + TokSet (Mac->ParamExp, LI_SLOT_INV); /* Set pointer to next token */ Mac->ParamExp = Mac->ParamExp->Next; diff --git a/src/ca65/toklist.c b/src/ca65/toklist.c index 44fbd7742..efd5bc105 100644 --- a/src/ca65/toklist.c +++ b/src/ca65/toklist.c @@ -82,17 +82,20 @@ void FreeTokNode (TokNode* N) -void TokSet (TokNode* N, unsigned LineInfoSlot) -/* Set the scanner token from the given token node. The given line info slot - * is used to store the position of the token fed into the scanner. +void TokSet (TokNode* N, int LineInfoSlot) +/* Set the scanner token from the given token node. If the given line info + * slot is not LI_SLOT_INV, it is used to store the position of the token fed + * into the scanner. */ { /* Set the values */ CopyToken (&CurTok, &N->T); SB_Terminate (&CurTok.SVal); - /* Set the position */ - GenLineInfo (LineInfoSlot, &CurTok.Pos); + /* Set the position if the slot is not invald */ + if (LineInfoSlot != LI_SLOT_INV) { + GenLineInfo (LineInfoSlot, &CurTok.Pos); + } } diff --git a/src/ca65/toklist.h b/src/ca65/toklist.h index 18a9c42f9..145c5f25a 100644 --- a/src/ca65/toklist.h +++ b/src/ca65/toklist.h @@ -95,9 +95,10 @@ TokNode* NewTokNode (void); void FreeTokNode (TokNode* N); /* Free the given token node */ -void TokSet (TokNode* N, unsigned LineInfoSlot); -/* Set the scanner token from the given token node. The given line info slot - * is used to store the position of the token fed into the scanner. +void TokSet (TokNode* N, int LineInfoSlot); +/* Set the scanner token from the given token node. If the given line info + * slot is not LI_SLOT_INV, it is used to store the position of the token fed + * into the scanner. */ enum TC TokCmp (const TokNode* N);