public Func <TReturn> Compile <TReturn>(string formula) { var definition = new LambdaTypeDefinition { ReturnedType = typeof(TReturn) }; return(CompileToExpression <Func <TReturn> >(formula, definition) .Compile()); }
public Func <TReturn> Compile <TReturn>(string formula) { var definition = new LambdaTypeDefinition { ReturnedType = typeof(TReturn) }; var compileToExpression = CompileToExpression <Func <TReturn> >(formula, definition); return(compileToExpression != null?compileToExpression.Compile() : null); }
internal Expression <T> CompileToExpression <T>(string formula, LambdaTypeDefinition definition) { BuildInfo.Clear(); var tree = Parse(formula); if (tree == null) { return(null); } return(_translator.Translate <T>(tree, definition, CallProvider, BuildInfo)); }
public Expression <T> Translate <T>(CommonTree lambdaTree, LambdaTypeDefinition definition, ICallProvider callProvider, BuildInfo buildInfo) { CallProvider = callProvider ?? EmptyCallProvider.Empty; Definition = definition; BuildInfo = buildInfo; // Prepare params Parameters = definition.Params.Select( p => Expression.Parameter(p.ParamType, p.Name)).ToList(); // Prepare this param if (definition.ThisType != null) { var thisParam = Expression.Parameter(definition.ThisType, "this"); This = thisParam; Parameters.Insert(0, thisParam); } else { This = null; } Expression <T> expression = null; try { expression = TranslateInternal <T>(lambdaTree); } catch (FormulaCompilerException e) { BuildInfo.Log(e.Message, FormulaCompilerBuildInfoLevels.Error); } return(expression); }
internal CompilableLambda(LambdaTypeDefinition definition, FormulaCompiler compiler) { Definition = definition; Compiler = compiler; }