internal void Reset(QueryContinuationSyntax node)
 {
     IsAnonymousType = false;
     IdentifiersChain.Clear();
     SourceIdentifier = node.Identifier;
     IdentifiersChain[SourceIdentifier.ValueText] = 0;
 }
Пример #2
0
        internal BoundExpression BindQuery(QueryExpressionSyntax node, DiagnosticBag diagnostics)
        {
            var fromClause          = node.FromClause;
            var boundFromExpression = BindLeftOfPotentialColorColorMemberAccess(fromClause.Expression, diagnostics);

            QueryTranslationState state = new QueryTranslationState();

            state.fromExpression = MakeMemberAccessValue(boundFromExpression, diagnostics);

            var x = state.rangeVariable = state.AddRangeVariable(this, fromClause.Identifier, diagnostics);

            for (int i = node.Body.Clauses.Count - 1; i >= 0; i--)
            {
                state.clauses.Push(node.Body.Clauses[i]);
            }

            state.selectOrGroup = node.Body.SelectOrGroup;

            // A from clause that explicitly specifies a range variable type
            //     from T x in e
            // is translated into
            //     from x in ( e ) . Cast < T > ( )
            BoundExpression cast = null;

            if (fromClause.Type != null)
            {
                var typeRestriction = BindTypeArgument(fromClause.Type, diagnostics);
                cast = MakeQueryInvocation(fromClause, state.fromExpression, "Cast", fromClause.Type, typeRestriction, diagnostics);
                state.fromExpression = cast;
            }

            state.fromExpression = MakeQueryClause(fromClause, state.fromExpression, x, castInvocation: cast);
            BoundExpression result = BindQueryInternal1(state, diagnostics);

            for (QueryContinuationSyntax continuation = node.Body.Continuation; continuation != null; continuation = continuation.Body.Continuation)
            {
                // A query expression with a continuation
                //     from ... into x ...
                // is translated into
                //     from x in ( from ... ) ...
                state.Clear();
                state.fromExpression = result;
                x = state.rangeVariable = state.AddRangeVariable(this, continuation.Identifier, diagnostics);
                Debug.Assert(state.clauses.IsEmpty());
                var clauses = continuation.Body.Clauses;
                for (int i = clauses.Count - 1; i >= 0; i--)
                {
                    state.clauses.Push(clauses[i]);
                }

                state.selectOrGroup = continuation.Body.SelectOrGroup;
                result = BindQueryInternal1(state, diagnostics);
                result = MakeQueryClause(continuation.Body, result, x);
                result = MakeQueryClause(continuation, result, x);
            }

            state.Free();
            return(MakeQueryClause(node, result));
        }
 private Doc PrintQueryContinuationSyntax(QueryContinuationSyntax node)
 {
     return(Concat(
                this.PrintSyntaxToken(node.IntoKeyword, " "),
                this.PrintSyntaxToken(node.Identifier, Line),
                this.PrintQueryBodySyntax(node.Body)
                ));
 }
Пример #4
0
 public static Doc Print(QueryContinuationSyntax node)
 {
     return(Doc.Concat(
                Token.PrintWithSuffix(node.IntoKeyword, " "),
                Token.PrintWithSuffix(node.Identifier, Doc.Line),
                QueryBody.Print(node.Body)
                ));
 }
Пример #5
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     if (_root == default(SyntaxToken) && node.IntoKeyword.ToString().Contains("into"))
     {
         _root = node.Identifier; // get the into object
         SetSearchPatterns();
     }
     base.VisitQueryContinuation(node);
 }
        public override SyntaxNode VisitQueryContinuation(QueryContinuationSyntax node)
        {
            if (!_visitQuerySyntax)
            {
                return(base.VisitQueryContinuation(node));
            }

            _state.Reset(node);
            VisitQueryBody(node.Body);
            return(node);
        }
 public override void AddChildren()
 {
     Kind                    = Node.Kind();
     _clauses                = ((QueryBodySyntax)Node).Clauses;
     _clausesIsChanged       = false;
     _clausesCount           = _clauses.Count;
     _selectOrGroup          = ((QueryBodySyntax)Node).SelectOrGroup;
     _selectOrGroupIsChanged = false;
     _continuation           = ((QueryBodySyntax)Node).Continuation;
     _continuationIsChanged  = false;
 }
