Преглед на файлове

2003-11-21 Miguel de Icaza <[email protected]>

	* cfold.cs (DoNumericPromotions): During constant folding of
	additions on UIntConstant, special case intconstants with
	IntConstants like we do on the expression binary operator.

svn path=/trunk/mcs/; revision=20327
Miguel de Icaza преди 22 години
родител
ревизия
c8750feb3e
променени са 3 файла, в които са добавени 20 реда и са изтрити 4 реда
  1. 6 0
      mcs/mcs/ChangeLog
  2. 13 3
      mcs/mcs/cfold.cs
  3. 1 1
      mcs/mcs/expression.cs

+ 6 - 0
mcs/mcs/ChangeLog

@@ -1,3 +1,9 @@
+2003-11-21  Miguel de Icaza  <[email protected]>
+
+	* cfold.cs (DoNumericPromotions): During constant folding of
+	additions on UIntConstant, special case intconstants with
+	IntConstants like we do on the expression binary operator. 
+
 2003-11-12  Miguel de Icaza  <[email protected]>
 
 	* convert.cs (ImplicitReferenceConversion): We were missing a case

+ 13 - 3
mcs/mcs/cfold.cs

@@ -111,8 +111,18 @@ namespace Mono.CSharp {
 				if (other is UIntConstant)
 					return;
 
-				if (other is SByteConstant || other is ShortConstant ||
-				    other is IntConstant){
+				IntConstant ic = other as IntConstant;
+				if (ic != null){
+					if (ic.Value >= 0){
+						if (left == other)
+							left = new UIntConstant ((uint) ic.Value);
+						else
+							right = new UIntConstant ((uint) ic.Value);
+					}
+					return;
+				}
+				
+				if (other is SByteConstant || other is ShortConstant || ic != null){
 					left = left.ToLong (loc);
 					right = right.ToLong (loc);
 				}
@@ -180,7 +190,7 @@ namespace Mono.CSharp {
 			Type rt = right.Type;
 			Type result_type = null;
 			bool bool_res;
-			
+
 			//
 			// Enumerator folding
 			//

+ 1 - 1
mcs/mcs/expression.cs

@@ -2091,7 +2091,7 @@ namespace Mono.CSharp {
 				//
 				// If either operand is of type uint, and the other
 				// operand is of type sbyte, short or int, othe operands are
-				// converted to type long.
+				// converted to type long (unless we have an int constant).
 				//
 				Type other = null;