public override BoundNode VisitWhileStatement(BoundWhileStatement node)
        {
            Debug.Assert(node != null);

            var rewrittenCondition = (BoundExpression)Visit(node.Condition);
            var rewrittenBody      = (BoundStatement)Visit(node.Body);

            TextSpan conditionSequencePointSpan = default(TextSpan);

            if (this.GenerateDebugInfo)
            {
                if (!node.WasCompilerGenerated)
                {
                    WhileStatementSyntax whileSyntax = (WhileStatementSyntax)node.Syntax;
                    conditionSequencePointSpan = TextSpan.FromBounds(
                        whileSyntax.WhileKeyword.SpanStart,
                        whileSyntax.CloseParenToken.Span.End);
                }
            }

            // EnC: We need to insert a hidden sequence point to handle function remapping in case
            // the containing method is edited while methods invoked in the condition are being executed.
            return(RewriteWhileStatement(
                       node.Syntax,
                       AddConditionSequencePoint(rewrittenCondition, node),
                       conditionSequencePointSpan,
                       rewrittenBody,
                       node.BreakLabel,
                       node.ContinueLabel,
                       node.HasErrors));
        }
        public override BoundNode VisitWhileStatement(BoundWhileStatement node)
        {
            Debug.Assert(node != null);

            var rewrittenCondition = (BoundExpression)Visit(node.Condition);
            var rewrittenBody      = (BoundStatement)Visit(node.Body);

            TextSpan conditionSequencePointSpan = default(TextSpan);

            if (this.GenerateDebugInfo)
            {
                if (!node.WasCompilerGenerated)
                {
                    WhileStatementSyntax whileSyntax = (WhileStatementSyntax)node.Syntax;
                    conditionSequencePointSpan = TextSpan.FromBounds(
                        whileSyntax.WhileKeyword.SpanStart,
                        whileSyntax.CloseParenToken.Span.End);
                }
            }

            return(RewriteWhileStatement(
                       node.Syntax,
                       AddConditionSequencePoint(rewrittenCondition, node),
                       conditionSequencePointSpan,
                       rewrittenBody,
                       node.BreakLabel,
                       node.ContinueLabel,
                       node.HasErrors));
        }
Example #3
0
 public override BoundNode VisitWhileStatement(BoundWhileStatement node)
 {
     AddAll(node.Locals);
     base.VisitWhileStatement(node);
     RemoveAll(node.Locals);
     return(null);
 }
        public override BoundNode VisitWhileStatement(BoundWhileStatement node)
        {
            Debug.Assert(node != null);

            var rewrittenCondition = (BoundExpression)Visit(node.Condition);
            var rewrittenBody = (BoundStatement)Visit(node.Body);

            TextSpan conditionSequencePointSpan = default(TextSpan);
            if (this.GenerateDebugInfo)
            {
                if (!node.WasCompilerGenerated)
                {
                    WhileStatementSyntax whileSyntax = (WhileStatementSyntax)node.Syntax;
                    conditionSequencePointSpan = TextSpan.FromBounds(
                        whileSyntax.WhileKeyword.SpanStart,
                        whileSyntax.CloseParenToken.Span.End);
                }
            }

            return RewriteWhileStatement(
                node.Syntax, 
                node.InnerLocals, 
                AddConditionSequencePoint(rewrittenCondition, node), 
                conditionSequencePointSpan, 
                rewrittenBody, 
                node.BreakLabel,
                node.ContinueLabel,
                node.HasErrors);
        }
        public override BoundNode VisitWhileStatement(BoundWhileStatement node)
        {
            Debug.Assert(node != null);

            var rewrittenCondition = (BoundExpression)Visit(node.Condition);
            var rewrittenBody = (BoundStatement)Visit(node.Body);

            TextSpan conditionSequencePointSpan = default(TextSpan);
            if (this.GenerateDebugInfo)
            {
                if (!node.WasCompilerGenerated)
                {
                    WhileStatementSyntax whileSyntax = (WhileStatementSyntax)node.Syntax;
                    conditionSequencePointSpan = TextSpan.FromBounds(
                        whileSyntax.WhileKeyword.SpanStart,
                        whileSyntax.CloseParenToken.Span.End);
                }
            }

            // EnC: We need to insert a hidden sequence point to handle function remapping in case 
            // the containing method is edited while methods invoked in the condition are being executed.
            return RewriteWhileStatement(
                node.Syntax,
                AddConditionSequencePoint(rewrittenCondition, node),
                conditionSequencePointSpan,
                rewrittenBody,
                node.BreakLabel,
                node.ContinueLabel,
                node.HasErrors);
        }
