Comment and indentation changes

git-svn-id: svn://svn.cc65.org/cc65/trunk@3070 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2004-06-03 11:08:50 +00:00
parent 6e34e386cb
commit 763a359114

View File

@@ -121,54 +121,50 @@ static void DoConversion (ExprDesc* Expr, const type* NewType)
ED_MakeRValExpr (Expr); ED_MakeRValExpr (Expr);
} }
} else { } else if (ED_IsLocAbs (Expr)) {
/* We have an rvalue. Check for a constant. */ /* A cast of a constant numeric value to another type. Be sure
if (ED_IsLocAbs (Expr)) { * to handle sign extension correctly.
*/
/* A cast of a constant to an integer. Be sure to handle sign /* Get the current and new size of the value */
* extension correctly. unsigned OldBits = OldSize * 8;
*/ unsigned NewBits = NewSize * 8;
/* Get the current and new size of the value */ /* Check if the new datatype will have a smaller range. If it
unsigned OldBits = OldSize * 8; * has a larger range, things are ok, since the value is
unsigned NewBits = NewSize * 8; * internally already represented by a long.
*/
if (NewBits <= OldBits) {
/* Check if the new datatype will have a smaller range. If it /* Cut the value to the new size */
* has a larger range, things are ok, since the value is Expr->Val &= (0xFFFFFFFFUL >> (32 - NewBits));
* internally already represented by a long.
*/
if (NewBits <= OldBits) {
/* Cut the value to the new size */ /* If the new type is signed, sign extend the value */
Expr->Val &= (0xFFFFFFFFUL >> (32 - NewBits)); if (!IsSignUnsigned (NewType)) {
if (Expr->Val & (0x01UL << (NewBits-1))) {
/* If the new type is signed, sign extend the value */ /* Beware: Use the safe shift routine here. */
if (!IsSignUnsigned (NewType)) { Expr->Val |= shl_l (~0UL, NewBits);
if (Expr->Val & (0x01UL << (NewBits-1))) {
/* Beware: Use the safe shift routine here. */
Expr->Val |= shl_l (~0UL, NewBits);
}
} }
} }
}
} else { } else {
/* The value is not a constant. If the sizes of the types are /* The value is not a constant. If the sizes of the types are
* not equal, add conversion code. Be sure to convert chars * not equal, add conversion code. Be sure to convert chars
* correctly. * correctly.
*/ */
if (OldSize != NewSize) { if (OldSize != NewSize) {
/* Load the value into the primary */ /* Load the value into the primary */
ExprLoad (CF_NONE, Expr); ExprLoad (CF_NONE, Expr);
/* Emit typecast code. */ /* Emit typecast code. */
g_typecast (TypeOf (NewType) | CF_FORCECHAR, TypeOf (OldType)); g_typecast (TypeOf (NewType) | CF_FORCECHAR, TypeOf (OldType));
/* Value is now a rvalue in the primary */ /* Value is now a rvalue in the primary */
ED_MakeRValExpr (Expr); ED_MakeRValExpr (Expr);
}
} }
} }