ParseFileToLambda(string filename, TextReader reader) { var asts = new Parser().ParseFile(reader); var scope = new AnalysisScope( null, filename, this, Expression.Parameter(typeof(Sympl), "symplRuntime"), Expression.Parameter(typeof(IDynamicMetaObjectProvider), "fileModule")); List <Expression> body = new List <Expression>(); foreach (var e in asts) { body.Add(ETGen.AnalyzeExpr(e, scope)); } body.Add(Expression.Constant(null)); var moduleFun = Expression.Lambda <Func <Sympl, IDynamicMetaObjectProvider, object> >( Expression.Block(body), scope.RuntimeExpr, scope.ModuleExpr); return(moduleFun); }
ParseExprToLambda(TextReader reader) { var ast = new Parser().ParseExpr(reader); var scope = new AnalysisScope( null, "__snippet__", this, Expression.Parameter(typeof(Sympl), "symplRuntime"), Expression.Parameter(typeof(IDynamicMetaObjectProvider), "fileModule")); List <Expression> body = new List <Expression>(); body.Add(Expression.Convert(ETGen.AnalyzeExpr(ast, scope), typeof(object))); var moduleFun = Expression.Lambda <Func <Sympl, IDynamicMetaObjectProvider, object> >( Expression.Block(body), scope.RuntimeExpr, scope.ModuleExpr ); return(moduleFun); }