From cdedb311997c2da932368177aa824195c8fceae0 Mon Sep 17 00:00:00 2001 From: cuz Date: Fri, 6 Jun 2003 21:09:36 +0000 Subject: [PATCH] Assertion checks were the wrong way round git-svn-id: svn://svn.cc65.org/cc65/trunk@2205 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/expr.c | 66 +++++++++++++++++++++++------------------------ src/ca65/expr.h | 18 ++++++------- src/ca65/instr.c | 8 +++--- src/ca65/main.c | 4 +-- src/ca65/pseudo.c | 8 +++--- src/ca65/ulabel.c | 18 ++++++------- 6 files changed, 61 insertions(+), 61 deletions(-) diff --git a/src/ca65/expr.c b/src/ca65/expr.c index af26c0dfe..f55dc5d56 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -512,7 +512,7 @@ static ExprNode* Function (int (*F) (void)) if (Tok != TOK_LPAREN) { Error (ERR_LPAREN_EXPECTED); SkipUntilSep (); - return LiteralExpr (0); + return GenLiteralExpr (0); } NextTok (); @@ -523,7 +523,7 @@ static ExprNode* Function (int (*F) (void)) ConsumeRParen (); /* Return an expression node with the boolean code */ - return LiteralExpr (Result); + return GenLiteralExpr (Result); } @@ -536,12 +536,12 @@ static ExprNode* Factor (void) switch (Tok) { case TOK_INTCON: - N = LiteralExpr (IVal); + N = GenLiteralExpr (IVal); NextTok (); break; case TOK_CHARCON: - N = LiteralExpr (TgtTranslateChar (IVal)); + N = GenLiteralExpr (TgtTranslateChar (IVal)); NextTok (); break; @@ -549,12 +549,12 @@ static ExprNode* Factor (void) NextTok (); if (Tok != TOK_IDENT) { Error (ERR_IDENT_EXPECTED); - N = LiteralExpr (0); /* Dummy */ + N = GenLiteralExpr (0); /* Dummy */ } else { S = SymRef (SVal, SCOPE_GLOBAL); if (SymIsConst (S)) { /* Use the literal value instead */ - N = LiteralExpr (GetSymVal (S)); + N = GenLiteralExpr (GetSymVal (S)); } else { /* Create symbol node */ N = NewExprNode (); @@ -569,7 +569,7 @@ static ExprNode* Factor (void) S = SymRef (SVal, SCOPE_LOCAL); if (SymIsConst (S)) { /* Use the literal value instead */ - N = LiteralExpr (GetSymVal (S)); + N = GenLiteralExpr (GetSymVal (S)); } else { /* Create symbol node */ N = NewExprNode (); @@ -601,7 +601,7 @@ static ExprNode* Factor (void) case TOK_STAR: case TOK_PC: NextTok (); - N = CurrentPC (); + N = GenCurrentPC (); break; case TOK_LT: @@ -633,7 +633,7 @@ static ExprNode* Factor (void) break; case TOK_CPU: - N = LiteralExpr (GetCPU()); + N = GenLiteralExpr (GetCPU()); NextTok (); break; @@ -662,7 +662,7 @@ static ExprNode* Factor (void) break; case TOK_TIME: - N = LiteralExpr (time (0)); + N = GenLiteralExpr (time (0)); NextTok (); break; @@ -673,9 +673,9 @@ static ExprNode* Factor (void) default: if (LooseCharTerm && Tok == TOK_STRCON && strlen(SVal) == 1) { /* A character constant */ - N = LiteralExpr (TgtTranslateChar (SVal[0])); + N = GenLiteralExpr (TgtTranslateChar (SVal[0])); } else { - N = LiteralExpr (0); /* Dummy */ + N = GenLiteralExpr (0); /* Dummy */ Error (ERR_SYNTAX); } NextTok (); @@ -963,7 +963,7 @@ void FreeExpr (ExprNode* Root) -ExprNode* LiteralExpr (long Val) +ExprNode* GenLiteralExpr (long Val) /* Return an expression tree that encodes the given literal value */ { ExprNode* Expr = NewExprNode (); @@ -974,7 +974,7 @@ ExprNode* LiteralExpr (long Val) -ExprNode* CurrentPC (void) +ExprNode* GenCurrentPC (void) /* Return the current program counter as expression */ { ExprNode* Left; @@ -988,11 +988,11 @@ ExprNode* CurrentPC (void) Root = NewExprNode (); Root->Left = Left; - Root->Right = LiteralExpr (GetPC ()); + Root->Right = GenLiteralExpr (GetPC ()); Root->Op = EXPR_PLUS; } else { - /* Absolute mode, just return PC value */ - Root = LiteralExpr (GetPC ()); + /* Absolute mode, just return PC value */ + Root = GenLiteralExpr (GetPC ()); } return Root; @@ -1000,7 +1000,7 @@ ExprNode* CurrentPC (void) -ExprNode* SwapExpr (ExprNode* Expr) +ExprNode* GenSwapExpr (ExprNode* Expr) /* Return an extended expression with lo and hi bytes swapped */ { ExprNode* N = NewExprNode (); @@ -1011,7 +1011,7 @@ ExprNode* SwapExpr (ExprNode* Expr) -ExprNode* BranchExpr (unsigned Offs) +ExprNode* GenBranchExpr (unsigned Offs) /* Return an expression that encodes the difference between current PC plus * offset and the target expression (that is, Expression() - (*+Offs) ). */ @@ -1028,10 +1028,10 @@ ExprNode* BranchExpr (unsigned Offs) N = NewExprNode (); N->Left = Left; - N->Right = LiteralExpr (GetPC () + Offs); + N->Right = GenLiteralExpr (GetPC () + Offs); N->Op = EXPR_PLUS; } else { - N = LiteralExpr (GetPC () + Offs); + N = GenLiteralExpr (GetPC () + Offs); } /* Create the root node */ @@ -1046,7 +1046,7 @@ ExprNode* BranchExpr (unsigned Offs) -ExprNode* ULabelExpr (unsigned Num) +ExprNode* GenULabelExpr (unsigned Num) /* Return an expression for an unnamed label with the given index */ { /* Get an expression node */ @@ -1062,7 +1062,7 @@ ExprNode* ULabelExpr (unsigned Num) -ExprNode* ForceByteExpr (ExprNode* Expr) +ExprNode* GenByteExpr (ExprNode* Expr) /* Force the given expression into a byte and return the result */ { /* Use the low byte operator to force the expression into byte size */ @@ -1076,14 +1076,14 @@ ExprNode* ForceByteExpr (ExprNode* Expr) -ExprNode* ForceWordExpr (ExprNode* Expr) +ExprNode* GenWordExpr (ExprNode* Expr) /* Force the given expression into a word and return the result. */ { /* AND the expression by $FFFF to force it into word size */ ExprNode* Root = NewExprNode (); Root->Left = Expr; Root->Op = EXPR_AND; - Root->Right = LiteralExpr (0xFFFF); + Root->Right = GenLiteralExpr (0xFFFF); /* Return the result */ return Root; @@ -1091,14 +1091,14 @@ ExprNode* ForceWordExpr (ExprNode* Expr) -ExprNode* CompareExpr (ExprNode* Expr, long Val) -/* Generate an expression that compares Expr and Val for equality */ +ExprNode* GenNE (ExprNode* Expr, long Val) +/* Generate an expression that compares Expr and Val for inequality */ { /* Generate a compare node */ ExprNode* Root = NewExprNode (); Root->Left = Expr; - Root->Op = EXPR_EQ; - Root->Right = LiteralExpr (Val); + Root->Op = EXPR_NE; + Root->Right = GenLiteralExpr (Val); /* Return the result */ return Root; @@ -1402,7 +1402,7 @@ static ExprNode* RemoveSyms (ExprNode* Expr, int MustClone) DumpExpr (Expr); } PError (GetSymPos (Sym), ERR_CIRCULAR_REFERENCE); - return LiteralExpr (0); /* Return a dummy value */ + return GenLiteralExpr (0); /* Return a dummy value */ } SymMarkUser (Sym); Expr = RemoveSyms (GetSymExpr (Sym), 1); @@ -1410,7 +1410,7 @@ static ExprNode* RemoveSyms (ExprNode* Expr, int MustClone) return Expr; } else if (SymIsConst (Expr->V.Sym)) { /* The symbol is a constant */ - return LiteralExpr (GetSymVal (Expr->V.Sym)); + return GenLiteralExpr (GetSymVal (Expr->V.Sym)); } break; @@ -1548,13 +1548,13 @@ ExprNode* FinalizeExpr (ExprNode* Expr) Expr = ConstExtract (Expr, &Val, 1); if (Expr == 0) { /* Reduced to a literal value */ - Expr = LiteralExpr (Val); + Expr = GenLiteralExpr (Val); } else if (Val) { /* Extracted a value */ N = NewExprNode (); N->Op = EXPR_PLUS; N->Left = Expr; - N->Right = LiteralExpr (Val); + N->Right = GenLiteralExpr (Val); Expr = N; } return Expr; diff --git a/src/ca65/expr.h b/src/ca65/expr.h index 7338b193e..58b787a4a 100644 --- a/src/ca65/expr.h +++ b/src/ca65/expr.h @@ -63,31 +63,31 @@ long ConstExpression (void); void FreeExpr (ExprNode* Root); /* Free the expression tree, Root is pointing to. */ -ExprNode* LiteralExpr (long Val); +ExprNode* GenLiteralExpr (long Val); /* Return an expression tree that encodes the given literal value */ -ExprNode* CurrentPC (void); +ExprNode* GenCurrentPC (void); /* Return the current program counter as expression */ -ExprNode* SwapExpr (ExprNode* Expr); +ExprNode* GenSwapExpr (ExprNode* Expr); /* Return an extended expression with lo and hi bytes swapped */ -ExprNode* BranchExpr (unsigned Offs); +ExprNode* GenBranchExpr (unsigned Offs); /* Return an expression that encodes the difference between current PC plus * offset and the target expression (that is, Expression() - (*+Offs) ). */ -ExprNode* ULabelExpr (unsigned Num); +ExprNode* GenULabelExpr (unsigned Num); /* Return an expression for an unnamed label with the given index */ -ExprNode* ForceByteExpr (ExprNode* Expr); +ExprNode* GenByteExpr (ExprNode* Expr); /* Force the given expression into a byte and return the result */ -ExprNode* ForceWordExpr (ExprNode* Expr); +ExprNode* GenWordExpr (ExprNode* Expr); /* Force the given expression into a word and return the result. */ -ExprNode* CompareExpr (ExprNode* Expr, long Val); -/* Generate an expression that compares Expr and Val for equality */ +ExprNode* GenNE (ExprNode* Expr, long Val); +/* Generate an expression that compares Expr and Val for inequality */ int IsConstExpr (ExprNode* Root); /* Return true if the given expression is a constant expression, that is, one diff --git a/src/ca65/instr.c b/src/ca65/instr.c index c39096aed..d16d2de47 100644 --- a/src/ca65/instr.c +++ b/src/ca65/instr.c @@ -525,7 +525,7 @@ static void EmitCode (EffAddr* A) * mode, force this address into 16 bit range to allow * addressing inside a 64K segment. */ - Emit2 (A->Opcode, ForceWordExpr (A->Expr)); + Emit2 (A->Opcode, GenWordExpr (A->Expr)); } else { Emit2 (A->Opcode, A->Expr); } @@ -588,7 +588,7 @@ static long PutImmed8 (const InsDesc* Ins) static void PutPCRel8 (const InsDesc* Ins) /* Handle branches with a 8 bit distance */ { - EmitPCRel (Ins->BaseCode, BranchExpr (2), 1); + EmitPCRel (Ins->BaseCode, GenBranchExpr (2), 1); } @@ -596,7 +596,7 @@ static void PutPCRel8 (const InsDesc* Ins) static void PutPCRel16 (const InsDesc* Ins) /* Handle branches with an 16 bit distance and PER */ { - EmitPCRel (Ins->BaseCode, BranchExpr (3), 2); + EmitPCRel (Ins->BaseCode, GenBranchExpr (3), 2); } @@ -687,7 +687,7 @@ static void PutJmp (const InsDesc* Ins) * a page cross. Be sure to use a copy of the expression otherwise * things will go weird later. */ - ExprNode* E = CompareExpr (ForceByteExpr (CloneExpr (A.Expr)), 0xFF); + ExprNode* E = GenNE (GenByteExpr (CloneExpr (A.Expr)), 0xFF); /* Generate the message */ unsigned Msg = GetStringId ("\"jmp (abs)\" across page border"); diff --git a/src/ca65/main.c b/src/ca65/main.c index 1b0bdfff1..e758680c1 100644 --- a/src/ca65/main.c +++ b/src/ca65/main.c @@ -183,7 +183,7 @@ static void DefineSymbol (const char* Def) } /* Define the symbol */ - SymDef (SymName, LiteralExpr (Val), 0, 0); + SymDef (SymName, GenLiteralExpr (Val), 0, 0); } @@ -389,7 +389,7 @@ static void OneLine (void) Done = 1; } else { /* Define a label */ - SymDef (Ident, CurrentPC(), IsZPSeg(), 1); + SymDef (Ident, GenCurrentPC(), IsZPSeg(), 1); /* Skip the colon. If NoColonLabels is enabled, allow labels * without a colon if there is no whitespace before the * identifier. diff --git a/src/ca65/pseudo.c b/src/ca65/pseudo.c index 2660ef8f4..d23557948 100644 --- a/src/ca65/pseudo.c +++ b/src/ca65/pseudo.c @@ -39,7 +39,7 @@ #include #include -/* common */ +/* common */ #include "assertdefs.h" #include "bitops.h" #include "cddefs.h" @@ -246,7 +246,7 @@ static void DoAddr (void) { while (1) { if (GetCPU() == CPU_65816) { - EmitWord (ForceWordExpr (Expression ())); + EmitWord (GenWordExpr (Expression ())); } else { /* Do a range check */ EmitWord (Expression ()); @@ -588,7 +588,7 @@ static void DoDByt (void) /* Output double bytes */ { while (1) { - EmitWord (SwapExpr (Expression ())); + EmitWord (GenSwapExpr (Expression ())); if (Tok != TOK_COMMA) { break; } else { @@ -1242,7 +1242,7 @@ static void DoProc (void) { if (Tok == TOK_IDENT) { /* The new scope has a name */ - SymDef (SVal, CurrentPC (), IsZPSeg (), 1); + SymDef (SVal, GenCurrentPC (), IsZPSeg (), 1); NextTok (); } SymEnterLevel (); diff --git a/src/ca65/ulabel.c b/src/ca65/ulabel.c index 7748f23dc..c63e7e10a 100644 --- a/src/ca65/ulabel.c +++ b/src/ca65/ulabel.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2000-2003 Ullrich von Bassewitz */ +/* Römerstrasse 52 */ +/* D-70794 Filderstadt */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -137,7 +137,7 @@ ExprNode* ULabRef (int Which) /* Label does not exist */ Error (ERR_UNDEFINED_LABEL); /* We must return something valid */ - return CurrentPC(); + return GenCurrentPC(); } else { /* Return a copy of the label value */ return CloneExpr (L->Val); @@ -150,7 +150,7 @@ ExprNode* ULabRef (int Which) } /* Return an unnamed label expression */ - return ULabelExpr (LabelNum); + return GenULabelExpr (LabelNum); } } @@ -162,11 +162,11 @@ void ULabDef (void) /* Create a new label if needed, or use an existing one */ if (ULabLastDef == 0 || ULabLastDef->Next == 0) { /* The last label is also the last defined label, we need a new one */ - ULabLastDef = NewULabel (CurrentPC ()); + ULabLastDef = NewULabel (GenCurrentPC ()); } else { /* We do already have the label, but it's undefined until now */ ULabLastDef = ULabLastDef->Next; - ULabLastDef->Val = CurrentPC (); + ULabLastDef->Val = GenCurrentPC (); ULabLastDef->Pos = CurPos; } ++ULabDefCount; @@ -199,7 +199,7 @@ ExprNode* ULabResolve (unsigned Index) /* If the label is open (not defined), return some valid value */ if (L->Val == 0) { - return LiteralExpr (0); + return GenLiteralExpr (0); } else { return CloneExpr (L->Val); }