예제 #1
0
 internal Expression AutoInline(InvocationExpression expression)
 {
     this.isLocked = true;
     if (expression == null) throw new ArgumentNullException("expression");
     LambdaExpression lambda = (LambdaExpression)expression.Expression;
     ExpressionRewriter childScope = new ExpressionRewriter(this);
     var lambdaParams = lambda.Parameters;
     var invokeArgs = expression.Arguments;
     if (lambdaParams.Count != invokeArgs.Count) throw new InvalidOperationException("Lambda/invoke mismatch");
     for (int i = 0; i < lambdaParams.Count; i++)
     {
         childScope.Subst(lambdaParams[i], invokeArgs[i]);
     }
     return childScope.Apply(lambda.Body);
 }
예제 #2
0
 private ExpressionRewriter(ExpressionRewriter parent)
 {
     if (parent == null) throw new ArgumentNullException("parent");
     this.subst = new Dictionary<Expression, Expression>(parent.subst);
     this.inline = parent.inline;
 }