/// <summary> /// Compiler entry point /// </summary> /// <param name="lambda">LambdaExpression to compile.</param> /// <returns>The compiled delegate.</returns> internal static Delegate Compile(LambdaExpression lambda) { // 1. Bind lambda AnalyzedTree tree = AnalyzeLambda(ref lambda); // 2. Create lambda compiler LambdaCompiler c = new LambdaCompiler(tree, lambda); // 3. Emit c.EmitLambdaBody(); // 4. Return the delegate. return(c.CreateDelegate()); }
/// <summary> /// Compiler entry point /// </summary> /// <param name="lambda">LambdaExpression to compile.</param> /// <returns>The compiled delegate.</returns> internal static Delegate Compile(LambdaExpression lambda) { lambda.ValidateArgumentCount(); // 1. Bind lambda var tree = AnalyzeLambda(ref lambda); // 2. Create lambda compiler var c = new LambdaCompiler(tree, lambda); // 3. Emit c.EmitLambdaBody(); // 4. Return the delegate. return(c.CreateDelegate()); }
/// <summary> /// Compiler entry point /// </summary> /// <param name="lambda">LambdaExpression to compile.</param> /// <param name="debugInfoGenerator">Debugging information generator used by the compiler to mark sequence points and annotate local variables.</param> /// <returns>The compiled delegate.</returns> internal static Delegate Compile(LambdaExpression lambda, DebugInfoGenerator debugInfoGenerator) { lambda.ValidateArgumentCount(); // 1. Bind lambda AnalyzedTree tree = AnalyzeLambda(ref lambda); // 2. Create lambda compiler LambdaCompiler c = new LambdaCompiler(tree, lambda, debugInfoGenerator); // 3. Emit c.EmitLambdaBody(); // 4. Return the delegate. return(c.CreateDelegate()); }
/// <summary> /// Compiler entry point /// </summary> /// <param name="lambda">LambdaExpression to compile.</param> /// <param name="method">Product of compilation</param> /// <param name="delegateType">Type of the delegate to create</param> /// <param name="emitDebugSymbols">True to emit debug symbols, false otherwise.</param> /// <param name="forceDynamic">Force dynamic method regardless of save assemblies.</param> /// <returns>The compiled delegate.</returns> internal static Delegate CompileLambda(LambdaExpression lambda, Type delegateType, bool emitDebugSymbols, bool forceDynamic, out MethodInfo method) { // 1. Create signature List <Type> types; List <string> names; string name; Type returnType; ComputeSignature(lambda, out types, out names, out name, out returnType); // 2. Bind lambda AnalyzedTree tree = AnalyzeLambda(ref lambda); // 3. Create lambda compiler LambdaCompiler c = CreateDynamicCompiler(tree, lambda, name, returnType, types, null, emitDebugSymbols, forceDynamic); // 4. Emit c.EmitLambdaBody(null); // 5. Return the delegate. return(c.CreateDelegate(delegateType, out method)); }