From 476e3f9acc1376510f71a26e892b01d52e6f8241 Mon Sep 17 00:00:00 2001 From: cuz Date: Tue, 30 Aug 2005 19:40:43 +0000 Subject: [PATCH] Fixed a bug in FuncStrAt. New shortcut function GenLiteral0(). git-svn-id: svn://svn.cc65.org/cc65/trunk@3605 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/ca65/enum.c | 2 +- src/ca65/expr.c | 23 +++++++++++++++-------- src/ca65/expr.h | 3 +++ 3 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/ca65/enum.c b/src/ca65/enum.c index 0383cada1..bb88e09fd 100644 --- a/src/ca65/enum.c +++ b/src/ca65/enum.c @@ -59,7 +59,7 @@ void DoEnum (void) { /* Start at zero */ long Offs = 0; - ExprNode* BaseExpr = GenLiteralExpr (0); + ExprNode* BaseExpr = GenLiteral0 (); /* Check for a name */ int Anon = (Tok != TOK_IDENT); diff --git a/src/ca65/expr.c b/src/ca65/expr.c index daed0e69b..86729c021 100644 --- a/src/ca65/expr.c +++ b/src/ca65/expr.c @@ -443,7 +443,7 @@ static ExprNode* DoMatch (enum TC EqualityLevel) /* We may not end-of-line of end-of-file here */ if (TokIsSep (Tok)) { Error ("Unexpected end of line"); - return GenLiteralExpr (0); + return GenLiteral0 (); } /* Get a node with this token */ @@ -481,7 +481,7 @@ static ExprNode* DoMatch (enum TC EqualityLevel) /* We may not end-of-line of end-of-file here */ if (TokIsSep (Tok)) { Error ("Unexpected end of line"); - return GenLiteralExpr (0); + return GenLiteral0 (); } /* Compare the tokens if the result is not already known */ @@ -587,7 +587,7 @@ static ExprNode* FuncSizeOf (void) if (ParentScope == 0) { /* No such scope */ DoneStrBuf (&ScopeName); - return GenLiteralExpr (0); + return GenLiteral0 (); } /* If ScopeName is empty, no explicit scope was specified. We have to @@ -651,8 +651,7 @@ static ExprNode* FuncStrAt (void) if (Tok != TOK_STRCON) { Error ("String constant expected"); NextTok (); - return 0; - + return GenLiteral0 (); } /* Remember the string and skip it */ @@ -668,7 +667,7 @@ static ExprNode* FuncStrAt (void) /* Must be a valid index */ if (Index >= (long) strlen (Str)) { Error ("Range error"); - return GenLiteralExpr (0); + return GenLiteral0 (); } /* Get the char, handle as unsigned. Be sure to translate it into @@ -768,7 +767,7 @@ static ExprNode* Function (ExprNode* (*F) (void)) if (Tok != TOK_LPAREN) { Error ("'(' expected"); SkipUntilSep (); - return GenLiteralExpr (0); + return GenLiteral0 (); } NextTok (); @@ -953,7 +952,7 @@ static ExprNode* Factor (void) /* A character constant */ N = GenLiteralExpr (TgtTranslateChar (SVal[0])); } else { - N = GenLiteralExpr (0); /* Dummy */ + N = GenLiteral0 (); /* Dummy */ Error ("Syntax error"); } NextTok (); @@ -1429,6 +1428,14 @@ ExprNode* GenLiteralExpr (long Val) +ExprNode* GenLiteral0 (void) +/* Return an expression tree that encodes the the number zero */ +{ + return GenLiteralExpr (0); +} + + + ExprNode* GenSymExpr (SymEntry* Sym) /* Return an expression node that encodes the given symbol */ { diff --git a/src/ca65/expr.h b/src/ca65/expr.h index de03e19ba..4e6c7988d 100644 --- a/src/ca65/expr.h +++ b/src/ca65/expr.h @@ -79,6 +79,9 @@ ExprNode* SimplifyExpr (ExprNode* Expr, const struct ExprDesc* D); ExprNode* GenLiteralExpr (long Val); /* Return an expression tree that encodes the given literal value */ +ExprNode* GenLiteral0 (void); +/* Return an expression tree that encodes the the number zero */ + ExprNode* GenSymExpr (struct SymEntry* Sym); /* Return an expression node that encodes the given symbol */ -- 2.39.5