Example #6
0
 public virtual BoundExpression InstrumentWhileStatementCondition(BoundWhileStatement original, BoundExpression rewrittenCondition, SyntheticBoundNodeFactory factory)
 {
     Debug.Assert(!original.WasCompilerGenerated);
     Debug.Assert(original.Syntax.Kind() == SyntaxKind.WhileStatement);
     Debug.Assert(factory != null);
     return(rewrittenCondition);
 }
Example #7
0
 public override BoundNode VisitWhileStatement(BoundWhileStatement node)
 {
     if (IsInside)
     {
         _labelsInside.Add(node.BreakLabel);
     }
     return(base.VisitWhileStatement(node));
 }
        public override BoundNode VisitWhileStatement(BoundWhileStatement node)
        {
            Debug.Assert(node != null);

            var rewrittenCondition = VisitExpression(node.Condition);
            var rewrittenBody      = VisitStatement(node.Body);

            Debug.Assert(rewrittenBody is { });
        public override BoundStatement InstrumentWhileStatementConditionalGotoStart(BoundWhileStatement original, BoundStatement ifConditionGotoStart)
        {
            WhileStatementSyntax whileSyntax = (WhileStatementSyntax)original.Syntax;
            TextSpan             conditionSequencePointSpan = TextSpan.FromBounds(
                whileSyntax.WhileKeyword.SpanStart,
                whileSyntax.CloseParenToken.Span.End);

            return(new BoundSequencePointWithSpan(whileSyntax, base.InstrumentWhileStatementConditionalGotoStart(original, ifConditionGotoStart), conditionSequencePointSpan));
        }
Example #10
0
 public virtual BoundStatement InstrumentWhileStatementConditionalGotoStartOrBreak(
     BoundWhileStatement original,
     BoundStatement ifConditionGotoStart
     )
 {
     Debug.Assert(!original.WasCompilerGenerated);
     Debug.Assert(original.Syntax.Kind() == SyntaxKind.WhileStatement);
     return(ifConditionGotoStart);
 }
Example #11
0
 public override BoundStatement InstrumentWhileStatementConditionalGotoStartOrBreak(
     BoundWhileStatement original,
     BoundStatement ifConditionGotoStart
     )
 {
     return(Previous.InstrumentWhileStatementConditionalGotoStartOrBreak(
                original,
                ifConditionGotoStart
                ));
 }
Example #12
0
 public override BoundExpression InstrumentWhileStatementCondition(
     BoundWhileStatement original,
     BoundExpression rewrittenCondition,
     SyntheticBoundNodeFactory factory
     )
 {
     return(Previous.InstrumentWhileStatementCondition(
                original,
                rewrittenCondition,
                factory
                ));
 }
Example #13
0
        private BoundStatement RewriteWhileStatement(
            BoundWhileStatement loop,
            ImmutableArray <LocalSymbol> locals,
            BoundExpression rewrittenCondition,
            BoundStatement rewrittenBody,
            GeneratedLabelSymbol breakLabel,
            GeneratedLabelSymbol continueLabel,
            bool hasErrors)
        {
            if (locals.IsEmpty)
            {
                return(RewriteWhileStatement(loop, rewrittenCondition, rewrittenBody, breakLabel, continueLabel, hasErrors));
            }

            // We need to enter scope-block from the top, that is where an instance of a display class will be created
            // if any local is captured within a lambda.

            // while (condition)
            //   body;
            //
            // becomes
            //
            // continue:
            // {
            //     GotoIfFalse condition break;
            //     body
            //     goto continue;
            // }
            // break:

            SyntaxNode     syntax = loop.Syntax;
            BoundStatement continueLabelStatement  = new BoundLabelStatement(syntax, continueLabel);
            BoundStatement ifNotConditionGotoBreak = new BoundConditionalGoto(rewrittenCondition.Syntax, rewrittenCondition, false, breakLabel);

            if (this.Instrument && !loop.WasCompilerGenerated)
            {
                ifNotConditionGotoBreak = _instrumenter.InstrumentWhileStatementConditionalGotoStartOrBreak(loop, ifNotConditionGotoBreak);
                continueLabelStatement  = new BoundSequencePoint(null, continueLabelStatement);
            }

            return(BoundStatementList.Synthesized(syntax, hasErrors,
                                                  continueLabelStatement,
                                                  new BoundBlock(syntax,
                                                                 locals,
                                                                 ImmutableArray.Create(
                                                                     ifNotConditionGotoBreak,
                                                                     rewrittenBody,
                                                                     new BoundGotoStatement(syntax, continueLabel))),
                                                  new BoundLabelStatement(syntax, breakLabel)));
        }
Example #14
0
        public override BoundNode VisitWhileStatement(BoundWhileStatement node)
        {
            Debug.Assert(node != null);

            var rewrittenCondition = (BoundExpression)Visit(node.Condition);
            var rewrittenBody      = (BoundStatement)Visit(node.Body);

            // EnC: We need to insert a hidden sequence point to handle function remapping in case
            // the containing method is edited while methods invoked in the condition are being executed.
            if (!node.WasCompilerGenerated && this.Instrument)
            {
                rewrittenCondition = _instrumenter.InstrumentWhileStatementCondition(node, rewrittenCondition, _factory);
            }

            return(RewriteWhileStatement(
                       node,
                       rewrittenCondition,
                       rewrittenBody,
                       node.BreakLabel,
                       node.ContinueLabel,
                       node.HasErrors));
        }
        public override BoundNode VisitWhileStatement(BoundWhileStatement node)
        {
            Debug.Assert(node != null);

            var rewrittenCondition = (BoundExpression)Visit(node.Condition);
            var rewrittenBody = (BoundStatement)Visit(node.Body);

            // EnC: We need to insert a hidden sequence point to handle function remapping in case 
            // the containing method is edited while methods invoked in the condition are being executed.
            if (!node.WasCompilerGenerated && this.Instrument)
            {
                rewrittenCondition = _instrumenter.InstrumentWhileStatementCondition(node, rewrittenCondition, _factory);
            }

            return RewriteWhileStatement(
                node,
                rewrittenCondition,
                rewrittenBody,
                node.BreakLabel,
                node.ContinueLabel,
                node.HasErrors);
        }
        private BoundStatement RewriteWhileStatement(
            BoundWhileStatement loop,
            ImmutableArray<LocalSymbol> locals,
            BoundExpression rewrittenCondition,
            BoundStatement rewrittenBody,
            GeneratedLabelSymbol breakLabel,
            GeneratedLabelSymbol continueLabel,
            bool hasErrors)
        {
            if (locals.IsEmpty)
            {
                return RewriteWhileStatement(loop, rewrittenCondition, rewrittenBody, breakLabel, continueLabel, hasErrors);
            }

            // We need to enter scope-block from the top, that is where an instance of a display class will be created
            // if any local is captured within a lambda.

            // while (condition) 
            //   body;
            //
            // becomes
            //
            // continue:
            // {
            //     GotoIfFalse condition break;
            //     body
            //     goto continue;
            // }
            // break:

            SyntaxNode syntax = loop.Syntax;
            BoundStatement continueLabelStatement = new BoundLabelStatement(syntax, continueLabel);
            BoundStatement ifNotConditionGotoBreak = new BoundConditionalGoto(rewrittenCondition.Syntax, rewrittenCondition, false, breakLabel);

            if (this.Instrument && !loop.WasCompilerGenerated)
            {
                ifNotConditionGotoBreak = _instrumenter.InstrumentWhileStatementConditionalGotoStartOrBreak(loop, ifNotConditionGotoBreak);
                continueLabelStatement = new BoundSequencePoint(null, continueLabelStatement);
            }

            return BoundStatementList.Synthesized(syntax, hasErrors,
                continueLabelStatement,
                new BoundBlock(syntax,
                               locals,
                               ImmutableArray.Create(
                                    ifNotConditionGotoBreak,
                                    rewrittenBody,
                                    new BoundGotoStatement(syntax, continueLabel))),
                new BoundLabelStatement(syntax, breakLabel));
        }
Example #17
0
 public override BoundStatement InstrumentWhileStatementGotoContinue(BoundWhileStatement original, BoundStatement gotoContinue)
 {
     return new BoundSequencePoint(null, base.InstrumentWhileStatementGotoContinue(original, gotoContinue));
 }
Example #18
0
        public override BoundStatement InstrumentWhileStatementConditionalGotoStart(BoundWhileStatement original, BoundStatement ifConditionGotoStart)
        {
            WhileStatementSyntax whileSyntax = (WhileStatementSyntax)original.Syntax;
            TextSpan conditionSequencePointSpan = TextSpan.FromBounds(
                whileSyntax.WhileKeyword.SpanStart,
                whileSyntax.CloseParenToken.Span.End);

            return new BoundSequencePointWithSpan(whileSyntax, base.InstrumentWhileStatementConditionalGotoStart(original, ifConditionGotoStart), conditionSequencePointSpan);
        }
Example #19
0
 public override BoundExpression InstrumentWhileStatementCondition(BoundWhileStatement original, BoundExpression rewrittenCondition, SyntheticBoundNodeFactory factory)
 {
     // EnC: We need to insert a hidden sequence point to handle function remapping in case 
     // the containing method is edited while methods invoked in the condition are being executed.
     return AddConditionSequencePoint(base.InstrumentWhileStatementCondition(original, rewrittenCondition, factory), original.Syntax, factory);
 }
Example #20
0
 public override BoundNode VisitWhileStatement(BoundWhileStatement node)
 {
     if (IsInside)
     {
         _labelsInside.Add(node.BreakLabel);
     }
     return base.VisitWhileStatement(node);
 }
Example #21
0
 public virtual BoundStatement InstrumentWhileStatementConditionalGotoStart(BoundWhileStatement original, BoundStatement ifConditionGotoStart)
 {
     Debug.Assert(!original.WasCompilerGenerated);
     Debug.Assert(original.Syntax.Kind() == SyntaxKind.WhileStatement);
     return ifConditionGotoStart;
 }
Example #22
0
 public override BoundStatement InstrumentWhileStatementGotoContinue(BoundWhileStatement original, BoundStatement gotoContinue)
 {
     return Previous.InstrumentWhileStatementGotoContinue(original, gotoContinue);
 }
Example #23
0
 public override BoundStatement InstrumentWhileStatementConditionalGotoStart(BoundWhileStatement original, BoundStatement ifConditionGotoStart)
 {
     return Previous.InstrumentWhileStatementConditionalGotoStart(original, ifConditionGotoStart);
 }
Example #24
0
 public override BoundExpression InstrumentWhileStatementCondition(BoundWhileStatement original, BoundExpression rewrittenCondition, SyntheticBoundNodeFactory factory)
 {
     return Previous.InstrumentWhileStatementCondition(original, rewrittenCondition, factory);
 }
Example #25
0
 public override BoundStatement InstrumentWhileStatementConditionalGotoStart(BoundWhileStatement original, BoundStatement ifConditionGotoStart)
 {
     return AddDynamicAnalysis(original, base.InstrumentWhileStatementConditionalGotoStart(original, ifConditionGotoStart));
 }
Example #26
0
 public virtual BoundStatement InstrumentWhileStatementGotoContinue(BoundWhileStatement original, BoundStatement gotoContinue)
 {
     Debug.Assert(!original.WasCompilerGenerated);
     Debug.Assert(original.Syntax.Kind() == SyntaxKind.WhileStatement);
     return gotoContinue;
 }
Example #27
0
 public override BoundStatement InstrumentWhileStatementConditionalGotoStartOrBreak(BoundWhileStatement original, BoundStatement ifConditionGotoStart)
 {
     return(AddDynamicAnalysis(original, base.InstrumentWhileStatementConditionalGotoStartOrBreak(original, ifConditionGotoStart)));
 }
Example #28
0
 public override BoundStatement InstrumentWhileStatementGotoContinue(BoundWhileStatement original, BoundStatement gotoContinue)
 {
     return(Previous.InstrumentWhileStatementGotoContinue(original, gotoContinue));
 }
Example #29
0
 public override BoundExpression InstrumentWhileStatementCondition(BoundWhileStatement original, BoundExpression rewrittenCondition, SyntheticBoundNodeFactory factory)
 {
     // EnC: We need to insert a hidden sequence point to handle function remapping in case
     // the containing method is edited while methods invoked in the condition are being executed.
     return(AddConditionSequencePoint(base.InstrumentWhileStatementCondition(original, rewrittenCondition, factory), original.Syntax, factory));
 }
Example #30
0
 public virtual BoundExpression InstrumentWhileStatementCondition(BoundWhileStatement original, BoundExpression rewrittenCondition, SyntheticBoundNodeFactory factory)
 {
     Debug.Assert(!original.WasCompilerGenerated);
     Debug.Assert(original.Syntax.Kind() == SyntaxKind.WhileStatement);
     Debug.Assert(factory != null);
     return rewrittenCondition;
 }
Example #31
0
 public override BoundStatement InstrumentWhileStatementGotoContinue(BoundWhileStatement original, BoundStatement gotoContinue)
 {
     return(new BoundSequencePoint(null, base.InstrumentWhileStatementGotoContinue(original, gotoContinue)));
 }
Example #32
0
 public virtual BoundStatement InstrumentWhileStatementGotoContinue(BoundWhileStatement original, BoundStatement gotoContinue)
 {
     Debug.Assert(!original.WasCompilerGenerated);
     Debug.Assert(original.Syntax.Kind() == SyntaxKind.WhileStatement);
     return(gotoContinue);
 }