Esempio n. 1
0
        private QueryClause VisitSelectMany(MethodCallExpression node, LambdaExpression selector, LambdaExpression projector)
        {
            if (projector != selector)
            {
                Type transparentType = projector.ReturnType;

                if (transparentType.IsCompilerGenerated())
                {
                    // from {item1} in {collection1}
                    // from {item2} in {collection2}
                    ParameterExpression firstVar  = GetVariable(projector.Parameters[0]);
                    ParameterExpression secondVar = GetVariable(projector.Parameters[1]);

                    _clauses.Add(Expressive.From(firstVar, node.Arguments[0]));

                    return(Expressive.From(secondVar, selector.Body));
                }
                else
                {
                    // from {item} in {collection}
                    // select {item}
                    ParameterExpression newItem = GetVariable(projector.Parameters[1]);

                    _clauses.Add(Expressive.From(newItem, selector.Body));

                    return(Expressive.Select(projector.Body));
                }
            }
            return(null);
        }
Esempio n. 2
0
 /// <inheritdoc />
 public override Expression VisitLockStatement(ILockStatement operation, LocalBinder argument)
 {
     return(Expressive.Lock(
                operation.LockedObject.Accept(this, argument),
                operation.Body.Accept(this, argument)
                ));
 }
Esempio n. 3
0
 /// <inheritdoc />
 public override Expression VisitQueryExpression(QueryExpressionSyntax node)
 {
     return(Expressive.Query(
                Enumerable.Repeat(VisitContinuationClause(node.FromClause), 1)
                .Concat(VisitLinqBody(node.Body))
                ));
 }
Esempio n. 4
0
 /// <inheritdoc />
 public override Expression VisitUsingStatement(IUsingStatement operation, LocalBinder argument)
 {
     // TODO: Declarations in new binder
     return(Expressive.Using(
                Visit(operation.Declaration ?? operation.Value, argument),
                operation.Body.Accept(this, argument)
                ));
 }
Esempio n. 5
0
 /// <inheritdoc />
 protected override Expression Reduce(QueryClause previous, QueryClause next)
 {
     return(Expressive.ForEach(
                Variable,
                Enumerable,
                next.Reduce()
                ));
 }
Esempio n. 6
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public OrderByClause Update(IEnumerable <OrderingExpression> orderings)
        {
            if (orderings.SequenceEqual(Orderings))
            {
                return(this);
            }

            return(Expressive.OrderBy(orderings));
        }
Esempio n. 7
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public LockExpression Update(Expression obj, Expression body)
        {
            if (body == Body && obj == Object)
            {
                return(this);
            }

            return(Expressive.Lock(obj, body));
        }
Esempio n. 8
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public WhereClause Update(Expression condition)
        {
            if (Condition == condition)
            {
                return(this);
            }

            return(Expressive.Where(condition));
        }
Esempio n. 9
0
        /// <inheritdoc cref="UnaryExpression.Update(System.Linq.Expressions.Expression)" select="summary"/>
        public AwaitExpression Update(Expression task, MethodInfo method)
        {
            if (Expression == task && Equals(Method, method))
            {
                return(this);
            }

            return(Expressive.Await(task, method));
        }
Esempio n. 10
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public SelectClause Update(Expression expression)
        {
            if (Selector == expression)
            {
                return(this);
            }

            return(Expressive.Select(expression));
        }
Esempio n. 11
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public FromClause Update(ParameterExpression variable, Expression enumerable)
        {
            if (Variable == variable && Enumerable == enumerable)
            {
                return(this);
            }

            return(Expressive.From(variable, enumerable));
        }
Esempio n. 12
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public GroupByClause Update(ParameterExpression variable, Expression selector)
        {
            if (Variable == variable && Selector == selector)
            {
                return(this);
            }

            return(Expressive.GroupBy(variable, selector));
        }
Esempio n. 13
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public JoinClause Update(ParameterExpression variable, Expression enumerable, Expression left, Expression right)
        {
            if (Variable == variable && Enumerable == enumerable && Left == left && Right == right)
            {
                return(this);
            }

            return(Expressive.Join(variable, enumerable, left, right));
        }
Esempio n. 14
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public LetClause Update(ParameterExpression variable, Expression expression)
        {
            if (Variable == variable && Expression == expression)
            {
                return(this);
            }

            return(Expressive.Let(variable, expression));
        }
Esempio n. 15
0
        private QueryClause VisitWhere(MethodCallExpression node, LambdaExpression predicate)
        {
            if (_clauses.Count == 0)
            {
                _clauses.Add(Expressive.From(GetVariable(predicate.Parameters[0]), node.Arguments[0]));
            }

            return(Expressive.Where(predicate.Body));
        }
