/* */
/* */
/* */
-/* (C) 2003 Ullrich von Bassewitz */
-/* Römerstrasse 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 2003-2009, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* common */
-#include "assertdefs.h"
+#include "assertion.h"
#include "coll.h"
#include "xmalloc.h"
+/* Assertion struct decl */
+struct Assertion {
+ FilePos Pos; /* File position of assertion */
+ ExprNode* Expr; /* Expression to evaluate */
+ AssertAction Action; /* What to do */
+ unsigned Msg; /* Message to print */
+ ObjData* Obj; /* Object file containing the assertion */
+};
+
/* List with all assertions */
static Collection Assertions = STATIC_COLLECTION_INITIALIZER;
/* Read the fields from the file */
A->Expr = ReadExpr (F, O);
- A->Action = ReadVar (F);
+ A->Action = (AssertAction) ReadVar (F);
A->Msg = MakeGlobalStringId (O, ReadVar (F));
ReadFilePos (F, &A->Pos);
/* Get the assertion */
Assertion* A = CollAtUnchecked (&Assertions, I);
+ /* Ignore assertions that shouldn't be handled at link time */
+ if (!AssertAtLinkTime (A->Action)) {
+ continue;
+ }
+
/* If the expression is not constant, we're not able to handle it */
if (!IsConstExpr (A->Expr)) {
Warning ("Cannot evaluate assertion in module `%s', line %lu",
switch (A->Action) {
case ASSERT_ACT_WARN:
+ case ASSERT_ACT_LDWARN:
Warning ("%s(%lu): %s", Module, A->Pos.Line, Message);
break;
case ASSERT_ACT_ERROR:
+ case ASSERT_ACT_LDERROR:
Error ("%s(%lu): %s", Module, A->Pos.Line, Message);
break;