/* */
/* */
/* */
-/* (C) 2003-2005, Ullrich von Bassewitz */
-/* Römerstraße 52 */
+/* (C) 2003-2011, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* common */
-#include "assertdefs.h"
#include "coll.h"
#include "xmalloc.h"
#include "asserts.h"
#include "error.h"
#include "expr.h"
+#include "lineinfo.h"
#include "objfile.h"
-#include "scanner.h"
#include "spool.h"
/* An assertion entry */
typedef struct Assertion Assertion;
struct Assertion {
- ExprNode* Expr; /* Expression to evaluate */
- unsigned Action; /* Action to take */
- unsigned Msg; /* Message to print (if any) */
- FilePos Pos; /* File position of assertion */
+ ExprNode* Expr; /* Expression to evaluate */
+ AssertAction Action; /* Action to take */
+ unsigned Msg; /* Message to print (if any) */
+ Collection LI; /* Line infos for the assertion */
};
/* Collection with all assertions for a module */
-static Assertion* NewAssertion (ExprNode* Expr, unsigned Action, unsigned Msg)
+static Assertion* NewAssertion (ExprNode* Expr, AssertAction Action, unsigned Msg)
/* Create a new Assertion struct and return it */
{
/* Allocate memory */
A->Expr = Expr;
A->Action = Action;
A->Msg = Msg;
- A->Pos = CurPos;
+ A->LI = EmptyCollection;
+ GetFullLineInfo (&A->LI, 1);
/* Return the new struct */
return A;
-void AddAssertion (ExprNode* Expr, unsigned Action, unsigned Msg)
+void AddAssertion (ExprNode* Expr, AssertAction Action, unsigned Msg)
/* Add an assertion to the assertion table */
{
/* Add an assertion object to the table */
/* Check the assertions */
for (I = 0; I < Count; ++I) {
+ long Val;
+
/* Get the next assertion */
Assertion* A = CollAtUnchecked (&Assertions, I);
+ /* Ignore it, if it should only be evaluated by the linker */
+ if (!AssertAtAsmTime (A->Action)) {
+ continue;
+ }
+
/* Can we evaluate the expression? */
- long Val;
if (IsConstExpr (A->Expr, &Val) && Val == 0) {
/* Apply the action */
const char* Msg = GetString (A->Msg);
switch (A->Action) {
case ASSERT_ACT_WARN:
- PWarning (&A->Pos, 0, "%s", Msg);
+ LIWarning (&A->LI, 0, "%s", Msg);
break;
case ASSERT_ACT_ERROR:
- PError (&A->Pos, "%s", Msg);
+ LIError (&A->LI, "%s", Msg);
break;
default:
/* Write it to the file */
WriteExpr (A->Expr);
- ObjWriteVar (A->Action);
+ ObjWriteVar ((unsigned) A->Action);
ObjWriteVar (A->Msg);
- ObjWritePos (&A->Pos);
+ WriteLineInfo (&A->LI);
}
/* Done writing the assertions */
+