mscorlib(4.0.0.0) API with additions
BlockExpression.cs
3 using System.Diagnostics;
4 using System.Dynamic.Utils;
5 using System.Threading;
6 
8 {
10  [DebuggerTypeProxy(typeof(BlockExpressionProxy))]
11  [global::__DynamicallyInvokable]
12  public class BlockExpression : Expression
13  {
16  [global::__DynamicallyInvokable]
18  {
19  [global::__DynamicallyInvokable]
20  get
21  {
22  return GetOrMakeExpressions();
23  }
24  }
25 
28  [global::__DynamicallyInvokable]
30  {
31  [global::__DynamicallyInvokable]
32  get
33  {
34  return GetOrMakeVariables();
35  }
36  }
37 
40  [global::__DynamicallyInvokable]
41  public Expression Result
42  {
43  [global::__DynamicallyInvokable]
44  get
45  {
46  return GetExpression(ExpressionCount - 1);
47  }
48  }
49 
52  [global::__DynamicallyInvokable]
53  public sealed override ExpressionType NodeType
54  {
55  [global::__DynamicallyInvokable]
56  get
57  {
58  return ExpressionType.Block;
59  }
60  }
61 
64  [global::__DynamicallyInvokable]
65  public override Type Type
66  {
67  [global::__DynamicallyInvokable]
68  get
69  {
70  return GetExpression(ExpressionCount - 1).Type;
71  }
72  }
73 
74  internal virtual int ExpressionCount
75  {
76  get
77  {
78  throw ContractUtils.Unreachable;
79  }
80  }
81 
82  internal virtual int VariableCount => 0;
83 
84  internal BlockExpression()
85  {
86  }
87 
91  [global::__DynamicallyInvokable]
92  protected internal override Expression Accept(ExpressionVisitor visitor)
93  {
94  return visitor.VisitBlock(this);
95  }
96 
101  [global::__DynamicallyInvokable]
103  {
104  if (variables == Variables && expressions == Expressions)
105  {
106  return this;
107  }
108  return Expression.Block(Type, variables, expressions);
109  }
110 
111  internal virtual Expression GetExpression(int index)
112  {
113  throw ContractUtils.Unreachable;
114  }
115 
116  internal virtual ReadOnlyCollection<Expression> GetOrMakeExpressions()
117  {
118  throw ContractUtils.Unreachable;
119  }
120 
121  internal virtual ParameterExpression GetVariable(int index)
122  {
123  throw ContractUtils.Unreachable;
124  }
125 
126  internal virtual ReadOnlyCollection<ParameterExpression> GetOrMakeVariables()
127  {
128  return EmptyReadOnlyCollection<ParameterExpression>.Instance;
129  }
130 
131  internal virtual BlockExpression Rewrite(ReadOnlyCollection<ParameterExpression> variables, Expression[] args)
132  {
133  throw ContractUtils.Unreachable;
134  }
135 
136  internal static ReadOnlyCollection<Expression> ReturnReadOnlyExpressions(BlockExpression provider, ref object collection)
137  {
138  Expression expression = collection as Expression;
139  if (expression != null)
140  {
141  Interlocked.CompareExchange(ref collection, new ReadOnlyCollection<Expression>(new BlockExpressionList(provider, expression)), expression);
142  }
143  return (ReadOnlyCollection<Expression>)collection;
144  }
145  }
146 }
Provides the base class for a generic read-only collection.
Represents a block that contains a sequence of expressions where variables can be defined.
Definition: __Canon.cs:3
Exposes the enumerator, which supports a simple iteration over a collection of a specified type....
Definition: IEnumerable.cs:9
Provides the base class from which the classes that represent expression tree nodes are derived....
Definition: Expression.cs:17
static int CompareExchange(ref int location1, int value, int comparand)
Compares two 32-bit signed integers for equality and, if they are equal, replaces the first value.
ReadOnlyCollection< Expression > Expressions
Gets the expressions in this block.
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
ExpressionType
Describes the node types for the nodes of an expression tree.
internal override Expression Accept(ExpressionVisitor visitor)
Dispatches to the specific visit method for this node type. For example, T:System....
virtual internal Expression VisitBlock(BlockExpression node)
Visits the children of the T:System.Linq.Expressions.BlockExpression.
BlockExpression Update(IEnumerable< ParameterExpression > variables, IEnumerable< Expression > expressions)
Creates a new expression that is like this one, but using the supplied children. If all of the childr...
ReadOnlyCollection< ParameterExpression > Variables
Gets the variables defined in this block.
Expression Result
Gets the last expression in this block.
Provides atomic operations for variables that are shared by multiple threads.
Definition: Interlocked.cs:10
sealed override ExpressionType NodeType
Returns the node type of this expression. Extension nodes should return F:System.Linq....
Represents a visitor or rewriter for expression trees.