#include "global.h"
#include "instr.h"
#include "istack.h"
+#include "lineinfo.h"
#include "nexttok.h"
#include "pseudo.h"
#include "toklist.h"
/* Structs that holds data for a macro expansion */
typedef struct MacExp MacExp;
struct MacExp {
- MacExp* Next; /* Pointer to next expansion */
- Macro* M; /* Which macro do we expand? */
- unsigned IfSP; /* .IF stack pointer at start of expansion */
+ MacExp* Next; /* Pointer to next expansion */
+ Macro* M; /* Which macro do we expand? */
+ unsigned IfSP; /* .IF stack pointer at start of expansion */
TokNode* Exp; /* Pointer to current token */
- TokNode* Final; /* Pointer to final token */
+ TokNode* Final; /* Pointer to final token */
unsigned LocalStart; /* Start of counter for local symbol names */
- unsigned ParamCount; /* Number of actual parameters */
- TokNode** Params; /* List of actual parameters */
- TokNode* ParamExp; /* Node for expanding parameters */
+ 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 */
};
/* Number of active macro expansions */
/* Initialize the data */
E->M = M;
- E->IfSP = GetIfStack ();
+ E->IfSP = GetIfStack ();
E->Exp = M->TokRoot;
- E->Final = 0;
+ E->Final = 0;
E->LocalStart = LocalName;
LocalName += M->LocalCount;
E->ParamCount = 0;
E->Params = xmalloc (M->ParamCount * sizeof (TokNode*));
E->ParamExp = 0;
for (I = 0; I < M->ParamCount; ++I) {
- E->Params [I] = 0;
+ E->Params[I] = 0;
}
+ E->LISlot = AllocLineInfoSlot (LI_TYPE_MACRO | MacExpansions);
/* One macro expansion more */
++MacExpansions;
}
xfree (E->Params);
+ /* Free the additional line info slot */
+ FreeLineInfoSlot (E->LISlot);
+
/* Free the final token if we have one */
if (E->Final) {
FreeTokNode (E->Final);
if (Mac->ParamExp) {
/* Ok, use token from parameter list */
- TokSet (Mac->ParamExp);
+ TokSet (Mac->ParamExp, Mac->LISlot);
/* Set pointer to next token */
Mac->ParamExp = Mac->ParamExp->Next;
if (Mac->Exp) {
/* Use next macro token */
- TokSet (Mac->Exp);
+ TokSet (Mac->Exp, Mac->LISlot);
/* Set pointer to next token */
Mac->Exp = Mac->Exp->Next;
if (Mac->Final) {
/* Set the final token and remove it */
- TokSet (Mac->Final);
+ TokSet (Mac->Final, Mac->LISlot);
FreeTokNode (Mac->Final);
Mac->Final = 0;
/* ca65 */
#include "error.h"
#include "istack.h"
+#include "lineinfo.h"
#include "nexttok.h"
#include "scanner.h"
#include "toklist.h"
-void TokSet (TokNode* N)
-/* Set the scanner token from 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.
+ */
{
/* Set the values */
CopyToken (&CurTok, &N->T);
SB_Terminate (&CurTok.SVal);
+
+ /* Set the position */
+ GenLineInfo (LineInfoSlot, &CurTok.Pos);
}
CHECK (L->Last != 0);
/* Set the next token from the list */
- TokSet (L->Last);
+ TokSet (L->Last, LI_SLOT_ASM);
/* If a check function is defined, call it, so it may look at the token
* just set and changed it as apropriate.
/*****************************************************************************/
/* Data */
/*****************************************************************************/
-
+
/* Struct holding a token */
void FreeTokNode (TokNode* N);
/* Free the given token node */
-void TokSet (TokNode* N);
-/* Set the scanner token from 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.
+ */
enum TC TokCmp (const TokNode* N);
/* Compare the token given as parameter against the current token */