9 [DebuggerTypeProxy(typeof(UnaryExpressionProxy))]
10 [global::__DynamicallyInvokable]
19 private readonly
Type _type;
23 [global::__DynamicallyInvokable]
26 [global::__DynamicallyInvokable]
35 [global::__DynamicallyInvokable]
38 [global::__DynamicallyInvokable]
47 [global::__DynamicallyInvokable]
50 [global::__DynamicallyInvokable]
59 [global::__DynamicallyInvokable]
62 [global::__DynamicallyInvokable]
72 [global::__DynamicallyInvokable]
75 [global::__DynamicallyInvokable]
82 bool flag = _operand.Type.IsNullableType();
83 bool flag2 =
Type.IsNullableType();
86 if (!flag || TypeUtils.AreEquivalent(_method.GetParametersCached()[0].ParameterType, _operand.Type))
90 return !TypeUtils.AreEquivalent(_method.ReturnType,
Type);
103 [global::__DynamicallyInvokable]
106 [global::__DynamicallyInvokable]
111 return Type.IsNullableType();
119 [global::__DynamicallyInvokable]
122 [global::__DynamicallyInvokable]
138 private bool IsPrefix
152 _operand = expression;
154 _nodeType = nodeType;
158 protected internal override Expression Accept(ExpressionVisitor visitor)
160 return visitor.VisitUnary(
this);
165 [global::__DynamicallyInvokable]
170 switch (_operand.NodeType)
173 return ReduceIndex();
175 return ReduceMember();
177 return ReduceVariable();
189 private Expression ReduceVariable()
193 return Expression.Assign(_operand, FunctionalOp(_operand));
195 ParameterExpression parameterExpression = Expression.Parameter(_operand.Type,
null);
196 return Expression.Block(
new ParameterExpression[1]
199 }, Expression.Assign(parameterExpression, _operand), Expression.Assign(_operand, FunctionalOp(parameterExpression)), parameterExpression);
202 private Expression ReduceMember()
204 MemberExpression memberExpression = (MemberExpression)_operand;
205 if (memberExpression.Expression ==
null)
207 return ReduceVariable();
209 ParameterExpression parameterExpression = Expression.Parameter(memberExpression.Expression.Type,
null);
210 BinaryExpression binaryExpression = Expression.Assign(parameterExpression, memberExpression.Expression);
211 memberExpression = Expression.MakeMemberAccess(parameterExpression, memberExpression.Member);
214 return Expression.Block(
new ParameterExpression[1]
217 }, binaryExpression, Expression.Assign(memberExpression, FunctionalOp(memberExpression)));
219 ParameterExpression parameterExpression2 = Expression.Parameter(memberExpression.Type,
null);
220 return Expression.Block(
new ParameterExpression[2]
224 }, binaryExpression, Expression.Assign(parameterExpression2, memberExpression), Expression.Assign(memberExpression, FunctionalOp(parameterExpression2)), parameterExpression2);
227 private Expression ReduceIndex()
229 bool isPrefix = IsPrefix;
230 IndexExpression indexExpression = (IndexExpression)_operand;
231 int count = indexExpression.Arguments.Count;
232 Expression[] array =
new Expression[count + (isPrefix ? 2 : 4)];
233 ParameterExpression[] array2 =
new ParameterExpression[count + (isPrefix ? 1 : 2)];
234 ParameterExpression[] array3 =
new ParameterExpression[count];
236 array2[num] = Expression.Parameter(indexExpression.Object.Type,
null);
237 array[num] = Expression.Assign(array2[num], indexExpression.Object);
238 for (num++; num <= count; num++)
240 Expression expression = indexExpression.Arguments[num - 1];
241 array3[num - 1] = (array2[num] = Expression.Parameter(expression.Type,
null));
242 array[num] = Expression.Assign(array2[num], expression);
244 indexExpression = Expression.MakeIndex(array2[0], indexExpression.Indexer,
new TrueReadOnlyCollection<Expression>(array3));
247 ParameterExpression parameterExpression = array2[num] = Expression.Parameter(indexExpression.Type,
null);
248 array[num] = Expression.Assign(array2[num], indexExpression);
250 array[num++] = Expression.Assign(indexExpression, FunctionalOp(parameterExpression));
251 array[num++] = parameterExpression;
255 array[num++] = Expression.Assign(indexExpression, FunctionalOp(indexExpression));
257 return Expression.Block(
new TrueReadOnlyCollection<ParameterExpression>(array2),
new TrueReadOnlyCollection<Expression>(array));
263 [global::__DynamicallyInvokable]
sealed override Type Type
Gets the static type of the expression that this T:System.Linq.Expressions.Expression represents.
bool IsLifted
Gets a value that indicates whether the expression tree node represents a lifted call to an operator.
Discovers the attributes of a method and provides access to method metadata.
override Expression Reduce()
Reduces the expression node to a simpler expression.
Provides the base class from which the classes that represent expression tree nodes are derived....
Represents type declarations: class types, interface types, array types, value types,...
ExpressionType
Describes the node types for the nodes of an expression tree.
MethodInfo Method
Gets the implementing method for the unary operation.
UnaryExpression Update(Expression operand)
Creates a new expression that is like this one, but using the supplied children. If all of the childr...
Represents an expression that has a unary operator.
bool IsLiftedToNull
Gets a value that indicates whether the expression tree node represents a lifted call to an operator ...
Expression Operand
Gets the operand of the unary operation.
sealed override ExpressionType NodeType
Returns the node type of this T:System.Linq.Expressions.Expression.
override bool CanReduce
Gets a value that indicates whether the expression tree node can be reduced.