sprintf(buf1, "%s %d: Error: %s\n", curfname, curlineno, buf);
break;
case SRC_IMACRO:
- sprintf(buf1, "%s %d: Error: %s\n", curfname, cur_inobj->inobj.imacro->im_macro->lineList->lineno, buf);
+ {
+ // This is basically SetFilenameForErrorReporting() but we don't call it here
+ // as it will clobber curfname. That function is used during fixups only so
+ // it really doesn't matter at that point...
+ char * filename;
+#include <token.h>
+ FILEREC * fr;
+ uint16_t fnum = cur_inobj->inobj.imacro->im_macro->cfileno;
+ // Check for absolute top filename (this should never happen)
+ if (fnum == -1)
+ interror(8);
+ else
+ {
+ fr = filerec;
+
+ // Advance to the correct record...
+ while (fr != NULL && fnum != 0)
+ {
+ fr = fr->frec_next;
+ fnum--;
+ }
+ }
+ // Check for file # record not found (this should never happen either)
+ if (fr == NULL)
+ interror(8);
+
+ filename = fr->frec_name;
+
+ sprintf(buf1, "%s %d: Error: %s\n", filename, cur_inobj->inobj.imacro->im_macro->lineList->lineno, buf);
+ }
break;
case SRC_IREPT:
sprintf(buf1, "%s %d: Error: %s\n", curfname, cur_inobj->inobj.irept->lineno, buf);
symbol->sorder = NULL;
symbol->uid = currentUID++;
+ // Record filename the symbol is defined (for now only used by macro error reporting)
+ symbol->cfileno = cfileno;
+
// Install symbol in the symbol table
int hash = HashSymbol(name, envno);
symbol->snext = symbolTable[hash];
uint8_t * sname; // * -> Symbol's print-name
LLIST * lineList; // * -> Macro's linked list of lines
LLIST * last; // * -> end of macro linked list
+ uint16_t cfileno; // File the macro is defined in
uint32_t uid; // Symbol's unique ID
};
char * string[TOKBUFSIZE*2];// Token buffer string pointer storage
int optimizeOff; // Optimization override flag
-// File record, used to maintain a list of every include file ever visited
-#define FILEREC struct _filerec
-FILEREC
-{
- FILEREC * frec_next;
- char * frec_name;
-};
FILEREC * filerec;
FILEREC * last_fr;
uint32_t lineno; // Repeat line number (Convert this to global instead of putting it here?)
};
+// File record, used to maintain a list of every include file ever visited
+#define FILEREC struct _filerec
+FILEREC
+{
+ FILEREC * frec_next;
+ char * frec_name;
+};
+
// Exported variables
extern int lnsave;
extern uint32_t curlineno;
extern int mjump_align;
extern char * string[];
extern int optimizeOff;
+extern FILEREC * filerec;
// Exported functions
int include(int, char *);