2008-01-14 Jb Evain <jbevain@novell.com>
authorJb Evain <jbevain@gmail.com>
Mon, 14 Jan 2008 08:49:56 +0000 (08:49 -0000)
committerJb Evain <jbevain@gmail.com>
Mon, 14 Jan 2008 08:49:56 +0000 (08:49 -0000)
* Expression.cs: MakeUnary is expected to call the appropriate
factory methods.

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

mcs/class/System.Core/System.Linq.Expressions/ChangeLog
mcs/class/System.Core/System.Linq.Expressions/Expression.cs

index 6f554554dbdef71710d8d2706f4435f64b703a27..8adc94a56d649480ee2e2cc30e392764b4669b73 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-14  Jb Evain  <jbevain@novell.com>
+
+       * Expression.cs: MakeUnary is expected to call the appropriate
+       factory methods.
+
 2008-01-14  Miguel de Icaza  <miguel@novell.com>
 
        * Expression.cs (Constant, MakeBinary and consumers of it): Some
index e2ceef3f559385cdb72b8773fce134cce41e12e7..90fac0c09ea27fcdaee749c7cf5905642932049e 100644 (file)
@@ -556,35 +556,33 @@ namespace System.Linq.Expressions {
 
                public static UnaryExpression MakeUnary (ExpressionType unaryType, Expression operand, Type type)
                {
-                       return MakeUnary (unaryType, operand, null, null);
+                       return MakeUnary (unaryType, operand, type, null);
                }
 
                public static UnaryExpression MakeUnary (ExpressionType unaryType, Expression operand, Type type, MethodInfo method)
                {
-                       if (!IsUnaryOperator (unaryType))
-                               throw new ArgumentException ("Make unary expect an unary operator");
-                       if (operand == null)
-                               throw new ArgumentNullException ("operand");
-
-                       return new UnaryExpression (unaryType, operand, type != null ? type : operand.Type, method);
-               }
-
-               static bool IsUnaryOperator (ExpressionType type)
-               {
-                       switch (type) {
+                       switch (unaryType) {
                        case ExpressionType.ArrayLength:
+                               return ArrayLength (operand);
                        case ExpressionType.Convert:
+                               return Convert (operand, type, method);
                        case ExpressionType.ConvertChecked:
+                               return ConvertChecked (operand, type, method);
                        case ExpressionType.Negate:
+                               return Negate (operand, method);
                        case ExpressionType.NegateChecked:
+                               return NegateChecked (operand, method);
                        case ExpressionType.Not:
+                               return Not (operand, method);
                        case ExpressionType.Quote:
+                               return Quote (operand);
                        case ExpressionType.TypeAs:
+                               return TypeAs (operand, type);
                        case ExpressionType.UnaryPlus:
-                               return true;
+                               return UnaryPlus (operand, method);
                        }
 
-                       return false;
+                       throw new ArgumentException ("MakeUnary expect an unary operator");
                }
 
                [MonoTODO]