1
0
mirror of https://github.com/cc65/cc65.git synced 2025-01-12 17:30:50 +00:00

Fixed a bug in FuncStrAt. New shortcut function GenLiteral0().

git-svn-id: svn://svn.cc65.org/cc65/trunk@3605 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2005-08-30 19:40:43 +00:00
parent 98f4a339ba
commit 476e3f9acc
3 changed files with 19 additions and 9 deletions

View File

@ -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);

View File

@ -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 */
{

View File

@ -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 */