Added assertions

git-svn-id: svn://svn.cc65.org/cc65/trunk@2202 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-06-06 12:45:19 +00:00
parent 0aa75f12d6
commit bb24d025f6
29 changed files with 405 additions and 183 deletions

View File

@@ -56,15 +56,17 @@
#include "global.h"
#include "incpath.h"
#include "instr.h"
#include "ldassert.h"
#include "listing.h"
#include "macpack.h"
#include "macro.h"
#include "nexttok.h"
#include "objcode.h"
#include "options.h"
#include "repeat.h"
#include "symtab.h"
#include "pseudo.h"
#include "repeat.h"
#include "spool.h"
#include "symtab.h"
@@ -326,6 +328,55 @@ static void DoASCIIZ (void)
static void DoAssert (void)
/* Add an assertion */
{
static const char* ActionTab [] = {
"WARN", "WARNING",
"ERROR"
};
int Action;
/* First we have the expression that has to evaluated */
ExprNode* Expr = Expression ();
ConsumeComma ();
/* Action follows */
if (Tok != TOK_IDENT) {
ErrorSkip (ERR_IDENT_EXPECTED);
return;
}
Action = GetSubKey (ActionTab, sizeof (ActionTab) / sizeof (ActionTab[0]));
switch (Action) {
case 0:
case 1:
/* Warning */
break;
case 2:
/* Error */
break;
default:
Error (ERR_ILLEGAL_SEG_ATTR);
}
NextTok ();
ConsumeComma ();
/* Read the message */
if (Tok != TOK_STRCON) {
ErrorSkip (ERR_STRCON_EXPECTED);
} else {
AddAssertion (Expr, Action, GetStringId (SVal));
NextTok ();
}
}
static void DoAutoImport (void)
/* Mark unresolved symbols as imported */
{
@@ -1078,7 +1129,7 @@ static void DoMacPack (void)
/* Insert the package */
InsertMacPack (Package);
}
}
@@ -1403,11 +1454,11 @@ enum {
};
/* Control command table */
struct CtrlDesc_ {
typedef struct CtrlDesc CtrlDesc;
struct CtrlDesc {
unsigned Flags; /* Flags for this directive */
void (*Handler) (void); /* Command handler */
};
typedef struct CtrlDesc_ CtrlDesc;
#define PSEUDO_COUNT (sizeof (CtrlCmdTab) / sizeof (CtrlCmdTab [0]))
static CtrlDesc CtrlCmdTab [] = {
@@ -1416,6 +1467,7 @@ static CtrlDesc CtrlCmdTab [] = {
{ ccNone, DoAddr }, /* .ADDR */
{ ccNone, DoAlign },
{ ccNone, DoASCIIZ },
{ ccNone, DoAssert },
{ ccNone, DoAutoImport },
{ ccNone, DoUnexpected }, /* .BLANK */
{ ccNone, DoBss },