protected override BoundStatement RewriteDoWhileStatement(BoundDoWhileStatement node) { // do // <body> // while <condition> // // -----> // // continue: // <body> // gotoTrue <condition> continue // var continueLabel = GenerateLabel(); var continueLabelStatement = new BoundLabelStatement(continueLabel); var gotoTrue = new BoundConditionalGotoStatement(continueLabel, node.Condition); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( continueLabelStatement, node.Body, gotoTrue )); return(RewriteStatement(result)); }
protected override BoundStatement RewriteIfStatement(BoundIfStatement node) { if (node.ElseStatement == null) { var endLabel = GenerateLabel("EndIf"); var gotoFalse = new BoundConditionalGotoStatement(endLabel, node.Condition, false); var endLabelStatement = new BoundLabelStatement(endLabel); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( gotoFalse, node.ThenStatement, endLabelStatement )); return(RewriteStatement(result)); } else { var endLabel = GenerateLabel("EndIf"); var elseLabel = GenerateLabel("IfElse"); var gotoFalse = new BoundConditionalGotoStatement(elseLabel, node.Condition, false); var gotoEndStatement = new BoundGotoStatement(endLabel); var elseLabelStatement = new BoundLabelStatement(elseLabel); var endLabelStatement = new BoundLabelStatement(endLabel); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( gotoFalse, node.ThenStatement, gotoEndStatement, elseLabelStatement, node.ElseStatement, endLabelStatement )); return(RewriteStatement(result)); } }
protected override BoundStatement RewriteWhileStatement(BoundWhileStatement node) { // while <condition> // <body> // // ---> // // goto check // continue: // <body> // check: // gotoTrue <condition> continue // break: // var checkLabel = GenerateLabel("Check"); var gotoCheck = new BoundGotoStatement(checkLabel); var continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); var checkLabelStatement = new BoundLabelStatement(checkLabel); var gotoTrue = new BoundConditionalGotoStatement(node.ContinueLabel, node.Condition); var breakLabelStatement = new BoundLabelStatement(node.BreakLabel); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( gotoCheck, continueLabelStatement, node.Body, checkLabelStatement, gotoTrue, breakLabelStatement )); return(RewriteStatement(result)); }
/// <inheritdoc/> protected override BoundStatement RewriteForInfiniteStatement(BoundForInfiniteStatement node) { // for // <body> // // ----> // // { // continue: // <body> // goto continue // break: // } var continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); var gotoContinue = new BoundGotoStatement(node.ContinueLabel); var breakLabelStatement = new BoundLabelStatement(node.BreakLabel); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( continueLabelStatement, node.Body, gotoContinue, breakLabelStatement)); return(RewriteStatement(result)); }
protected override BoundStatement RewriteWhileStatement(BoundWhileStatement node) { // while <condition> <body> // --- to ---> // { // continue: // gotoFalse <condition> break // <body> // goto continue // break: // } var continueLabel = node.ContinueLabel; var breakLabel = node.BreakLabel; var continueStatement = new BoundLabelStatement(continueLabel); var gotoFalseStatement = new BoundConditionalGotoStatement(breakLabel, node.Condition, jumpIfTrue: false); var gotoContinue = new BoundGotoStatement(continueLabel); var breakStatement = new BoundLabelStatement(breakLabel); var result = new BoundBlockStatement( continueStatement, gotoFalseStatement, node.Body, gotoContinue, breakStatement); return(RewriteStatement(result)); }
protected override BoundStatement RewriteWhileStatement(BoundWhileStatement node) { // while <condition> // <bode> // // -----> // // goto continue // <body> // continue: // gotoTrue <condition> body // Break // var gotoContinue = new BoundGotoStatment(node.ContinueLabel); var bodyLabelStatement = new BoundLabelStatement(node.BodyLabel); var continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); var gotoTrue = new BoundConditionalGotoStatment(node.BodyLabel, node.Condition); var breakLabelStatement = new BoundLabelStatement(node.BreakLabel); var result = new BoundBlockStatemnet(ImmutableArray.Create <BoundStatement>( gotoContinue, bodyLabelStatement, node.Body, continueLabelStatement, gotoTrue, breakLabelStatement )); return(RewriteStatement(result)); }
protected override BoundStatement RewriteWhileStatement(BoundWhileStatement node) { // goto continue // body: // <body> // continue: // goto body if <condition> // break: var bodyLabel = CreateLabel(); var gotoContinue = new BoundGotoStatement(node.ContinueLabel, node.IsValid); var gotoBody = new BoundConditionalGotoStatement(bodyLabel, node.Condition, jumpIfFalse: false, node.IsValid); var continueLabelStmt = new BoundLabelStatement(node.ContinueLabel, node.IsValid); var bodyLabelStmt = new BoundLabelStatement(bodyLabel, node.IsValid); var breakLabelStmt = new BoundLabelStatement(node.BreakLabel, node.IsValid); var res = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( gotoContinue, bodyLabelStmt, node.Body, continueLabelStmt, gotoBody, breakLabelStmt ), node.IsValid); return(RewriteStatement(res)); }
protected override BoundStatement RewriteIfStatement(BoundIfStatement node) { if (node.ElseStatement is null) { var endLabel = CreateLabel(); var gotoIfFalse = new BoundConditionalGotoStatement(endLabel, node.Condition, jumpIfFalse: true, node.IsValid); var endLabelStmt = new BoundLabelStatement(endLabel, node.IsValid); var res = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>(gotoIfFalse, node.Body, endLabelStmt), node.IsValid); return(RewriteStatement(res)); } else { var elseLabel = CreateLabel(); var endLabel = CreateLabel(); var gotoIfFalse = new BoundConditionalGotoStatement(elseLabel, node.Condition, jumpIfFalse: true, node.IsValid); var gotoEnd = new BoundGotoStatement(endLabel, node.IsValid); var elseLabelStmt = new BoundLabelStatement(elseLabel, node.IsValid); var endLabelStmt = new BoundLabelStatement(endLabel, node.IsValid); var res = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( gotoIfFalse, node.Body, gotoEnd, elseLabelStmt, node.ElseStatement, endLabelStmt ), node.IsValid); return(RewriteStatement(res)); } }
protected override BoundStatement RewriteDoWhileStatement(BoundDoWhileStatement node) { // do // <body> // while <condition> // // ----> // // body: // <body> // continue: // gotoTrue <condition> body // break: var bodyLabel = GenerateLabel(); var bodyLabelStatement = new BoundLabelStatement(bodyLabel); var continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); var gotoTrue = new BoundConditionalGotoStatement(bodyLabel, node.Condition, jumpIfTrue: true); var breakLabelStatement = new BoundLabelStatement(node.BreakLabel); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( bodyLabelStatement, node.Body, continueLabelStatement, gotoTrue, breakLabelStatement )); return(RewriteStatement(result)); }
public override BoundNode VisitLabelStatement(BoundLabelStatement node) { if (IsInside) { _labelsInside.Add(node.Label); } return(base.VisitLabelStatement(node)); }
protected override BoundStatement RewriteIfStatement(BoundIfStatement node) { if (node.ElseStatement == null) { // if <condition> // <then> // // ----> // // gotoFalse <condition> end // <then> // end: // var endLabel = GenerateLabel(); var gotoFalse = new BoundConditionalGotoStatement(endLabel, node.Condition, false); var endLabelStatement = new BoundLabelStatement(endLabel); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>(gotoFalse, node.ThenStatement, endLabelStatement)); return(RewriteStatement(result)); } else { // if <condition> // <then> // else // <else> // // ----> // // gotoFalse <condition> else // <then> // goto end // else: // <else> // end: var elseLabel = GenerateLabel(); var endLabel = GenerateLabel(); var gotoFalse = new BoundConditionalGotoStatement(elseLabel, node.Condition, false); var gotoEndStatement = new BoundGotoStatement(endLabel); var elseLabelStatement = new BoundLabelStatement(elseLabel); var endLabelStatement = new BoundLabelStatement(endLabel); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( gotoFalse, node.ThenStatement, gotoEndStatement, elseLabelStatement, node.ElseStatement, endLabelStatement )); return(RewriteStatement(result)); } }
protected override BoundStatement RewriteForStatement(BoundForStatement node) { // for <var> = <lower> to <upper> // <body> // // ----> // { // var <var> = <lower> // let upperBound = <upper> // while (<var> <= upperBound) // { // <body> // continue: // <var> = <var> + 1 // } // } var variableDeclaration = new BoundVariableDeclaration(node.Variable, node.LowerBound); var variableExpression = new BoundVariableExpression(node.Variable); var upperBoundSymbol = new LocalVariableSymbol("upperBound", true, TypeSymbol.Int); var upperBoundDeclaration = new BoundVariableDeclaration(upperBoundSymbol, node.UpperBound); var condition = new BoundBinaryExpression( variableExpression, BoundBinaryOperator.Bind(SyntaxKind.LessOrEqualsToken, TypeSymbol.Int, TypeSymbol.Int), new BoundVariableExpression(upperBoundSymbol) ); var continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); var increment = new BoundExpressionStatement( new BoundAssignmentExpression( node.Variable, new BoundBinaryExpression( variableExpression, BoundBinaryOperator.Bind(SyntaxKind.PlusToken, TypeSymbol.Int, TypeSymbol.Int), new BoundLiteralExpression(1) ) ) ); var whileBody = new BoundBlockStatement( ImmutableArray.Create <BoundStatement>( node.Body, continueLabelStatement, increment ) ); var whileStatement = new BoundWhileStatement(condition, whileBody, node.BreakLabel, GenerateLabel()); var result = new BoundBlockStatement( ImmutableArray.Create <BoundStatement>( variableDeclaration, upperBoundDeclaration, whileStatement ) ); return(RewriteStatement(result)); }
protected override BoundStatement RewriteConditionalStatement(BoundConditionalStatement node) { if (node.ElseStatement is null) { // if <condition> <then> // --- to ---> // { // gotoFalse <condition> end // <then> // end: // } var endLabel = GenerateLabel("end"); var gotoFalse = new BoundConditionalGotoStatement(endLabel, node.Condition, false); var endLabelStatement = new BoundLabelStatement(endLabel); var result = new BoundBlockStatement( gotoFalse, node.ThenStatement, endLabelStatement); return(RewriteStatement(result)); } else { // if <condition> <then> else <else> // --- to ---> // { // gotoFalse <condition> else // <then> // goto end // else: // <else> // end: // } var endLabel = GenerateLabel("end"); var elseLabel = GenerateLabel("else"); var gotoFalse = new BoundConditionalGotoStatement(elseLabel, node.Condition, false); var gotoEnd = new BoundGotoStatement(endLabel); var elseLabelStatement = new BoundLabelStatement(elseLabel); var endLabelStatement = new BoundLabelStatement(endLabel); var result = new BoundBlockStatement( gotoFalse, node.ThenStatement, gotoEnd, elseLabelStatement, node.ElseStatement, endLabelStatement); return(RewriteStatement(result)); } }
protected override BoundStatement RewriteForStatement(BoundForStatement node) { var initializer = new BoundExpressionStatement(node.Initializer); var loop = new BoundExpressionStatement(node.Loop); var continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); var whileBlock = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>(node.Body, continueLabelStatement, loop)); var whileStatement = new BoundWhileStatement(node.Condition, whileBlock, node.BreakLabel, GenerateLabel()); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>(initializer, whileStatement)); return(RewriteStatement(result)); }
internal void Parse(BoundLabelStatement boundLabelStatement) { if (boundLabelStatement == null) { throw new ArgumentNullException(); } var localLabel = new Label(); localLabel.Parse(boundLabelStatement.Label); this.Label = localLabel; }
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))); }
public override BoundNode VisitLabeledStatement(BoundLabeledStatement node) { Debug.Assert(node != null); var rewrittenBody = (BoundStatement)Visit(node.Body); var labelStatement = new BoundLabelStatement(node.Syntax, node.Label); if (rewrittenBody == null) { // Body may be null if the body has no associated IL // (declaration with no initializer for instance.) return labelStatement; } return BoundStatementList.Synthesized(node.Syntax, labelStatement, rewrittenBody); }
protected override BoundStatement RewriteDoWhileStatement(BoundDoWhileStatement node) { var continueLabelStmt = new BoundLabelStatement(node.ContinueLabel, node.IsValid); var breakLabelStmt = new BoundLabelStatement(node.BreakLabel, node.IsValid); var gotoContinue = new BoundConditionalGotoStatement(node.ContinueLabel, node.Condition, jumpIfFalse: false, node.IsValid); var res = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( continueLabelStmt, node.Body, gotoContinue, breakLabelStmt ), node.IsValid); return(RewriteStatement(res)); }
private static void WriteBoundLabelStatement(this IndentedTextWriter writer, BoundLabelStatement node) { if (writer is IndentedTextWriter iw) { iw.Indent -= 4; iw.ColorWrite(node.Label.Identifier + ":", ConsoleColor.DarkGray); iw.Indent += 4; } else { var iw2 = new IndentedTextWriter(writer); iw2.Indent -= 4; iw2.ColorWrite(node.Label.Identifier + ":", ConsoleColor.DarkGray); iw2.Indent += 4; } }
protected override BoundStatement RewriteIfStatement(BoundIfStatement node) { /* * gotoIfFalse <condition> end * <Then> * end: * * gotoIfFalse <condition> else * <Then> * goto end * else: * <Else> * end: */ BoundBlockStatement result; if (node.ElseClause is null) { result = Create(); } else { result = CreateWithElse(); } return(RewriteStatement(result)); BoundBlockStatement Create() { var endLabelStatement = new BoundLabelStatement(GenerateLabel()); var gotoIfFalseStatement = new BoundConditionalGotoStatement(endLabelStatement.Label, node.Condition, false); return(new BoundBlockStatement(ImmutableArray.Create <BoundStatement>(gotoIfFalseStatement, node.Statement, endLabelStatement))); } BoundBlockStatement CreateWithElse() { var elseLabelStatement = new BoundLabelStatement(GenerateLabel()); var endLabelStatement = new BoundLabelStatement(GenerateLabel()); var gotoIfFalseStatement = new BoundConditionalGotoStatement(elseLabelStatement.Label, node.Condition, false); var gotoEndStatement = new BoundGotoStatement(endLabelStatement.Label); var statements = ImmutableArray.Create <BoundStatement>(gotoIfFalseStatement, node.Statement, gotoEndStatement, elseLabelStatement, node.ElseClause, endLabelStatement); return(new BoundBlockStatement(statements)); } }
public override BoundNode VisitLabeledStatement(BoundLabeledStatement node) { Debug.Assert(node != null); var rewrittenBody = (BoundStatement)Visit(node.Body); var labelStatement = new BoundLabelStatement(node.Syntax, node.Label); if (rewrittenBody == null) { // Body may be null if the body has no associated IL // (declaration with no initializer for instance.) return(labelStatement); } return(BoundStatementList.Synthesized(node.Syntax, labelStatement, rewrittenBody)); }
public override void VisitLabelStatement(BoundLabelStatement node) { var dedent = (_writer.Indent > 0); if (dedent) { _writer.Indent--; } _writer.WritePunctuation(node.BoundLabel.Name); _writer.WritePunctuation(":"); _writer.WriteLine(); if (dedent) { _writer.Indent++; } }
protected override BoundStatement RewriteWhileStatement(BoundWhileStatement node) { /* * check: * gotoIfFalse <condition> end * <statement> * goto check * end: */ var checkLabelStatement = new BoundLabelStatement(GenerateLabel()); var endLabelStatement = new BoundLabelStatement(GenerateLabel()); var gotoIfFalseStatement = new BoundConditionalGotoStatement(endLabelStatement.Label, node.Condition, false); var gotoCheckStatement = new BoundGotoStatement(checkLabelStatement.Label); var statements = ImmutableArray.Create <BoundStatement>(checkLabelStatement, gotoIfFalseStatement, node.Statement, gotoCheckStatement, endLabelStatement); var result = new BoundBlockStatement(statements); return(RewriteStatement(result)); }
protected override BoundStatement RewriteDoWhileStatement(BoundDoWhileStatement node) { var bodyLabel = GenerateLabel(); var bodyLabelStatement = new BoundLabelStatement(bodyLabel); var continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); var gotoTrue = new BoundConditionalGotoStatement(bodyLabel, node.Condition); var breakLabelStatement = new BoundLabelStatement(node.BreakLabel); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( bodyLabelStatement, node.Body, continueLabelStatement, gotoTrue, breakLabelStatement )); return(RewriteStatement(result)); }
protected override BoundStatement RewriteForStatement(BoundForStatement node) { var condition = node.Condition; var continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); var increment = new BoundExpressionStatement( node.Action ); var whileBody = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( node.Body, continueLabelStatement, increment) ); var whileStatement = new BoundWhileStatement(condition, whileBody, node.BreakLabel, GenerateLabel()); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( node.Variable, whileStatement )); return(RewriteStatement(result)); }
protected override BoundStatement RewriteDoWhileStatement(BoundDoWhileStatement node) { BoundLabel bodyLabel = GenerateLabel(); BoundLabel endLabel = new BoundLabel("End"); BoundLabelStatement bodyLabelStatement = new BoundLabelStatement(bodyLabel); BoundLabelStatement continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); BoundConditionalGotoStatement gotoTrue = new BoundConditionalGotoStatement(bodyLabel, node.Condition, true); BoundLabelStatement breakLabelStatement = new BoundLabelStatement(node.BreakLabel); BoundLabelStatement endLabelStatement = new BoundLabelStatement(endLabel); BoundBlockStatement result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( bodyLabelStatement, node.Body, continueLabelStatement, gotoTrue, breakLabelStatement, endLabelStatement )); return(RewriteStatement(result)); }
private BoundStatement MakeLabeledStatement(BoundLabeledStatement node, BoundStatement rewrittenBody) { BoundStatement labelStatement = new BoundLabelStatement(node.Syntax, node.Label); if (this.Instrument) { var labeledSyntax = node.Syntax as LabeledStatementSyntax; if (labeledSyntax != null) { labelStatement = _instrumenter.InstrumentLabelStatement(node, labelStatement); } } if (rewrittenBody == null) { // Body may be null if the body has no associated IL // (declaration with no initializer for instance.) return(labelStatement); } return(BoundStatementList.Synthesized(node.Syntax, labelStatement, rewrittenBody)); }
protected override BoundStatement RewriteForStatement(BoundForStatement node) { BoundVariableDeclaration variableDeclaration = new BoundVariableDeclaration(node.Variable, node.LowerBound); BoundVariableExpression variableExpression = new BoundVariableExpression(node.Variable); VariableSymbol upperVariableSymbol = new LocalVariableSymbol("upperBound", true, TypeSymbol.Int); BoundVariableDeclaration upperVariableDeclaration = new BoundVariableDeclaration(upperVariableSymbol, node.UpperBound); BoundBinaryExpression condition = new BoundBinaryExpression( variableExpression, BoundBinaryOperator.Bind(SyntaxKind.LessOrEqualsToken, TypeSymbol.Int, TypeSymbol.Int), new BoundVariableExpression(upperVariableSymbol) ); BoundLabelStatement continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); BoundExpressionStatement increment = new BoundExpressionStatement( new BoundAssignmentExpression( node.Variable, new BoundBinaryExpression( variableExpression, BoundBinaryOperator.Bind(SyntaxKind.PlusToken, TypeSymbol.Int, TypeSymbol.Int), new BoundLiteralExpression(1) ) ) ); BoundBlockStatement whileBody = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( node.Body, continueLabelStatement, increment )); BoundWhileStatement whileStatement = new BoundWhileStatement(condition, whileBody, node.BreakLabel, GenerateLabel()); BoundBlockStatement result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( variableDeclaration, upperVariableDeclaration, whileStatement )); return(RewriteStatement(result)); }
protected override BoundStatement RewriteTryCatchStatement(BoundTryCatchStatement node) { // try // <tryBody> // catch // <catchBody> // // ----> // // beginTry error // <tryBody> // endTry // goto end // error: // <catchBody> // end: var errorLabel = GenerateLabel(); var endLabel = GenerateLabel(); var beginTryStatement = new BoundBeginTryStatement(errorLabel); var endTryStatement = new BoundEndTryStatement(); var gotoEndStatement = new BoundGotoStatement(endLabel); var errorLabelStatement = new BoundLabelStatement(errorLabel); var endLabelStatement = new BoundLabelStatement(endLabel); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( beginTryStatement, node.TryBody, endTryStatement, gotoEndStatement, errorLabelStatement, node.CatchBody, endLabelStatement )); return(RewriteStatement(result)); }
protected override BoundStatement RewriteWhileStatement(BoundWhileStatement node) { // goto check: // continue: // <body> // check: // gotoTrue condition continue: // end: // ------------------------------------------------------- // later try out //- begin //- gotoFalse <condition> end //- <body> //- goto begin //- end var endLabel = GenerateLabel(); var checkLabel = GenerateLabel(); var continueLabel = GenerateLabel(); var gotoCheck = new BoundGotoStatement(checkLabel); var gotoTrue = new BoundConditionalGotoStatement(continueLabel, node.Condition); var continueLabelStatement = new BoundLabelStatement(continueLabel); var checkLabelStatement = new BoundLabelStatement(checkLabel); var endLabelStatement = new BoundLabelStatement(endLabel); var result = new BoundBlockStatement( ImmutableArray.Create <BoundStatement>( gotoCheck, continueLabelStatement, node.Body, checkLabelStatement, gotoTrue, endLabelStatement)); return(RewriteStatement(result)); }
/// <summary> /// To handle a label, we resolve all branches to that label. Returns true if the state of /// the label changes as a result. /// </summary> /// <param name="target"></param> /// <returns></returns> private bool ResolveBranches(BoundLabelStatement target) { bool labelStateChanged = false; var newPendingBranches = ArrayBuilder <PendingBranch> .GetInstance(); foreach (var pending in this.pendingBranches) { var branch = pending.Branch as BoundGotoStatement; if (branch != null && branch.Label == target.Label) { var state = LabelState(target.Label); NoteBranch(pending, branch, target); labelStateChanged |= state.Value.Join(pending.State); } else { newPendingBranches.Add(pending); } } this.pendingBranches.Free(); this.pendingBranches = newPendingBranches; return(labelStateChanged); }
public override BoundNode VisitLabelStatement(BoundLabelStatement node) { RecordLabel(node.Label); return base.VisitLabelStatement(node); }
private void EmitLabelStatement(BoundLabelStatement boundLabelStatement) { _builder.MarkLabel(boundLabelStatement.Label); }
public override BoundNode VisitLabelStatement(BoundLabelStatement node) { return node.Update(GetLabelClone(node.Label)); }
/// <summary> /// To handle a label, we resolve all branches to that label. Returns true if the state of /// the label changes as a result. /// </summary> /// <param name="target"></param> /// <returns></returns> private bool ResolveBranches(BoundLabelStatement target) { bool labelStateChanged = false; var newPendingBranches = ArrayBuilder<PendingBranch>.GetInstance(); foreach (var pending in this.pendingBranches) { var branch = pending.Branch as BoundGotoStatement; if (branch != null && branch.Label == target.Label) { var state = LabelState(target.Label); NoteBranch(pending, branch, target); labelStateChanged |= state.Value.Join(pending.State); } else { newPendingBranches.Add(pending); } } this.pendingBranches.Free(); this.pendingBranches = newPendingBranches; return labelStateChanged; }
/// <summary> /// Subclasses override this if they want to take special actions on processing a goto /// statement, when both the jump and the label have been located. /// </summary> /// <param name="pending"></param> /// <param name="gotoStmt"></param> /// <param name="labelStmt"></param> protected virtual void NoteBranch(PendingBranch pending, BoundGotoStatement gotoStmt, BoundLabelStatement labelStmt) { }