public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
 {
     base.VisitYieldReturnStatement(node);
     MarkLocalsUnassigned();
     seenYieldInCurrentTry = true;
     return(null);
 }
Beispiel #2
0
 public override BoundStatement InstrumentYieldReturnStatement(
     BoundYieldReturnStatement original,
     BoundStatement rewritten
     )
 {
     return(Previous.InstrumentYieldReturnStatement(original, rewritten));
 }
Beispiel #3
0
        public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
        {
            BoundSpillSequenceBuilder builder = null;
            var expression = VisitExpression(ref builder, node.Expression);

            return(UpdateStatement(builder, node.Update(expression)));
        }
Beispiel #4
0
 public virtual BoundStatement InstrumentYieldReturnStatement(
     BoundYieldReturnStatement original,
     BoundStatement rewritten
     )
 {
     return(InstrumentStatement(original, rewritten));
 }
        public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
        {
            //     yield return expression;
            // is translated to
            //     this.current = expression;
            //     this.state = <next_state>;
            //     return true;
            //     <next_state_label>: ;
            //     <hidden sequence point>
            //     this.state = finalizeState;
            int stateNumber;
            GeneratedLabelSymbol resumeLabel;

            AddState(out stateNumber, out resumeLabel);
            _currentFinallyFrame.AddState(stateNumber);

            var rewrittenExpression = (BoundExpression)Visit(node.Expression);

            return(F.Block(
                       F.Assignment(F.Field(F.This(), _current), rewrittenExpression),
                       F.Assignment(F.Field(F.This(), stateField), F.Literal(stateNumber)),
                       GenerateReturn(finished: false),
                       F.Label(resumeLabel),
                       F.HiddenSequencePoint(),
                       F.Assignment(
                           F.Field(F.This(), stateField),
                           F.Literal(_currentFinallyFrame.finalizeState)
                           )
                       ));
        }
Beispiel #6
0
        public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
        {
            // Produce:
            //     _current = expression;
            //     _state = <next_state>;
            //     goto _exprReturnLabelTrue;
            //     <next_state_label>: ;
            //     <hidden sequence point>
            //     this.state = cachedState = NotStartedStateMachine;
            //     if (disposeMode) goto currentDisposalLabel;

            // Note: at label _exprReturnLabelTrue we have:
            //  _promiseOfValueOrEnd.SetResult(true);
            //  return;

            var stateNumber = _nextYieldReturnState--;

            AddState(stateNumber, out GeneratedLabelSymbol resumeLabel);

            var rewrittenExpression = (BoundExpression)Visit(node.Expression);
            var blockBuilder        = ArrayBuilder <BoundStatement> .GetInstance();

            blockBuilder.Add(
                // _current = expression;
                F.Assignment(F.InstanceField(_asyncIteratorInfo.CurrentField), rewrittenExpression)
                );

            blockBuilder.Add(
                // this.state = cachedState = stateForLabel
                GenerateSetBothStates(stateNumber)
                );

            blockBuilder.Add(
                // goto _exprReturnLabelTrue;
                F.Goto(_exprReturnLabelTrue)
                );

            blockBuilder.Add(
                // <next_state_label>: ;
                F.Label(resumeLabel)
                );

            blockBuilder.Add(F.HiddenSequencePoint());

            blockBuilder.Add(
                // this.state = cachedState = NotStartedStateMachine
                GenerateSetBothStates(StateMachineStates.NotStartedStateMachine)
                );

            Debug.Assert(_currentDisposalLabel is object); // no yield return allowed inside a finally
            blockBuilder.Add(
                // if (disposeMode) goto currentDisposalLabel;
                GenerateJumpToCurrentDisposalLabel()
                );

            blockBuilder.Add(F.HiddenSequencePoint());

            return(F.Block(blockBuilder.ToImmutableAndFree()));
        }
Beispiel #7
0
        public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
        {
            var result = (BoundStatement)base.VisitYieldReturnStatement(node);
            if (this.Instrument && !node.WasCompilerGenerated)
            {
                result = _instrumenter.InstrumentYieldReturnStatement(node, result);
            }

            return result;
        }
Beispiel #8
0
        public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
        {
            var result = (BoundStatement)base.VisitYieldReturnStatement(node);

            if (this.Instrument && !node.WasCompilerGenerated)
            {
                result = _instrumenter.InstrumentYieldReturnStatement(node, result);
            }

            return(result);
        }
