Author: jbevain
Date: 2008-01-30 10:05:30 -0500 (Wed, 30 Jan 2008)
New Revision: 94384
Modified:
trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs
Log:
refactoring
Modified: trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs
===================================================================
--- trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs
2008-01-30 15:01:30 UTC (rev 94383)
+++ trunk/mcs/class/System.Core/System.Linq.Expressions/Expression.cs
2008-01-30 15:05:30 UTC (rev 94384)
@@ -574,10 +574,18 @@
public static BinaryExpression AndAlso (Expression left,
Expression right, MethodInfo method)
{
- method = BinaryCoreCheck ("op_BitwiseAnd", left, right,
method);
+ method = ConditionalBinaryCheck ("op_BitwiseAnd", left,
right, method);
+
+ return MakeBoolBinary (ExpressionType.AndAlso, left,
right, false, method);
+ }
+
+ static MethodInfo ConditionalBinaryCheck (string oper,
Expression left, Expression right, MethodInfo method)
+ {
+ method = BinaryCoreCheck (oper, left, right, method);
+
if (method == null) {
if (left.Type != typeof (bool))
- throw new InvalidOperationException
("Only booleans are allowed for AndAlso");
+ throw new InvalidOperationException
("Only booleans are allowed");
} else {
// The method should have identical parameter
and return types.
@@ -585,7 +593,7 @@
throw new ArgumentException ("left,
right and return type must match");
}
- return MakeBoolBinary (ExpressionType.AndAlso, left,
right, false, method);
+ return method;
}
public static BinaryExpression OrElse (Expression left,
Expression right)
@@ -595,17 +603,8 @@
public static BinaryExpression OrElse (Expression left,
Expression right, MethodInfo method)
{
- method = BinaryCoreCheck ("op_BitwiseOr", left, right,
method);
- if (method == null) {
- if (left.Type != typeof (bool))
- throw new InvalidOperationException
("Only booleans are allowed for OrElse");
- } else {
- // The method should have identical parameter
and return types.
+ method = ConditionalBinaryCheck ("op_BitwiseOr", left,
right, method);
- if (left.Type != right.Type ||
method.ReturnType != left.Type)
- throw new ArgumentException ("left,
right and return type must match");
- }
-
return MakeBoolBinary (ExpressionType.OrElse, left,
right, false, method);
}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches