1
0
mirror of https://github.com/cc65/cc65.git synced 2024-12-28 06:30:16 +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:
cuz 2005-04-19 22:03:30 +00:00
parent 94b11e7a73
commit 05ab8714d2

View File

@ -384,8 +384,8 @@ static void DoAssert (void)
"ERROR"
};
int Action;
int Action;
long Val;
/* First we have the expression that has to evaluated */
ExprNode* Expr = Expression ();
@ -419,10 +419,35 @@ static void DoAssert (void)
/* Read the message */
if (Tok != TOK_STRCON) {
ErrorSkip ("String constant expected");
} else {
AddAssertion (Expr, Action, GetStringId (SVal));
NextTok ();
return;
}
/* 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 ();
}