Started to generalize line info handling. Remove separate FilePos fields and

try to manage all and everything with LineInfos.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4914 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz
2011-01-24 22:38:22 +00:00
parent 0f9ced267e
commit 06e3152035
11 changed files with 446 additions and 141 deletions

View File

@@ -43,6 +43,7 @@
/* ca65 */
#include "error.h"
#include "filetab.h"
#include "lineinfo.h"
#include "nexttok.h"
@@ -62,6 +63,32 @@ unsigned WarningCount = 0;
/*****************************************************************************/
/* Helper functions */
/*****************************************************************************/
static int FindAsmEntry (const Collection* LineInfos)
/* Return the last entry of type LI_TYPE_ASM in the given line infos. If none
* was found, return -1.
*/
{
unsigned I = CollCount (LineInfos);
while (I > 0) {
const LineInfo* LI = CollConstAt (LineInfos, --I);
if ((LI->Type & LI_MASK_TYPE) == LI_TYPE_ASM) {
/* Found */
return (int) I;
}
}
/* Not found */
return -1;
}
/*****************************************************************************/
/* Warnings */
/*****************************************************************************/
@@ -111,6 +138,29 @@ void PWarning (const FilePos* Pos, unsigned Level, const char* Format, ...)
void LIWarning (const Collection* LineInfos, unsigned Level, const char* Format, ...)
/* Print warning message using the given line infos */
{
const LineInfo* LI;
va_list ap;
/* Search backwards in LI for the first entry of type LI_TYPE_ASM. */
int I = FindAsmEntry (LineInfos);
/* We must have such an entry */
CHECK (I >= 0);
/* Get the position for this entry */
LI = CollConstAt (LineInfos, I);
/* Output a warning for this position */
va_start (ap, Format);
WarningMsg (&LI->Pos, Level, Format, ap);
va_end (ap);
}
/*****************************************************************************/
/* Errors */
/*****************************************************************************/
@@ -157,6 +207,29 @@ void PError (const FilePos* Pos, const char* Format, ...)
void LIError (const Collection* LineInfos, const char* Format, ...)
/* Print an error message using the given line infos. */
{
const LineInfo* LI;
va_list ap;
/* Search backwards in LI for the first entry of type LI_TYPE_ASM. */
int I = FindAsmEntry (LineInfos);
/* We must have such an entry */
CHECK (I >= 0);
/* Get the position for this entry */
LI = CollConstAt (LineInfos, I);
/* Output an error for this position */
va_start (ap, Format);
ErrorMsg (&LI->Pos, Format, ap);
va_end (ap);
}
void ErrorSkip (const char* Format, ...)
/* Print an error message and skip the rest of the line */
{