Esempio n. 16
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public ForExpression Update(ParameterExpression variable, Expression initializer, Expression test, Expression step, Expression body, LabelTarget breakTarget, LabelTarget continueTarget)
        {
            if (Variable == variable && Initializer == initializer && Test == test && Step == step && Body == body && BreakLabel == breakTarget && ContinueLabel == continueTarget)
            {
                return(this);
            }

            return(Expressive.For(variable, initializer, test, step, body, breakTarget, continueTarget));
        }
Esempio n. 17
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public ForEachExpression Update(ParameterExpression variable, Expression enumerable, Expression body, LabelTarget breakTarget, LabelTarget continueTarget)
        {
            if (this.Variable == variable && this.Enumerable == enumerable && this.Body == body && BreakLabel == breakTarget && ContinueLabel == continueTarget)
            {
                return(this);
            }

            return(Expressive.ForEach(variable, enumerable, body, breakTarget, continueTarget));
        }
Esempio n. 18
0
        private QueryClause VisitOrderBy(MethodCallExpression node, LambdaExpression lambda, bool descending)
        {
            if (_clauses.Count == 0)
            {
                _clauses.Add(Expressive.From(GetVariable(lambda.Parameters[1]), node.Arguments[0]));
            }

            return(Expressive.OrderBy(lambda.Body, !descending));
        }
Esempio n. 19
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public AsyncExpression Update(Expression body)
        {
            if (Body == body)
            {
                return(this);
            }

            return(Expressive.Async(body));
        }
Esempio n. 20
0
        /// <inheritdoc />
        public override Expression VisitWhileUntilLoopStatement(IWhileUntilLoopStatement operation, LocalBinder argument)
        {
            Expression condition = operation.Condition.Accept(this, argument);
            Expression body      = operation.Body.Accept(this, argument);

            return(operation.IsTopTest
                ? Expressive.While(condition, body) as Expression
                : Expressive.DoWhile(condition, body));
        }
Esempio n. 21
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public QueryExpression Update(params QueryClause[] clauses)
        {
            if (Clauses.SequenceEqual(clauses))
            {
                return(this);
            }

            return(Expressive.Query(clauses));
        }
Esempio n. 22
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public DoWhileExpression Update(Expression test, Expression body, LabelTarget breakTarget, LabelTarget continueTarget)
        {
            if (Test == test && Body == body && BreakLabel == breakTarget && ContinueLabel == continueTarget)
            {
                return(this);
            }

            return(Expressive.DoWhile(test, body, breakTarget, continueTarget));
        }
Esempio n. 23
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public UsingExpression Update(ParameterExpression variable, Expression disposable, Expression body)
        {
            if (Variable == variable && Disposable == disposable && Body == body)
            {
                return(this);
            }

            return(Expressive.Using(variable, disposable, body));
        }
Esempio n. 24
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public IteratorExpression Update(Expression iterator)
        {
            if (Iterator == iterator)
            {
                return(this);
            }

            return(Expressive.Iterator(iterator));
        }
Esempio n. 25
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public TypeOfExpression Update(Type type)
        {
            if (TargetType == type)
            {
                return(this);
            }

            return(Expressive.TypeOf(type));
        }
Esempio n. 26
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public WhileExpression Update(Expression test, Expression body, LabelTarget breakTarget, LabelTarget continueTarget)
        {
            if (test == Test && body == Body && breakTarget == BreakLabel && continueTarget == ContinueLabel)
            {
                return(this);
            }

            return(Expressive.While(test, body, breakTarget, continueTarget));
        }
Esempio n. 27
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public TypeExpression Update(Type type)
        {
            if (Type == type)
            {
                return(this);
            }

            return(Expressive.Type(type));
        }
Esempio n. 28
0
        /// <inheritdoc cref="UnaryExpression.Update(System.Linq.Expressions.Expression)" select="summary"/>
        public YieldExpression Update(Expression value)
        {
            if (Expression == value)
            {
                return(this);
            }

            return(Expressive.Yield(value));
        }
Esempio n. 29
0
        /// <inheritdoc cref="UnaryExpression.Update(Expression)" select="summary"/>
        public GroupByIntoClause Update(ParameterExpression variable, Expression selector, ParameterExpression group)
        {
            if (Variable == variable && Selector == selector && Group == group)
            {
                return(this);
            }

            return(Expressive.GroupBy(variable, selector, group));
        }
Esempio n. 30
0
        /// <inheritdoc />
        public override Expression VisitForEachLoopStatement(IForEachLoopStatement operation, LocalBinder argument)
        {
            ParameterExpression variable = VisitLocal(operation.IterationVariable);
            LocalBinder         binder   = argument.Child(operation.IterationVariable, variable);

            return(Expressive.ForEach(variable,
                                      operation.Collection.Accept(this, argument),
                                      operation.Body.Accept(this, binder)
                                      ));
        }