Пример #8
0
        public override void VisitQueryContinuation(QueryContinuationSyntax node)
        {
            var paramInfo  = m_LinqParamInfoStack.Peek();
            var paramNames = paramInfo.ParamNames;

            paramNames.Clear();
            paramNames.Add(node.Identifier.Text);

            CodeBuilder.Append("continuation()");
            node.Body.Accept(this);
        }
Пример #9
0
        public override void VisitQueryContinuation(QueryContinuationSyntax node)
        {
            var    paramInfo  = m_LinqParamInfoStack.Peek();
            var    paramNames = paramInfo.ParamNames;
            string prestr     = paramInfo.Prestr;

            paramInfo.Prestr = ", ";
            paramNames.Clear();
            paramNames.Add(node.Identifier.Text);

            CodeBuilder.AppendFormat("{0}{{\"continuation\"}}", prestr);
            node.Body.Accept(this);
        }
Пример #10
0
        public override void VisitQueryContinuation(QueryContinuationSyntax node)
        {
            if (!PreVisit(node))
            {
                return;
            }

            node.Body?.Accept(this);

            base.VisitQueryContinuation(node);

            PostVisit(node);
        }
Пример #11
0
        public void VisitQueryContinuation(QueryContinuationSyntax node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            node.Validate();

            if (node.Identifier != null)
            {
                _writer.WriteKeyword(PrinterKeyword.Into);
                _writer.WriteSpace();
                _writer.WriteIdentifier(node.Identifier);
                _writer.WriteSpace();
            }

            node.Body.Accept(this);
        }
Пример #12
0
 public override IRangeVariableSymbol GetDeclaredSymbol(QueryContinuationSyntax node, CancellationToken cancellationToken = default(CancellationToken))
 {
     CheckSyntaxNode(node);
     var model = this.GetMemberModel(node);
     return (model == null) ? null : model.GetDeclaredSymbol(node, cancellationToken);
 }
 public IRangeVariableSymbol?ToSymbol(QueryContinuationSyntax node)
 => Model.GetDeclaredSymbol(node, CancellationToken);
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     base.VisitQueryContinuation(node);
     Add(node.Identifier);
 }
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     base.VisitQueryContinuation(node);
     Add(node.Identifier);
 }
 public override LuaSyntaxNode VisitQueryContinuation(QueryContinuationSyntax node)
 {
     throw new InvalidOperationException();
 }
Пример #17
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     map.Add(node.Identifier.ValueText, node.Identifier);
     base.VisitQueryContinuation(node);
 }
Пример #18
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     throw new NotImplementedException();
 }
Пример #19
0
 public override IRangeVariableSymbol GetDeclaredSymbol(QueryContinuationSyntax node, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (Logger.LogBlock(FunctionId.CSharp_SemanticModel_GetDeclaredSymbol, message: this.SyntaxTree.FilePath, cancellationToken: cancellationToken))
     {
         CheckSyntaxNode(node);
         var model = this.GetMemberModel(node);
         return (model == null) ? null : model.GetDeclaredSymbol(node, cancellationToken);
     }
 }
Пример #20
0
        public override Evaluation VisitQueryContinuation(QueryContinuationSyntax node)
        {
            node.Body?.Accept <Evaluation>(this);

            return(base.VisitQueryContinuation(node));
        }
Пример #21
0
        public void VisitQueryContinuation(QueryContinuationSyntax node)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            node.Validate();

            if (node.Identifier != null)
            {
                _writer.WriteKeyword(PrinterKeyword.Into);
                _writer.WriteSpace();
                _writer.WriteIdentifier(node.Identifier);
                _writer.WriteSpace();
            }

            node.Body.Accept(this);
        }
Пример #22
0
 public TameQueryContinuationSyntax(QueryContinuationSyntax node)
 {
     Node = node;
     AddChildren();
 }
Пример #23
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
 }
Пример #24
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     Visit(node.Body);
     _proceed = true;
 }
Пример #25
0
 /// <inheritdoc />
 public override Expression VisitQueryContinuation(QueryContinuationSyntax node)
 {
     throw Unexpected(node, nameof(VisitQueryExpression));
 }
