From 14fc5c10734066a48ba02a5225efb12685ad7291 Mon Sep 17 00:00:00 2001 From: cuz Date: Fri, 29 Aug 2003 09:16:28 +0000 Subject: [PATCH] Renamed exprhs to ExprLoad git-svn-id: svn://svn.cc65.org/cc65/trunk@2426 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/assignment.c | 8 ++--- src/cc65/expr.c | 74 ++++++++++++++++++++++--------------------- src/cc65/expr.h | 4 +-- src/cc65/locals.c | 6 ++-- src/cc65/stdfunc.c | 16 +++++----- src/cc65/stmt.c | 4 +-- src/cc65/typeconv.c | 4 +-- 7 files changed, 59 insertions(+), 57 deletions(-) diff --git a/src/cc65/assignment.c b/src/cc65/assignment.c index a6f00ac13..196e0dcd9 100644 --- a/src/cc65/assignment.c +++ b/src/cc65/assignment.c @@ -87,7 +87,7 @@ int Assignment (ExprDesc* lval) if (UseReg) { PushAddr (lval); } else { - exprhs (0, 0, lval); + ExprLoad (0, 0, lval); g_push (CF_PTR | CF_UNSIGNED, 0); } @@ -107,7 +107,7 @@ int Assignment (ExprDesc* lval) lval2.Type = stype; /* Load the value into the primary */ - exprhs (CF_FORCECHAR, k, &lval2); + ExprLoad (CF_FORCECHAR, k, &lval2); /* Store it into the new location */ Store (lval, stype); @@ -115,7 +115,7 @@ int Assignment (ExprDesc* lval) } else { /* We will use memcpy. Push the address of the rhs */ - exprhs (0, 0, &lval2); + ExprLoad (0, 0, &lval2); /* Push the address (or whatever is in ax in case of errors) */ g_push (CF_PTR | CF_UNSIGNED, 0); @@ -158,7 +158,7 @@ int Assignment (ExprDesc* lval) k = TypeConversion (&lval2, k, ltype); /* If necessary, load the value into the primary register */ - exprhs (CF_NONE, k, &lval2); + ExprLoad (CF_NONE, k, &lval2); /* Generate a store instruction */ Store (lval, 0); diff --git a/src/cc65/expr.c b/src/cc65/expr.c index a8ef6191a..feb76482d 100644 --- a/src/cc65/expr.c +++ b/src/cc65/expr.c @@ -413,8 +413,10 @@ void CheckBoolExpr (ExprDesc* lval) -void exprhs (unsigned Flags, int k, ExprDesc* Expr) -/* Put the result of an expression into the primary register */ +void ExprLoad (unsigned Flags, int k, ExprDesc* Expr) +/* Place the result of an expression into the primary register if it is not + * already there. + */ { int f; @@ -561,7 +563,7 @@ static unsigned FunctionParamList (FuncDesc* Func) /* If we don't have an argument spec, accept anything, otherwise * convert the actual argument to the type needed. - */ + */ Flags = CF_NONE; if (!Ellipsis) { /* Convert the argument to the parameter type if needed */ @@ -572,7 +574,7 @@ static unsigned FunctionParamList (FuncDesc* Func) } /* Load the value into the primary if it is not already there */ - exprhs (Flags, k, &Expr); + ExprLoad (Flags, k, &Expr); /* Use the type of the argument for the push */ Flags |= TypeOf (Expr.Type); @@ -598,7 +600,7 @@ static unsigned FunctionParamList (FuncDesc* Func) } else { /* Push the argument */ g_push (Flags, Expr.ConstVal); - } + } /* Calculate total parameter size */ ParamSize += ArgSize; @@ -664,7 +666,7 @@ static void FunctionCall (int k, ExprDesc* lval) /* Not a global or local variable, or a fastcall function. Load * the pointer into the primary and mark it as an expression. */ - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); lval->Flags |= E_MEXPR; /* Remember the code position */ @@ -714,7 +716,7 @@ static void FunctionCall (int k, ExprDesc* lval) } } else { /* Load from original location */ - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); } /* Call the function */ @@ -984,7 +986,7 @@ static int arrayref (int k, ExprDesc* lval) Mark2 = 0; /* Silence gcc */ if (!ConstBaseAddr) { /* Get a pointer to the array into the primary */ - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); /* Get the array pointer on stack. Do not push more than 16 * bit, even if this value is greater, since we cannot handle @@ -1004,7 +1006,7 @@ static int arrayref (int k, ExprDesc* lval) pop (CF_PTR); } else { /* Get an array pointer into the primary */ - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); } if (IsClassPtr (tptr1)) { @@ -1029,7 +1031,7 @@ static int arrayref (int k, ExprDesc* lval) } else { /* Pointer - load into primary and remember offset */ if ((lval->Flags & E_MEXPR) == 0 || k != 0) { - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); } lval->ConstVal = lval2.ConstVal; lval->Flags = E_MEOFFS; @@ -1063,7 +1065,7 @@ static int arrayref (int k, ExprDesc* lval) /* Array subscript is not constant. Load it into the primary */ Mark2 = GetCodePos (); - exprhs (CF_NONE, l, &lval2); + ExprLoad (CF_NONE, l, &lval2); tptr2 = lval2.Type; if (IsClassPtr (tptr1)) { @@ -1090,7 +1092,7 @@ static int arrayref (int k, ExprDesc* lval) */ if (ConstBaseAddr) { g_push (CF_INT, 0); - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); ConstBaseAddr = 0; } else { g_swap (CF_INT); @@ -1140,7 +1142,7 @@ static int arrayref (int k, ExprDesc* lval) */ SavedType = lval->Type; lval->Type = tptr1; - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); lval->Type = SavedType; /* Add the variable */ @@ -1217,7 +1219,7 @@ static int structref (int k, ExprDesc* lval) lval->ConstVal += Field->V.Offs; } else { if ((flags & E_MEXPR) == 0 || k != 0) { - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); } lval->ConstVal = Field->V.Offs; lval->Flags = E_MEOFFS; @@ -1370,7 +1372,7 @@ static void pre_incdec (ExprDesc* lval, void (*inc) (unsigned, unsigned long)) PushAddr (lval); /* Fetch the value */ - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); /* Increment value in primary */ inc (flags, val); @@ -1441,7 +1443,7 @@ static void post_incdec (ExprDesc* lval, int k, void (*inc) (unsigned, unsigned PushAddr (lval); /* Fetch the value and save it (since it's the result of the expression) */ - exprhs (CF_NONE, 1, lval); + ExprLoad (CF_NONE, 1, lval); g_save (flags | CF_FORCECHAR); /* If we have a pointer expression, increment by the size of the type */ @@ -1479,7 +1481,7 @@ static void unaryop (int tok, ExprDesc* lval) } } else { /* Value is not constant */ - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); /* Get the type of the expression */ flags = TypeOf (lval->Type); @@ -1659,7 +1661,7 @@ static int hie_internal (const GenDesc** ops, /* List of generators */ g_push (ltype | CF_CONST, lval->ConstVal); } else { /* Value not constant */ - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); Mark2 = GetCodePos (); g_push (ltype, 0); } @@ -1759,7 +1761,7 @@ static int hie_compare (const GenDesc** ops, /* List of generators */ g_push (ltype | CF_CONST, lval->ConstVal); } else { /* Value not constant */ - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); Mark2 = GetCodePos (); g_push (ltype, 0); } @@ -1921,7 +1923,7 @@ static void parseadd (int k, ExprDesc* lval) /* lhs is a constant and rhs is not constant. Load rhs into * the primary. */ - exprhs (CF_NONE, k, &lval2); + ExprLoad (CF_NONE, k, &lval2); /* Beware: The check above (for lhs) lets not only pass numeric * constants, but also constant addresses (labels), maybe even @@ -2007,7 +2009,7 @@ static void parseadd (int k, ExprDesc* lval) } else { /* Left hand side is not constant. Get the value onto the stack. */ - exprhs (CF_NONE, k, lval); /* --> primary register */ + ExprLoad (CF_NONE, k, lval); /* --> primary register */ Mark = GetCodePos (); g_push (TypeOf (lval->Type), 0); /* --> stack */ @@ -2122,7 +2124,7 @@ static void parsesub (int k, ExprDesc* lval) /* Remember the output queue position, then bring the value onto the stack */ Mark1 = GetCodePos (); - exprhs (CF_NONE, k, lval); /* --> primary register */ + ExprLoad (CF_NONE, k, lval); /* --> primary register */ Mark2 = GetCodePos (); g_push (TypeOf (lhst), 0); /* --> stack */ @@ -2454,7 +2456,7 @@ static int hieAnd (ExprDesc* lval, unsigned TrueLab, int* BoolOp) } /* Load the value */ - exprhs (CF_FORCECHAR, k, lval); + ExprLoad (CF_FORCECHAR, k, lval); /* Generate the jump */ g_falsejump (CF_NONE, lab); @@ -2470,7 +2472,7 @@ static int hieAnd (ExprDesc* lval, unsigned TrueLab, int* BoolOp) if ((lval2.Test & E_CC) == 0) { lval2.Test |= E_FORCETEST; } - exprhs (CF_FORCECHAR, k, &lval2); + ExprLoad (CF_FORCECHAR, k, &lval2); /* Do short circuit evaluation */ if (CurTok.Tok == TOK_BOOL_AND) { @@ -2519,7 +2521,7 @@ static int hieOr (ExprDesc *lval) } /* Get first expr */ - exprhs (CF_FORCECHAR, k, lval); + ExprLoad (CF_FORCECHAR, k, lval); /* For each expression jump to TrueLab if true. Beware: If we * had && operators, the jump is already in place! @@ -2543,7 +2545,7 @@ static int hieOr (ExprDesc *lval) if ((lval2.Test & E_CC) == 0) { lval2.Test |= E_FORCETEST; } - exprhs (CF_FORCECHAR, k, &lval2); + ExprLoad (CF_FORCECHAR, k, &lval2); /* If there is more to come, add shortcut boolean eval. */ g_truejump (CF_NONE, TrueLab); @@ -2588,7 +2590,7 @@ static int hieQuest (ExprDesc* lval) /* Condition codes not set, force a test */ lval->Test |= E_FORCETEST; } - exprhs (CF_NONE, k1, lval); + ExprLoad (CF_NONE, k1, lval); labf = GetLocalLabel (); g_falsejump (CF_NONE, labf); @@ -2599,7 +2601,7 @@ static int hieQuest (ExprDesc* lval) Expr2IsNULL = IsNullPtr (&Expr2); if (!IsTypeVoid (Expr2.Type)) { /* Load it into the primary */ - exprhs (CF_NONE, k2, &Expr2); + ExprLoad (CF_NONE, k2, &Expr2); Expr2.Flags = E_MEXPR; k2 = 0; } @@ -2617,7 +2619,7 @@ static int hieQuest (ExprDesc* lval) Expr3IsNULL = IsNullPtr (&Expr3); if (!IsTypeVoid (Expr3.Type)) { /* Load it into the primary */ - exprhs (CF_NONE, k3, &Expr3); + ExprLoad (CF_NONE, k3, &Expr3); Expr3.Flags = E_MEXPR; k3 = 0; } @@ -2718,7 +2720,7 @@ static void opeq (const GenDesc* Gen, ExprDesc *lval, int k) PushAddr (lval); /* Fetch the lhs into the primary register if needed */ - exprhs (CF_NONE, k, lval); + ExprLoad (CF_NONE, k, lval); /* Bring the lhs on stack */ Mark = GetCodePos (); @@ -2822,7 +2824,7 @@ static void addsubeq (const GenDesc* Gen, ExprDesc *lval, int k) lflags |= CF_CONST; } else { /* Not constant, load into the primary */ - exprhs (CF_NONE, k, &lval2); + ExprLoad (CF_NONE, k, &lval2); if (MustScale) { /* lhs is a pointer, scale rhs */ g_scale (TypeOf (lval2.Type), CheckedSizeOf (lval->Type+1)); @@ -2962,7 +2964,7 @@ int hie0 (ExprDesc *lval) int evalexpr (unsigned flags, int (*f) (ExprDesc*), ExprDesc* lval) /* Will evaluate an expression via the given function. If the result is a * constant, 0 is returned and the value is put in the lval struct. If the - * result is not constant, exprhs is called to bring the value into the + * result is not constant, ExprLoad is called to bring the value into the * primary register and 1 is returned. */ { @@ -2975,7 +2977,7 @@ int evalexpr (unsigned flags, int (*f) (ExprDesc*), ExprDesc* lval) return 0; } else { /* Not constant, load into the primary */ - exprhs (flags, k, lval); + ExprLoad (flags, k, lval); return 1; } } @@ -3011,7 +3013,7 @@ void expression1 (ExprDesc* lval) */ { InitExprDesc (lval); - exprhs (CF_NONE, expr (hie1, lval), lval); + ExprLoad (CF_NONE, expr (hie1, lval), lval); } @@ -3020,7 +3022,7 @@ void expression (ExprDesc* lval) /* Evaluate an expression and put it into the primary register */ { InitExprDesc (lval); - exprhs (CF_NONE, expr (hie0, lval), lval); + ExprLoad (CF_NONE, expr (hie0, lval), lval); } @@ -3099,7 +3101,7 @@ void Test (unsigned Label, int Invert) } /* Load the value into the primary register */ - exprhs (CF_FORCECHAR, k, &lval); + ExprLoad (CF_FORCECHAR, k, &lval); /* Generate the jump */ if (Invert) { diff --git a/src/cc65/expr.h b/src/cc65/expr.h index 3398e7c27..99a0af32d 100644 --- a/src/cc65/expr.h +++ b/src/cc65/expr.h @@ -42,7 +42,7 @@ void CheckBoolExpr (ExprDesc* lval); * if not. */ -void exprhs (unsigned flags, int k, ExprDesc *lval); +void ExprLoad (unsigned flags, int k, ExprDesc *lval); /* Put the result of an expression into the primary register */ void Store (ExprDesc* lval, const type* StoreType); @@ -57,7 +57,7 @@ int hie0 (ExprDesc *lval); int evalexpr (unsigned flags, int (*f) (ExprDesc*), ExprDesc* lval); /* Will evaluate an expression via the given function. If the result is a * constant, 0 is returned and the value is put in the lval struct. If the - * result is not constant, exprhs is called to bring the value into the + * result is not constant, ExprLoad is called to bring the value into the * primary register and 1 is returned. */ diff --git a/src/cc65/locals.c b/src/cc65/locals.c index 00d15d1bc..7b7af0479 100644 --- a/src/cc65/locals.c +++ b/src/cc65/locals.c @@ -117,7 +117,7 @@ static unsigned ParseRegisterDecl (Declaration* Decl, unsigned* SC, int Reg) k = TypeConversion (&lval, k, Decl->Type); /* Load the value into the primary */ - exprhs (CF_NONE, k, &lval); + ExprLoad (CF_NONE, k, &lval); /* Store the value into the variable */ g_putstatic (CF_REGVAR | TypeOf (Decl->Type), Reg, 0); @@ -218,7 +218,7 @@ static unsigned ParseAutoDecl (Declaration* Decl, unsigned* SC) * Otherwise pass the information to the code generator. */ if (k != 0 || lval.Flags != E_MCONST) { - exprhs (CF_NONE, k, &lval); + ExprLoad (CF_NONE, k, &lval); k = 0; } else { Flags |= CF_CONST; @@ -291,7 +291,7 @@ static unsigned ParseAutoDecl (Declaration* Decl, unsigned* SC) k = TypeConversion (&lval, k, Decl->Type); /* Load the value into the primary */ - exprhs (CF_NONE, k, &lval); + ExprLoad (CF_NONE, k, &lval); /* Store the value into the variable */ g_putstatic (TypeOf (Decl->Type), SymData, 0); diff --git a/src/cc65/stdfunc.c b/src/cc65/stdfunc.c index 40d74f692..aee2dac9d 100644 --- a/src/cc65/stdfunc.c +++ b/src/cc65/stdfunc.c @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 1998 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 1998-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 */ @@ -125,7 +125,7 @@ static unsigned ParseArg (type* Type, ExprDesc* Arg) if (k != 0 || Arg->Flags != E_MCONST) { /* Load into the primary */ - exprhs (CF_NONE, k, Arg); + ExprLoad (CF_NONE, k, Arg); k = 0; } else { @@ -194,7 +194,7 @@ static void StdFunc_memset (FuncDesc* F attribute ((unused)), */ Flags = ParseArg (Arg3Type, &Arg); if (Flags & CF_CONST) { - exprhs (CF_FORCECHAR, 0, &Arg); + ExprLoad (CF_FORCECHAR, 0, &Arg); } /* Emit the actual function call */ @@ -264,7 +264,7 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), ExprDesc Length; MakeConstIntExpr (&Length, strlen (GetLiteral (Param.ConstVal))); ResetLiteralPoolOffs (Param.ConstVal); - exprhs (CF_NONE, 0, &Length); + ExprLoad (CF_NONE, 0, &Length); goto ExitPoint; } else { CodeFlags |= CF_CONST | CF_STATIC; @@ -279,7 +279,7 @@ static void StdFunc_strlen (FuncDesc* F attribute ((unused)), } else { /* Not an array with a constant address. Load parameter into primary */ - exprhs (CF_NONE, k, &Param); + ExprLoad (CF_NONE, k, &Param); } diff --git a/src/cc65/stmt.c b/src/cc65/stmt.c index 6a18b43b3..ba20981f7 100644 --- a/src/cc65/stmt.c +++ b/src/cc65/stmt.c @@ -6,7 +6,7 @@ /* */ /* */ /* */ -/* (C) 1998-2001 Ullrich von Bassewitz */ +/* (C) 1998-2003 Ullrich von Bassewitz */ /* Wacholderweg 14 */ /* D-70597 Stuttgart */ /* EMail: uz@cc65.org */ @@ -278,7 +278,7 @@ static void ReturnStatement (void) TypeConversion (&Expr, k, F_GetReturnType (CurrentFunc)); /* Load the value into the primary */ - exprhs (CF_NONE, k, &Expr); + ExprLoad (CF_NONE, k, &Expr); } } else if (!F_HasVoidReturn (CurrentFunc) && !F_HasOldStyleIntRet (CurrentFunc)) { diff --git a/src/cc65/typeconv.c b/src/cc65/typeconv.c index 916afbfd6..612aa0213 100644 --- a/src/cc65/typeconv.c +++ b/src/cc65/typeconv.c @@ -109,7 +109,7 @@ static int DoConversion (ExprDesc* Expr, int k, type* NewType) */ if (NewSize > OldSize) { /* Load the value into the primary */ - exprhs (CF_NONE, k, Expr); + ExprLoad (CF_NONE, k, Expr); /* Emit typecast code */ g_typecast (TypeOf (NewType), TypeOf (OldType)); @@ -158,7 +158,7 @@ static int DoConversion (ExprDesc* Expr, int k, type* NewType) if (OldSize != NewSize) { /* Load the value into the primary */ - exprhs (CF_NONE, k, Expr); + ExprLoad (CF_NONE, k, Expr); /* Emit typecast code. */ g_typecast (TypeOf (NewType) | CF_FORCECHAR, TypeOf (OldType)); -- 2.39.5