Beispiel #9
0
        public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
        {
            Debug.Assert(_asyncIteratorInfo != null);

            // Produce:
            //     _current = expression;
            //     _state = <next_state>;
            //     _valueOrEndPromise.SetResult(true);
            //     goto <exit_label>;
            //     <next_state_label>: ;
            //     this.state = finalizeState;

            int stateNumber;
            GeneratedLabelSymbol resumeLabel;

            AddState(out stateNumber, out resumeLabel);
            // https://github.com/dotnet/roslyn/issues/30260 Need to handle try/finally statements (see IteratorMethodToStateMachineRewriter)
            //_currentFinallyFrame.AddState(stateNumber);

            var rewrittenExpression = (BoundExpression)Visit(node.Expression);
            var blockBuilder        = ArrayBuilder <BoundStatement> .GetInstance();

            blockBuilder.Add(
                // _current = expression;
                F.Assignment(F.Field(F.This(), _asyncIteratorInfo.CurrentField), rewrittenExpression));

            blockBuilder.Add(
                // _state = <next_state>;
                F.Assignment(F.Field(F.This(), stateField), F.Literal(stateNumber)));

            blockBuilder.Add(
                // _promiseOfValueOrEnd.SetResult(true);
                GenerateSetResultOnPromise(true));

            blockBuilder.Add(
                // goto <exit_label>;
                GenerateReturn(finished: false));

            blockBuilder.Add(
                // <next_state_label>: ;
                F.Label(resumeLabel));

            blockBuilder.Add(
                F.HiddenSequencePoint());

            // https://github.com/dotnet/roslyn/issues/30260 Need to handle try/finally statements (see IteratorMethodToStateMachineRewriter)
            //blockBuilder.Add(
            //    // this.state = finalizeState;
            //    F.Assignment(F.Field(F.This(), stateField), F.Literal(_currentFinallyFrame.finalizeState)));

            return(F.Block(blockBuilder.ToImmutableAndFree()));
        }
 public override BoundStatement InstrumentYieldReturnStatement(BoundYieldReturnStatement original, BoundStatement rewritten)
 {
     return(AddSequencePoint(base.InstrumentYieldReturnStatement(original, rewritten)));
 }
 public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
 {
     base.VisitYieldReturnStatement(node);
     MarkLocalsUnassigned();
     _seenYieldInCurrentTry = true;
     return null;
 }
 public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
 {
     _seenYield = true;
     return base.VisitYieldReturnStatement(node);
 }
Beispiel #13
0
 public override BoundStatement InstrumentYieldReturnStatement(BoundYieldReturnStatement original, BoundStatement rewritten)
 {
     return AddSequencePoint(base.InstrumentYieldReturnStatement(original, rewritten));
 }
Beispiel #14
0
 public override BoundStatement InstrumentYieldReturnStatement(BoundYieldReturnStatement original, BoundStatement rewritten)
 {
     return(AddDynamicAnalysis(original, base.InstrumentYieldReturnStatement(original, rewritten)));
 }
        public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
        {
            //     yield return expression;
            // is translated to
            //     this.current = expression;
            //     this.state = <next_state>;
            //     return true;
            //     <next_state_label>: ;
            //     this.state = finalizeState;
            int stateNumber;
            GeneratedLabelSymbol resumeLabel;
            AddState(out stateNumber, out resumeLabel);
            _currentFinallyFrame.AddState(stateNumber);

            var rewrittenExpression = (BoundExpression)Visit(node.Expression);

            return F.Block(
                F.Assignment(F.Field(F.This(), _current), rewrittenExpression),
                F.Assignment(F.Field(F.This(), stateField), F.Literal(stateNumber)),
                GenerateReturn(finished: false),
                F.Label(resumeLabel),
                F.HiddenSequencePoint(),
                F.Assignment(F.Field(F.This(), stateField), F.Literal(_currentFinallyFrame.finalizeState)));
        }
 public override BoundStatement InstrumentYieldReturnStatement(BoundYieldReturnStatement original, BoundStatement rewritten)
 {
     return AddDynamicAnalysis(original, base.InstrumentYieldReturnStatement(original, rewritten));
 }
Beispiel #17
0
 public virtual BoundStatement InstrumentYieldReturnStatement(BoundYieldReturnStatement original, BoundStatement rewritten)
 {
     return InstrumentStatement(original, rewritten);
 }
 public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
 {
     return(AddSequencePoint((BoundStatement)base.VisitYieldReturnStatement(node)));
 }
Beispiel #19
0
 public override BoundStatement InstrumentYieldReturnStatement(BoundYieldReturnStatement original, BoundStatement rewritten)
 {
     return Previous.InstrumentYieldReturnStatement(original, rewritten);
 }
 public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
 {
     _seenYield = true;
     return(base.VisitYieldReturnStatement(node));
 }
Beispiel #21
0
 public override BoundNode VisitYieldReturnStatement(BoundYieldReturnStatement node)
 {
     return AddSequencePoint((BoundStatement)base.VisitYieldReturnStatement(node));
 }