9 [DebuggerTypeProxy(typeof(BinaryExpressionProxy))]
10 [global::__DynamicallyInvokable]
19 [global::__DynamicallyInvokable]
22 [global::__DynamicallyInvokable]
25 return IsOpAssignment(NodeType);
31 [global::__DynamicallyInvokable]
34 [global::__DynamicallyInvokable]
43 [global::__DynamicallyInvokable]
46 [global::__DynamicallyInvokable]
55 [global::__DynamicallyInvokable]
58 [global::__DynamicallyInvokable]
67 [global::__DynamicallyInvokable]
70 [global::__DynamicallyInvokable]
73 return GetConversion();
80 [global::__DynamicallyInvokable]
83 [global::__DynamicallyInvokable]
90 if (_left.Type.IsNullableType())
93 if (!(method ==
null))
95 return !TypeUtils.AreEquivalent(method.GetParametersCached()[0].ParameterType.GetNonRefType(), _left.Type);
106 [global::__DynamicallyInvokable]
109 [global::__DynamicallyInvokable]
114 return Type.IsNullableType();
120 internal bool IsLiftedLogical
124 Type type = _left.Type;
125 Type type2 = _right.Type;
128 if ((nodeType ==
ExpressionType.AndAlso || nodeType ==
ExpressionType.OrElse) && TypeUtils.AreEquivalent(type2, type) && type.IsNullableType() && method !=
null)
130 return TypeUtils.AreEquivalent(method.
ReturnType, type.GetNonNullableType());
136 internal bool IsReferenceComparison
140 Type type = _left.Type;
141 Type type2 = _right.Type;
146 return !type2.IsValueType;
152 internal BinaryExpression(Expression left, Expression right)
192 [global::__DynamicallyInvokable]
199 if (IsReferenceComparison)
203 return Expression.ReferenceEqual(left, right);
205 return Expression.ReferenceNotEqual(left, right);
212 [global::__DynamicallyInvokable]
215 if (IsOpAssignment(NodeType))
217 switch (_left.NodeType)
220 return ReduceMember();
222 return ReduceIndex();
224 return ReduceVariable();
263 throw Error.InvalidOperation(
"op");
267 private Expression ReduceVariable()
269 ExpressionType binaryOpFromAssignmentOp = GetBinaryOpFromAssignmentOp(NodeType);
270 Expression expression = Expression.MakeBinary(binaryOpFromAssignmentOp, _left, _right, liftToNull:
false,
Method);
271 LambdaExpression conversion = GetConversion();
272 if (conversion !=
null)
274 expression = Expression.Invoke(conversion, expression);
276 return Expression.Assign(_left, expression);
279 private Expression ReduceMember()
281 MemberExpression memberExpression = (MemberExpression)_left;
282 if (memberExpression.Expression ==
null)
284 return ReduceVariable();
286 ParameterExpression parameterExpression = Expression.Variable(memberExpression.Expression.Type,
"temp1");
287 Expression expression = Expression.Assign(parameterExpression, memberExpression.Expression);
288 ExpressionType binaryOpFromAssignmentOp = GetBinaryOpFromAssignmentOp(NodeType);
289 Expression expression2 = Expression.MakeBinary(binaryOpFromAssignmentOp, Expression.MakeMemberAccess(parameterExpression, memberExpression.Member), _right, liftToNull:
false,
Method);
290 LambdaExpression conversion = GetConversion();
291 if (conversion !=
null)
293 expression2 = Expression.Invoke(conversion, expression2);
295 ParameterExpression parameterExpression2 = Expression.Variable(expression2.Type,
"temp2");
296 expression2 = Expression.Assign(parameterExpression2, expression2);
297 Expression expression3 = Expression.Assign(Expression.MakeMemberAccess(parameterExpression, memberExpression.Member), parameterExpression2);
298 Expression expression4 = parameterExpression2;
299 return Expression.Block(
new ParameterExpression[2]
303 }, expression, expression2, expression3, expression4);
306 private Expression ReduceIndex()
308 IndexExpression indexExpression = (IndexExpression)_left;
311 ParameterExpression parameterExpression = Expression.Variable(indexExpression.Object.Type,
"tempObj");
312 list.Add(parameterExpression);
313 list2.
Add(Expression.Assign(parameterExpression, indexExpression.Object));
315 foreach (Expression argument
in indexExpression.Arguments)
317 ParameterExpression parameterExpression2 = Expression.Variable(argument.Type,
"tempArg" + list3.
Count);
318 list.Add(parameterExpression2);
319 list3.
Add(parameterExpression2);
320 list2.
Add(Expression.Assign(parameterExpression2, argument));
322 IndexExpression left = Expression.MakeIndex(parameterExpression, indexExpression.Indexer, list3);
323 ExpressionType binaryOpFromAssignmentOp = GetBinaryOpFromAssignmentOp(NodeType);
324 Expression expression = Expression.MakeBinary(binaryOpFromAssignmentOp, left, _right, liftToNull:
false,
Method);
325 LambdaExpression conversion = GetConversion();
326 if (conversion !=
null)
328 expression = Expression.Invoke(conversion, expression);
330 ParameterExpression parameterExpression3 = Expression.Variable(expression.Type,
"tempValue");
331 list.Add(parameterExpression3);
332 list2.
Add(Expression.Assign(parameterExpression3, expression));
333 list2.
Add(Expression.Assign(left, parameterExpression3));
334 return Expression.Block(list, list2);
337 internal virtual LambdaExpression GetConversion()
345 [global::__DynamicallyInvokable]
355 return new AssignBinaryExpression(left, right);
357 if (conversion !=
null)
359 return new CoalesceConversionBinaryExpression(left, right, conversion);
363 return new MethodBinaryExpression(nodeType, left, right, type, method);
365 if (type == typeof(
bool))
367 return new LogicalBinaryExpression(nodeType, left, right);
369 return new SimpleBinaryExpression(nodeType, left, right, type);
372 internal Expression ReduceUserdefinedLifted()
374 ParameterExpression parameterExpression = Expression.Parameter(_left.Type,
"left");
375 ParameterExpression parameterExpression2 = Expression.Parameter(
Right.Type,
"right");
376 string name = (NodeType ==
ExpressionType.AndAlso) ?
"op_False" :
"op_True";
378 return Expression.Block(
new ParameterExpression[1]
381 }, Expression.Assign(parameterExpression, _left), Expression.Condition(Expression.Property(parameterExpression,
"HasValue"), Expression.Condition(Expression.Call(booleanOperator, Expression.Call(parameterExpression,
"GetValueOrDefault",
null)), parameterExpression, Expression.Block(
new ParameterExpression[1]
384 }, Expression.Assign(parameterExpression2, _right), Expression.Condition(Expression.Property(parameterExpression2,
"HasValue"), Expression.Convert(Expression.Call(
Method, Expression.Call(parameterExpression,
"GetValueOrDefault",
null), Expression.Call(parameterExpression2,
"GetValueOrDefault",
null)), Type), Expression.Constant(
null, Type)))), Expression.Constant(
null, Type)));
Expression Right
Gets the right operand of the binary operation.
int Count
Gets the number of elements contained in the T:System.Collections.Generic.List`1.
Discovers the attributes of a method and provides access to method metadata.
virtual Type ReturnType
Gets the return type of this method.
BinaryExpression Update(Expression left, LambdaExpression conversion, Expression right)
Creates a new expression that is like this one, but using the supplied children. If all of the childr...
bool IsLiftedToNull
Gets a value that indicates whether the expression tree node represents a lifted call to an operator ...
void Add(T item)
Adds an object to the end of the T:System.Collections.Generic.List`1.
Provides the base class from which the classes that represent expression tree nodes are derived....
bool IsLifted
Gets a value that indicates whether the expression tree node represents a lifted call to an operator.
MethodInfo Method
Gets the implementing method for the binary operation.
LambdaExpression Conversion
Gets the type conversion function that is used by a coalescing or compound assignment operation.
Represents type declarations: class types, interface types, array types, value types,...
Type DeclaringType
Provides COM objects with version-independent access to the P:System.Reflection.MemberInfo....
ExpressionType
Describes the node types for the nodes of an expression tree.
virtual internal Expression VisitBinary(BinaryExpression node)
Visits the children of the T:System.Linq.Expressions.BinaryExpression.
internal override Expression Accept(ExpressionVisitor visitor)
Dispatches to the specific visit method for this node type. For example, T:System....
Represents a strongly typed list of objects that can be accessed by index. Provides methods to search...
override Expression Reduce()
Reduces the binary expression node to a simpler expression.
override bool CanReduce
Gets a value that indicates whether the expression tree node can be reduced.
Describes a lambda expression. This captures a block of code that is similar to a ....
Represents an expression that has a binary operator.
Expression Left
Gets the left operand of the binary operation.
Represents a visitor or rewriter for expression trees.