public override BoundNode VisitForStatement(BoundForStatement node) { Debug.Assert(node != null); var rewrittenInitializer = (BoundStatement)Visit(node.Initializer); var rewrittenCondition = (BoundExpression)Visit(node.Condition); var rewrittenIncrement = (BoundStatement)Visit(node.Increment); 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 (rewrittenCondition != null && this.Instrument) { rewrittenCondition = _instrumenter.InstrumentForStatementCondition(node, rewrittenCondition, _factory); } return(RewriteForStatement( node, node.OuterLocals, rewrittenInitializer, rewrittenCondition, rewrittenIncrement, rewrittenBody, node.BreakLabel, node.ContinueLabel, node.HasErrors)); }
public override BoundStatement InstrumentForStatementConditionalGotoStartOrBreak( BoundForStatement original, BoundStatement branchBack ) { return(Previous.InstrumentForStatementConditionalGotoStartOrBreak(original, branchBack)); }
public virtual BoundExpression InstrumentForStatementCondition(BoundForStatement original, BoundExpression rewrittenCondition, SyntheticBoundNodeFactory factory) { Debug.Assert(!original.WasCompilerGenerated); Debug.Assert(original.Syntax.Kind() == SyntaxKind.ForStatement); Debug.Assert(factory != null); return(rewrittenCondition); }
public override BoundNode VisitForStatement(BoundForStatement node) { Debug.Assert(node != null); var rewrittenInitializer = (BoundStatement)Visit(node.Initializer); var rewrittenCondition = (BoundExpression)Visit(node.Condition); var rewrittenIncrement = (BoundStatement)Visit(node.Increment); 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 (rewrittenCondition != null && this.Instrument) { rewrittenCondition = _instrumenter.InstrumentForStatementCondition(node, rewrittenCondition, _factory); } return RewriteForStatement( node, node.OuterLocals, rewrittenInitializer, rewrittenCondition, rewrittenIncrement, rewrittenBody, node.BreakLabel, node.ContinueLabel, node.HasErrors); }
public override BoundExpression InstrumentForStatementCondition( BoundForStatement original, BoundExpression rewrittenCondition, SyntheticBoundNodeFactory factory ) { return(Previous.InstrumentForStatementCondition(original, rewrittenCondition, factory)); }
internal override BoundForStatement BindForParts( BindingDiagnosticBag diagnostics, Binder originalBinder ) { BoundForStatement result = BindForParts(_syntax, originalBinder, diagnostics); return(result); }
public override BoundNode VisitForStatement(BoundForStatement node) { if (IsInside) { _labelsInside.Add(node.BreakLabel); _labelsInside.Add(node.ContinueLabel); } return(base.VisitForStatement(node)); }
public virtual BoundStatement InstrumentForStatementConditionalGotoStartOrBreak( BoundForStatement original, BoundStatement branchBack ) { Debug.Assert(!original.WasCompilerGenerated); Debug.Assert(original.Syntax.Kind() == SyntaxKind.ForStatement); return(branchBack); }
public override BoundNode VisitForStatement(BoundForStatement node) { Debug.Assert(node != null); var rewrittenInitializer = VisitStatement(node.Initializer); var rewrittenCondition = VisitExpression(node.Condition); var rewrittenIncrement = VisitStatement(node.Increment); var rewrittenBody = VisitStatement(node.Body); Debug.Assert(rewrittenBody is { });
public override BoundNode VisitForStatement(BoundForStatement node) { AddAll(node.OuterLocals); this.Visit(node.Initializer); AddAll(node.InnerLocals); this.Visit(node.Condition); this.Visit(node.Increment); this.Visit(node.Body); RemoveAll(node.InnerLocals); RemoveAll(node.OuterLocals); return(null); }
internal override BoundForStatement BindForParts(DiagnosticBag diagnostics) { BoundForStatement result = BindForParts(syntax, diagnostics); var initializationBinder = (ForLoopInitializationBinder)this.Next; if (!initializationBinder.Locals.IsDefaultOrEmpty) { result = result.Update(initializationBinder.Locals, result.Initializer, result.InnerLocals, result.Condition, result.Increment, result.Body, result.BreakLabel, result.ContinueLabel); } return(result); }
public override BoundNode VisitForStatement(BoundForStatement node) { Debug.Assert(node != null); var rewrittenInitializer = (BoundStatement)Visit(node.Initializer); var rewrittenCondition = (BoundExpression)Visit(node.Condition); var rewrittenIncrement = (BoundStatement)Visit(node.Increment); var rewrittenBody = (BoundStatement)Visit(node.Body); return(RewriteForStatement( node.Syntax, node.OuterLocals, rewrittenInitializer, AddConditionSequencePoint(rewrittenCondition, node), node.Condition?.Syntax, default(TextSpan), rewrittenIncrement, rewrittenBody, node.BreakLabel, node.ContinueLabel, node.HasErrors)); }
public override BoundNode VisitForStatement(BoundForStatement node) { Debug.Assert(node != null); var rewrittenInitializer = (BoundStatement)Visit(node.Initializer); var rewrittenCondition = (BoundExpression)Visit(node.Condition); var rewrittenIncrement = (BoundStatement)Visit(node.Increment); var rewrittenBody = (BoundStatement)Visit(node.Body); return RewriteForStatement( node.Syntax, node.OuterLocals, rewrittenInitializer, AddConditionSequencePoint(rewrittenCondition, node), node.Condition?.Syntax, default(TextSpan), rewrittenIncrement, rewrittenBody, node.BreakLabel, node.ContinueLabel, node.HasErrors); }
public override BoundNode VisitForStatement(BoundForStatement node) { Debug.Assert(node != null); var rewrittenInitializer = (BoundStatement)Visit(node.Initializer); var rewrittenCondition = (BoundExpression)Visit(node.Condition); var rewrittenIncrement = (BoundStatement)Visit(node.Increment); var rewrittenBody = (BoundStatement)Visit(node.Body); SyntaxNodeOrToken conditionSyntax = ((BoundNode)rewrittenCondition ?? node).Syntax; return RewriteForStatement( node.Syntax, node.Locals, rewrittenInitializer, rewrittenCondition, conditionSyntax, rewrittenIncrement, rewrittenBody, node.BreakLabel, node.ContinueLabel, node.HasErrors); }
public override BoundNode VisitForStatement(BoundForStatement node) { Debug.Assert(node != null); var rewrittenInitializer = (BoundStatement)Visit(node.Initializer); var rewrittenCondition = (BoundExpression)Visit(node.Condition); var rewrittenIncrement = (BoundStatement)Visit(node.Increment); var rewrittenBody = (BoundStatement)Visit(node.Body); SyntaxNodeOrToken conditionSyntax = ((BoundNode)rewrittenCondition ?? node).Syntax; return(RewriteForStatement( node.Syntax, node.Locals, rewrittenInitializer, rewrittenCondition, conditionSyntax, rewrittenIncrement, rewrittenBody, node.BreakLabel, node.ContinueLabel, node.HasErrors)); }
public override BoundNode VisitForStatement(BoundForStatement node) { Debug.Assert(node != null); var rewrittenInitializer = (BoundStatement)Visit(node.Initializer); var rewrittenCondition = (BoundExpression)Visit(node.Condition); var rewrittenIncrement = (BoundStatement)Visit(node.Increment); 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. return RewriteForStatement( node.Syntax, node.OuterLocals, rewrittenInitializer, AddConditionSequencePoint(rewrittenCondition, node), node.Condition?.Syntax, default(TextSpan), rewrittenIncrement, rewrittenBody, node.BreakLabel, node.ContinueLabel, node.HasErrors); }
public override BoundNode VisitForStatement(BoundForStatement node) { Debug.Assert(node != null); var rewrittenInitializer = (BoundStatement)Visit(node.Initializer); var rewrittenCondition = (BoundExpression)Visit(node.Condition); var rewrittenIncrement = (BoundStatement)Visit(node.Increment); 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. return(RewriteForStatement( node.Syntax, node.OuterLocals, rewrittenInitializer, AddConditionSequencePoint(rewrittenCondition, node), node.Condition?.Syntax, default(TextSpan), rewrittenIncrement, rewrittenBody, node.BreakLabel, node.ContinueLabel, node.HasErrors)); }
public override BoundExpression InstrumentForStatementCondition(BoundForStatement original, BoundExpression rewrittenCondition, SyntheticBoundNodeFactory factory) { return Previous.InstrumentForStatementCondition(original, rewrittenCondition, factory); }
public override BoundExpression InstrumentForStatementCondition(BoundForStatement 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.InstrumentForStatementCondition(original, rewrittenCondition, factory), original.Syntax, factory); }
public override BoundStatement InstrumentForStatementConditionalGotoStart(BoundForStatement original, BoundStatement branchBack) { // hidden sequence point if there is no condition return new BoundSequencePoint(original.Condition?.Syntax, base.InstrumentForStatementConditionalGotoStart(original, branchBack)); }
public override BoundStatement InstrumentForStatementGotoEnd(BoundForStatement original, BoundStatement gotoEnd) { return ForStatementCreateGotoEndSequencePoint(base.InstrumentForStatementGotoEnd(original, gotoEnd)); }
public virtual BoundStatement InstrumentForStatementConditionalGotoStart(BoundForStatement original, BoundStatement branchBack) { Debug.Assert(!original.WasCompilerGenerated); Debug.Assert(original.Syntax.Kind() == SyntaxKind.ForStatement); return branchBack; }
public override BoundNode VisitForStatement(BoundForStatement node) { if (IsInside) { _labelsInside.Add(node.BreakLabel); _labelsInside.Add(node.ContinueLabel); } return base.VisitForStatement(node); }
private BoundStatement RewriteForStatement( BoundForStatement node, BoundStatement rewrittenInitializer, BoundExpression rewrittenCondition, BoundStatement rewrittenIncrement, BoundStatement rewrittenBody) { if (node.InnerLocals.IsEmpty) { return RewriteForStatementWithoutInnerLocals( node, node.OuterLocals, rewrittenInitializer, rewrittenCondition, rewrittenIncrement, rewrittenBody, node.BreakLabel, node.ContinueLabel, node.HasErrors); } // We need to enter inner_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. // for (initializer; condition; increment) // body; // // becomes the following (with block added for locals) // // { // initializer; // start: // { // GotoIfFalse condition break; // body; // continue: // increment; // goto start; // } // break: // } Debug.Assert(rewrittenBody != null); SyntaxNode syntax = node.Syntax; var statementBuilder = ArrayBuilder<BoundStatement>.GetInstance(); // initializer; if (rewrittenInitializer != null) { statementBuilder.Add(rewrittenInitializer); } var startLabel = new GeneratedLabelSymbol("start"); // start: BoundStatement startLabelStatement = new BoundLabelStatement(syntax, startLabel); if (Instrument) { startLabelStatement = new BoundSequencePoint(null, startLabelStatement); } statementBuilder.Add(startLabelStatement); var blockBuilder = ArrayBuilder<BoundStatement>.GetInstance(); // GotoIfFalse condition break; if (rewrittenCondition != null) { BoundStatement ifNotConditionGotoBreak = new BoundConditionalGoto(rewrittenCondition.Syntax, rewrittenCondition, false, node.BreakLabel); if (this.Instrument) { ifNotConditionGotoBreak = _instrumenter.InstrumentForStatementConditionalGotoStartOrBreak(node, ifNotConditionGotoBreak); } blockBuilder.Add(ifNotConditionGotoBreak); } // body; blockBuilder.Add(rewrittenBody); // continue: // increment; blockBuilder.Add(new BoundLabelStatement(syntax, node.ContinueLabel)); if (rewrittenIncrement != null) { blockBuilder.Add(rewrittenIncrement); } // goto start; blockBuilder.Add(new BoundGotoStatement(syntax, startLabel)); statementBuilder.Add(new BoundBlock(syntax, node.InnerLocals, blockBuilder.ToImmutableAndFree())); // break: statementBuilder.Add(new BoundLabelStatement(syntax, node.BreakLabel)); var statements = statementBuilder.ToImmutableAndFree(); return new BoundBlock(syntax, node.OuterLocals, statements, node.HasErrors); }
public override BoundStatement InstrumentForStatementGotoEnd(BoundForStatement original, BoundStatement gotoEnd) { return(ForStatementCreateGotoEndSequencePoint(base.InstrumentForStatementGotoEnd(original, gotoEnd))); }
public override BoundStatement InstrumentForStatementConditionalGotoStart(BoundForStatement original, BoundStatement branchBack) { return Previous.InstrumentForStatementConditionalGotoStart(original, branchBack); }
private BoundStatement RewriteForStatement( BoundForStatement node, BoundStatement rewrittenInitializer, BoundExpression rewrittenCondition, BoundStatement rewrittenIncrement, BoundStatement rewrittenBody) { if (node.InnerLocals.IsEmpty) { return(RewriteForStatementWithoutInnerLocals( node, node.OuterLocals, rewrittenInitializer, rewrittenCondition, rewrittenIncrement, rewrittenBody, node.BreakLabel, node.ContinueLabel, node.HasErrors)); } // We need to enter inner_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. // for (initializer; condition; increment) // body; // // becomes the following (with block added for locals) // // { // initializer; // start: // { // GotoIfFalse condition break; // body; // continue: // increment; // goto start; // } // break: // } Debug.Assert(rewrittenBody != null); SyntaxNode syntax = node.Syntax; var statementBuilder = ArrayBuilder <BoundStatement> .GetInstance(); // initializer; if (rewrittenInitializer != null) { statementBuilder.Add(rewrittenInitializer); } var startLabel = new GeneratedLabelSymbol("start"); // start: BoundStatement startLabelStatement = new BoundLabelStatement(syntax, startLabel); if (Instrument) { startLabelStatement = new BoundSequencePoint(null, startLabelStatement); } statementBuilder.Add(startLabelStatement); var blockBuilder = ArrayBuilder <BoundStatement> .GetInstance(); // GotoIfFalse condition break; if (rewrittenCondition != null) { BoundStatement ifNotConditionGotoBreak = new BoundConditionalGoto(rewrittenCondition.Syntax, rewrittenCondition, false, node.BreakLabel); if (this.Instrument) { ifNotConditionGotoBreak = _instrumenter.InstrumentForStatementConditionalGotoStartOrBreak(node, ifNotConditionGotoBreak); } blockBuilder.Add(ifNotConditionGotoBreak); } // body; blockBuilder.Add(rewrittenBody); // continue: // increment; blockBuilder.Add(new BoundLabelStatement(syntax, node.ContinueLabel)); if (rewrittenIncrement != null) { blockBuilder.Add(rewrittenIncrement); } // goto start; blockBuilder.Add(new BoundGotoStatement(syntax, startLabel)); statementBuilder.Add(new BoundBlock(syntax, node.InnerLocals, blockBuilder.ToImmutableAndFree())); // break: statementBuilder.Add(new BoundLabelStatement(syntax, node.BreakLabel)); var statements = statementBuilder.ToImmutableAndFree(); return(new BoundBlock(syntax, node.OuterLocals, statements, node.HasErrors)); }
public override BoundExpression InstrumentForStatementCondition(BoundForStatement 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.InstrumentForStatementCondition(original, rewrittenCondition, factory), original.Syntax, factory)); }
public virtual BoundExpression InstrumentForStatementCondition(BoundForStatement original, BoundExpression rewrittenCondition, SyntheticBoundNodeFactory factory) { Debug.Assert(!original.WasCompilerGenerated); Debug.Assert(original.Syntax.Kind() == SyntaxKind.ForStatement); Debug.Assert(factory != null); return rewrittenCondition; }
public virtual BoundStatement InstrumentForStatementGotoEnd(BoundForStatement original, BoundStatement gotoEnd) { Debug.Assert(!original.WasCompilerGenerated); Debug.Assert(original.Syntax.Kind() == SyntaxKind.ForStatement); return(gotoEnd); }
public override BoundNode VisitForStatement(BoundForStatement node) { throw ExceptionUtilities.Unreachable; // for statements have been lowered away by now }
public override BoundStatement InstrumentForStatementGotoEnd(BoundForStatement original, BoundStatement gotoEnd) { return(Previous.InstrumentForStatementGotoEnd(original, gotoEnd)); }
public override BoundStatement InstrumentForStatementConditionalGotoStart(BoundForStatement original, BoundStatement branchBack) { // hidden sequence point if there is no condition return(new BoundSequencePoint(original.Condition?.Syntax, base.InstrumentForStatementConditionalGotoStart(original, branchBack))); }
public virtual BoundStatement InstrumentForStatementGotoEnd(BoundForStatement original, BoundStatement gotoEnd) { Debug.Assert(!original.WasCompilerGenerated); Debug.Assert(original.Syntax.Kind() == SyntaxKind.ForStatement); return gotoEnd; }
public override BoundStatement InstrumentForStatementGotoEnd(BoundForStatement original, BoundStatement gotoEnd) { return Previous.InstrumentForStatementGotoEnd(original, gotoEnd); }