mirror of
https://github.com/cc65/cc65.git
synced 2025-01-15 22:30:04 +00:00
Evaluate .asserts with known conditions in the assembler.
git-svn-id: svn://svn.cc65.org/cc65/trunk@3471 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
parent
94b11e7a73
commit
05ab8714d2
@ -385,7 +385,7 @@ static void DoAssert (void)
|
|||||||
};
|
};
|
||||||
|
|
||||||
int Action;
|
int Action;
|
||||||
|
long Val;
|
||||||
|
|
||||||
/* First we have the expression that has to evaluated */
|
/* First we have the expression that has to evaluated */
|
||||||
ExprNode* Expr = Expression ();
|
ExprNode* Expr = Expression ();
|
||||||
@ -419,10 +419,35 @@ static void DoAssert (void)
|
|||||||
/* Read the message */
|
/* Read the message */
|
||||||
if (Tok != TOK_STRCON) {
|
if (Tok != TOK_STRCON) {
|
||||||
ErrorSkip ("String constant expected");
|
ErrorSkip ("String constant expected");
|
||||||
} else {
|
return;
|
||||||
AddAssertion (Expr, Action, GetStringId (SVal));
|
|
||||||
NextTok ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we can evaluate the assertion now, there's no need to pass it to the
|
||||||
|
* linker.
|
||||||
|
*/
|
||||||
|
if (IsConstExpr (Expr, &Val)) {
|
||||||
|
/* We can evaluate the expression, so handle it in the assembler */
|
||||||
|
switch (Action) {
|
||||||
|
|
||||||
|
case ASSERT_ACT_WARN:
|
||||||
|
Warning (0, "%s", SVal);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case ASSERT_ACT_ERROR:
|
||||||
|
Error ("%s", SVal);
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
Internal ("Illegal assert action specifier");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
/* Cannot evaluate, add it to the object file */
|
||||||
|
AddAssertion (Expr, Action, GetStringId (SVal));
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Skip the message */
|
||||||
|
NextTok ();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user