Fixed a problem in line info generation: Recorded token lists emitted the

tokens using the standard ASM line info, overwriting the existing one from the
real source line. Since this info was lost, and couldn't be recovered, the
original source location was omitted in error messages.


git-svn-id: svn://svn.cc65.org/cc65/trunk@5905 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2012-11-04 12:57:34 +00:00
parent 0b5c667cd9
commit 4a41865898
4 changed files with 80 additions and 37 deletions

View File

@@ -6,7 +6,7 @@
/* */
/* */
/* */
/* (C) 1998-2011, Ullrich von Bassewitz */
/* (C) 1998-2012, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
@@ -49,6 +49,17 @@
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Number of currently pushed token lists */
static unsigned PushCounter = 0;
/*****************************************************************************/
/* Code */
/*****************************************************************************/
@@ -117,9 +128,12 @@ enum TC TokCmp (const TokNode* N)
void InitTokList (TokList* T)
/* Initialize a token list structure for later use */
TokList* NewTokList (void)
/* Create a new, empty token list */
{
/* Allocate memory for the list structure */
TokList* T = xmalloc (sizeof (TokList));
/* Initialize the fields */
T->Next = 0;
T->Root = 0;
@@ -129,18 +143,7 @@ void InitTokList (TokList* T)
T->Count = 0;
T->Check = 0;
T->Data = 0;
}
TokList* NewTokList (void)
/* Create a new, empty token list */
{
/* Allocate memory for the list structure */
TokList* T = xmalloc (sizeof (TokList));
/* Initialize the fields */
InitTokList (T);
T->LI = 0;
/* Return the new list */
return T;
@@ -159,6 +162,11 @@ void FreeTokList (TokList* List)
FreeTokNode (Tmp);
}
/* Free associated line info */
if (List->LI) {
EndLine (List->LI);
}
/* If we have associated data, free it */
if (List->Data) {
xfree (List->Data);
@@ -215,14 +223,30 @@ static int ReplayTokList (void* List)
/* Cast the generic pointer to an actual list */
TokList* L = List;
/* Last may never be a NULL pointer, otherwise there's a bug in the code */
CHECK (L->Last != 0);
/* If there are no more tokens, decrement the repeat counter. If it goes
* zero, delete the list and remove the function from the stack.
*/
if (L->Last == 0) {
if (++L->RepCount >= L->RepMax) {
/* Done with this list */
FreeTokList (L);
--PushCounter;
PopInput ();
return 0;
} else {
/* Replay one more time */
L->Last = L->Root;
}
}
/* Set the next token from the list */
TokSet (L->Last);
/* Set the line info for the new token */
NewAsmLine ();
if (L->LI) {
EndLine (L->LI);
}
L->LI = StartLine (&CurTok.Pos, LI_TYPE_ASM, PushCounter);
/* If a check function is defined, call it, so it may look at the token
* just set and changed it as apropriate.
@@ -234,20 +258,6 @@ static int ReplayTokList (void* List)
/* Set the pointer to the next token */
L->Last = L->Last->Next;
/* If this was the last token, decrement the repeat counter. If it goes
* zero, delete the list and remove the function from the stack.
*/
if (L->Last == 0) {
if (++L->RepCount >= L->RepMax) {
/* Done with this list */
FreeTokList (L);
PopInput ();
} else {
/* Replay one more time */
L->Last = L->Root;
}
}
/* We have a token */
return 1;
}
@@ -270,6 +280,7 @@ void PushTokList (TokList* List, const char* Desc)
List->Last = List->Root;
/* Insert the list specifying our input function */
++PushCounter;
PushInput (ReplayTokList, List, Desc);
}