Пример #26
0
            internal BoundExpression BindQueryInternal1(QueryExpressionSyntax node, DiagnosticBag diagnostics)
            {
                var fromClause = (FromClauseSyntax)node.Clauses[0];
                QueryTranslationState state = new QueryTranslationState();

                state.fromSyntax     = fromClause;
                state.fromExpression = BindValue(fromClause.Expression, BindValueKind.RValue, diagnostics);
                state.queryVariable  = state.AddQueryVariable(this, fromClause.Identifier);
                for (int i = node.Clauses.Count - 1; i > 0; i--)
                {
                    state.clauses.Push(node.Clauses[i]);
                }

                state.selectOrGroup = node.SelectOrGroup;

                // A from clause that explicitly specifies a range variable type
                //     from T x in e
                // is translated into
                //     from x in ( e ) . Cast < T > ( )
                MethodSymbol castMethod = null;

                if (fromClause.TypeOpt != null)
                {
                    var typeRestriction = BindType(fromClause.TypeOpt, diagnostics);
                    var cast            = MakeInvocation(state.fromSyntax, state.fromExpression, "Cast", fromClause.TypeOpt, typeRestriction, diagnostics);
                    castMethod           = cast.Method;
                    state.fromExpression = cast;
                }

                state.fromExpression = new BoundQueryClause(
                    syntax: fromClause,
                    syntaxTree: this.SyntaxTree,
                    value: state.fromExpression,
                    definedSymbol: state.queryVariable,
                    queryMethod: null,
                    castMethod: castMethod,
                    type: state.fromExpression.Type);

                // If the query is a degenerate one the form "from x in e select x", but in source,
                // then we go ahead and generate the select anyway.  We do this by skipping BindQueryInternal2,
                // whose job it is to (reduce away the whole query and) optimize away degenerate queries.
                BoundExpression result = (fromClause.TypeOpt == null && IsDegenerateQuery(state))
                    ? FinalTranslation(state, diagnostics)
                    : BindQueryInternal2(state, diagnostics);

                QueryContinuationSyntax continuation = node.ContinuationOpt;

                while (continuation != null)
                {
                    // A query expression with a continuation
                    //     from … into x …
                    // is translated into
                    //     from x in ( from … ) …
                    state.Clear();
                    state.fromExpression = result;
                    var x = state.AddQueryVariable(this, continuation.Identifier);
                    state.fromExpression = new BoundQueryClause(
                        syntax: continuation,
                        syntaxTree: SyntaxTree,
                        value: state.fromExpression,
                        definedSymbol: x,
                        queryMethod: null,
                        castMethod: null,
                        type: state.fromExpression.Type);
                    state.queryVariable = x;
                    Debug.Assert(state.clauses.IsEmpty());
                    var clauses = continuation.Query.Clauses;
                    for (int i = clauses.Count - 1; i >= 0; i--)
                    {
                        state.clauses.Push(clauses[i]);
                    }

                    state.selectOrGroup = continuation.Query.SelectOrGroup;
                    result       = BindQueryInternal2(state, diagnostics);
                    continuation = continuation.Query.ContinuationOpt;
                }

                state.Free();
                return(result);
            }
Пример #27
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     Visit(node.Body);
     _proceed = true;
 }
Пример #28
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     tracker.AddIdentifier(node.Identifier);
     VisitQueryInternal(null, node.Body);
     tracker.RemoveIdentifier(node.Identifier);
 }
Пример #29
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     this.Found |= node.Identifier.ValueText == this.name;
     base.VisitQueryContinuation(node);
 }
 private static void HandleContinuation(QueryContinuationSyntax continuation, List<SyntaxToken> tokensToCheck)
 {
     tokensToCheck.Add(continuation.IntoKeyword);
     HandleQueryBody(continuation.Body, tokensToCheck);
 }
Пример #31
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     tracker.AddIdentifier(node.Identifier);
     VisitQueryInternal(null, node.Body);
     tracker.RemoveIdentifier(node.Identifier);
 }
        private LuaExpressionSyntax BuildQueryContinuation(LuaExpressionSyntax collection, QueryContinuationSyntax node)
        {
            var rangeVariable = AddRangeIdentifier(node.Identifier);

            return(BuildQueryBody(collection, node.Body, rangeVariable));
        }
Пример #33
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     Log(node, "Unsupported Syntax !");
 }
Пример #34
0
 /// <summary>
 /// Get the query range variable declared in a query continuation clause.
 /// </summary>
 public abstract IRangeVariableSymbol GetDeclaredSymbol(QueryContinuationSyntax node, CancellationToken cancellationToken = default(CancellationToken));
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     this.OnNodeVisited(node, this.type.IsInstanceOfType(node));
     base.VisitQueryContinuation(node);
 }
