From 2fa9b6e5acbfea981887dd2824bc2e96e9ef6cfd Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 3 Jun 2004 12:08:49 +0000 Subject: [PATCH] Improved code generation git-svn-id: svn://svn.cc65.org/cc65/trunk@3072 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/expr.c | 16 ++++++++++------ src/cc65/exprdesc.c | 2 +- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/cc65/expr.c b/src/cc65/expr.c index 00fe4990f..18f7fece2 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -1247,7 +1247,7 @@ static void StructRef (ExprDesc* Expr) return; } - /* If we have a struct pointer that is an lvalue and not already in the + /* If we have a struct pointer that is an lvalue and not already in the * primary, load it now. */ if (ED_IsLVal (Expr) && IsTypePtr (Expr->Type)) { @@ -1676,10 +1676,14 @@ void hie10 (ExprDesc* Expr) case TOK_STAR: NextToken (); - if (evalexpr (CF_NONE, hie10, Expr) != 0) { - /* Expression is not const, indirect value loaded into primary */ - ED_MakeRValExpr (Expr); - } + ExprWithCheck (hie10, Expr); + if (ED_IsLVal (Expr) || !(ED_IsLocConst (Expr) || ED_IsLocStack (Expr)))) { + /* Not a const, load it into the primary and make it a + * calculated value. + */ + ExprLoad (CF_NONE, Expr); + ED_MakeRValExpr (Expr); + } /* If the expression is already a pointer to function, the * additional dereferencing operator must be ignored. */ @@ -1698,7 +1702,7 @@ void hie10 (ExprDesc* Expr) case TOK_AND: NextToken (); - hie10 (Expr); + ExprWithCheck (hie10, Expr); /* The & operator may be applied to any lvalue, and it may be * applied to functions, even if they're no lvalues. */ diff --git a/src/cc65/exprdesc.c b/src/cc65/exprdesc.c index 14200a9e1..cf0986bf8 100644 --- a/src/cc65/exprdesc.c +++ b/src/cc65/exprdesc.c @@ -197,7 +197,7 @@ int ED_IsConstAbs (const ExprDesc* Expr) * a numeric constant, cast to any type. */ { - return ED_IsConst (Expr) && ED_IsLocAbs (Expr); + return (Expr->Flags & (E_MASK_LOC|E_MASK_RTYPE)) == (E_LOC_ABS|E_RTYPE_RVAL); } -- 2.39.5