2002-05-07 Miguel de Icaza <miguel@ximian.com>
authorMiguel de Icaza <miguel@gnome.org>
Tue, 7 May 2002 15:36:17 +0000 (15:36 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Tue, 7 May 2002 15:36:17 +0000 (15:36 -0000)
* expression.cs (Unary.TryReduceNegative): Ah!  Tricky!  Tricky!
Because of the way we parse things, we should try to see if a
UIntConstant can fit in an integer.

svn path=/trunk/mcs/; revision=4379

mcs/mcs/ChangeLog
mcs/mcs/expression.cs

index ec1d97c456449b866e07921e42c2ea4695fedb32..57c534f522a736fb8ab1f56ecbb08c57af3a507d 100755 (executable)
@@ -1,3 +1,9 @@
+2002-05-07  Miguel de Icaza  <miguel@ximian.com>
+
+       * expression.cs (Unary.TryReduceNegative): Ah!  Tricky!  Tricky!
+       Because of the way we parse things, we should try to see if a
+       UIntConstant can fit in an integer.
+
 2002-05-07  Ravi Pratap  <ravi@ximian.com>
 
        * ecore.cs (GetConversionOperators): Do not pick up op_True operators
index 12c2a9e7e81c0b6012ad6a7d9f4bf5923a9e48c8..bec12e7399ab59f3479072e9bbe954ed65ed1b97 100755 (executable)
@@ -159,8 +159,14 @@ namespace Mono.CSharp {
                        
                        if (expr is IntConstant)
                                e = new IntConstant (-((IntConstant) expr).Value);
-                       else if (expr is UIntConstant)
-                               e = new LongConstant (-((UIntConstant) expr).Value);
+                       else if (expr is UIntConstant){
+                               uint value = ((UIntConstant) expr).Value;
+
+                               if (value < 2147483649)
+                                       return new IntConstant (-(int)value);
+                               else
+                                       e = new LongConstant (value);
+                       }
                        else if (expr is LongConstant)
                                e = new LongConstant (-((LongConstant) expr).Value);
                        else if (expr is FloatConstant)