Пример #36
0
 public override IRangeVariableSymbol GetDeclaredSymbol(QueryContinuationSyntax node, CancellationToken cancellationToken = default(CancellationToken))
 {
     var bound = GetBoundQueryClause(node);
     return bound == null ? null : bound.DefinedSymbol;
 }
Пример #37
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     map.Add(node.Identifier.ValueText, node.Identifier);
     base.VisitQueryContinuation(node);
 }
Пример #38
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="node"></param>
 public override sealed void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     this.OnNodeVisited(node);
     if (!this.traverseRootOnly) base.VisitQueryContinuation(node);
 }
Пример #39
0
 private static void HandleContinuation(QueryContinuationSyntax continuation, List <SyntaxToken> tokensToCheck)
 {
     tokensToCheck.Add(continuation.IntoKeyword);
     HandleQueryBody(continuation.Body, tokensToCheck);
 }
Пример #40
0
 public override Ust VisitQueryContinuation(QueryContinuationSyntax node)
 {
     return(base.VisitQueryContinuation(node));
 }
Пример #41
0
 public override void VisitQueryContinuation(QueryContinuationSyntax node)
 {
     this.Found |= node.Identifier.ValueText == this.name;
     base.VisitQueryContinuation(node);
 }
Пример #42
0
        internal BoundExpression BindQuery(QueryExpressionSyntax node, DiagnosticBag diagnostics)
        {
            var fromClause          = node.FromClause;
            var boundFromExpression = BindLeftOfPotentialColorColorMemberAccess(fromClause.Expression, diagnostics);

            // If the from expression is of the type dynamic we can't infer the types for any lambdas that occur in the query.
            // Only if there are none we could bind the query but we report an error regardless since such queries are not useful.
            if (boundFromExpression.HasDynamicType())
            {
                diagnostics.Add(ErrorCode.ERR_BadDynamicQuery, fromClause.Expression.Location);
                boundFromExpression = BadExpression(fromClause.Expression, boundFromExpression);
            }

            QueryTranslationState state = new QueryTranslationState();

            state.fromExpression = MakeMemberAccessValue(boundFromExpression, diagnostics);

            var x = state.rangeVariable = state.AddRangeVariable(this, fromClause.Identifier, diagnostics);

            for (int i = node.Body.Clauses.Count - 1; i >= 0; i--)
            {
                state.clauses.Push(node.Body.Clauses[i]);
            }

            state.selectOrGroup = node.Body.SelectOrGroup;

            // A from clause that explicitly specifies a range variable type
            //     from T x in e
            // is translated into
            //     from x in ( e ) . Cast < T > ( )
            BoundExpression cast = null;

            if (fromClause.Type != null)
            {
                var typeRestriction = BindTypeArgument(fromClause.Type, diagnostics);
                cast = MakeQueryInvocation(fromClause, state.fromExpression, "Cast", fromClause.Type, typeRestriction, diagnostics);
                state.fromExpression = cast;
            }

            state.fromExpression = MakeQueryClause(fromClause, state.fromExpression, x, castInvocation: cast);
            BoundExpression result = BindQueryInternal1(state, diagnostics);

            for (QueryContinuationSyntax continuation = node.Body.Continuation; continuation != null; continuation = continuation.Body.Continuation)
            {
                // A query expression with a continuation
                //     from ... into x ...
                // is translated into
                //     from x in ( from ... ) ...
                state.Clear();
                state.fromExpression = result;
                x = state.rangeVariable = state.AddRangeVariable(this, continuation.Identifier, diagnostics);
                Debug.Assert(state.clauses.IsEmpty());
                var clauses = continuation.Body.Clauses;
                for (int i = clauses.Count - 1; i >= 0; i--)
                {
                    state.clauses.Push(clauses[i]);
                }

                state.selectOrGroup = continuation.Body.SelectOrGroup;
                result = BindQueryInternal1(state, diagnostics);
                result = MakeQueryClause(continuation.Body, result, x);
                result = MakeQueryClause(continuation, result, x);
            }

            state.Free();
            return(MakeQueryClause(node, result));
        }
Пример #43
0
        public override void VisitQueryContinuation(QueryContinuationSyntax node)
        {
            node.Body?.Accept(this);

            base.VisitQueryContinuation(node);
        }