mscorlib(4.0.0.0) API with additions
LambdaExpression.cs
2 using System.Diagnostics;
3 using System.Dynamic.Utils;
7 
9 {
11  [DebuggerTypeProxy(typeof(LambdaExpressionProxy))]
12  [global::__DynamicallyInvokable]
13  public abstract class LambdaExpression : Expression
14  {
15  private readonly string _name;
16 
17  private readonly Expression _body;
18 
19  private readonly ReadOnlyCollection<ParameterExpression> _parameters;
20 
21  private readonly Type _delegateType;
22 
23  private readonly bool _tailCall;
24 
27  [global::__DynamicallyInvokable]
28  public sealed override Type Type
29  {
30  [global::__DynamicallyInvokable]
31  get
32  {
33  return _delegateType;
34  }
35  }
36 
39  [global::__DynamicallyInvokable]
40  public sealed override ExpressionType NodeType
41  {
42  [global::__DynamicallyInvokable]
43  get
44  {
45  return ExpressionType.Lambda;
46  }
47  }
48 
51  [global::__DynamicallyInvokable]
53  {
54  [global::__DynamicallyInvokable]
55  get
56  {
57  return _parameters;
58  }
59  }
60 
63  [global::__DynamicallyInvokable]
64  public string Name
65  {
66  [global::__DynamicallyInvokable]
67  get
68  {
69  return _name;
70  }
71  }
72 
75  [global::__DynamicallyInvokable]
76  public Expression Body
77  {
78  [global::__DynamicallyInvokable]
79  get
80  {
81  return _body;
82  }
83  }
84 
87  [global::__DynamicallyInvokable]
88  public Type ReturnType
89  {
90  [global::__DynamicallyInvokable]
91  get
92  {
93  return Type.GetMethod("Invoke").ReturnType;
94  }
95  }
96 
99  [global::__DynamicallyInvokable]
100  public bool TailCall
101  {
102  [global::__DynamicallyInvokable]
103  get
104  {
105  return _tailCall;
106  }
107  }
108 
109  internal LambdaExpression(Type delegateType, string name, Expression body, bool tailCall, ReadOnlyCollection<ParameterExpression> parameters)
110  {
111  _name = name;
112  _body = body;
113  _parameters = parameters;
114  _delegateType = delegateType;
115  _tailCall = tailCall;
116  }
117 
120  [global::__DynamicallyInvokable]
121  public Delegate Compile()
122  {
123  return LambdaCompiler.Compile(this, null);
124  }
125 
129  public Delegate Compile(DebugInfoGenerator debugInfoGenerator)
130  {
131  ContractUtils.RequiresNotNull(debugInfoGenerator, "debugInfoGenerator");
132  return LambdaCompiler.Compile(this, debugInfoGenerator);
133  }
134 
139  public Delegate Compile(bool preferInterpretation)
140  {
141  return Compile();
142  }
143 
146  public void CompileToMethod(MethodBuilder method)
147  {
148  CompileToMethodInternal(method, null);
149  }
150 
154  public void CompileToMethod(MethodBuilder method, DebugInfoGenerator debugInfoGenerator)
155  {
156  ContractUtils.RequiresNotNull(debugInfoGenerator, "debugInfoGenerator");
157  CompileToMethodInternal(method, debugInfoGenerator);
158  }
159 
160  private void CompileToMethodInternal(MethodBuilder method, DebugInfoGenerator debugInfoGenerator)
161  {
162  ContractUtils.RequiresNotNull(method, "method");
163  ContractUtils.Requires(method.IsStatic, "method");
164  TypeBuilder left = method.DeclaringType as TypeBuilder;
165  if (left == null)
166  {
167  throw Error.MethodBuilderDoesNotHaveTypeBuilder();
168  }
169  LambdaCompiler.Compile(this, method, debugInfoGenerator);
170  }
171 
172  internal abstract LambdaExpression Accept(StackSpiller spiller);
173  }
174 }
bool TailCall
Gets the value that indicates if the lambda expression will be compiled with the tail call optimizati...
Definition: __Canon.cs:3
Delegate Compile(bool preferInterpretation)
Produces an interpreted or compiled delegate that represents the lambda expression.
Generates debug information for lambda expressions in an expression tree.
bool IsStatic
Gets a value indicating whether the method is static.
Definition: MethodBase.cs:227
Provides the base class from which the classes that represent expression tree nodes are derived....
Definition: Expression.cs:17
Defines and creates new instances of classes during run time.
Definition: TypeBuilder.cs:15
Delegate Compile(DebugInfoGenerator debugInfoGenerator)
Produces a delegate that represents the lambda expression.
Represents a delegate, which is a data structure that refers to a static method or to a class instanc...
Definition: Delegate.cs:15
Represents type declarations: class types, interface types, array types, value types,...
Definition: Type.cs:18
Type ReturnType
Gets the return type of the lambda expression.
ExpressionType
Describes the node types for the nodes of an expression tree.
MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
Searches for the specified method whose parameters match the specified argument types and modifiers,...
Definition: Type.cs:1488
Defines and represents a method (or constructor) on a dynamic class.
sealed override ExpressionType NodeType
Returns the node type of this T:System.Linq.Expressions.Expression.
override Type DeclaringType
Returns the type that declares this method.
Describes a lambda expression. This captures a block of code that is similar to a ....
string Name
Gets the name of the lambda expression.
Delegate Compile()
Produces a delegate that represents the lambda expression.
Expression Body
Gets the body of the lambda expression.
void CompileToMethod(MethodBuilder method)
Compiles the lambda into a method definition.
ReadOnlyCollection< ParameterExpression > Parameters
Gets the parameters of the lambda expression.
void CompileToMethod(MethodBuilder method, DebugInfoGenerator debugInfoGenerator)
Compiles the lambda into a method definition and custom debug information.