protected override BoundStatement RewriteDoWhileStatement(BoundDoWhileStatement node) { // do // <body> // while <condition> // // -----> // // body: // <body> // continue: // gotoTrue <condition> body // break: var bodyLabel = GenerateLabel(); var result = Block( node.Syntax, Label(node.Syntax, bodyLabel), node.Body, Label(node.Syntax, node.ContinueLabel), GotoTrue(node.Syntax, bodyLabel, node.Condition), Label(node.Syntax, node.BreakLabel) ); return(RewriteStatement(result)); }
protected override BoundStatement RewriteDoWhileStatement(BoundDoWhileStatement node) { // do // <body> // while <condition> // // -----> // // continue: // <body> // gotoTrue <condition> continue // var continueLabelStatement = new BoundLabelStatement(node.ContinueLabel); var gotoTrue = new BoundConditionalGotoStatement(node.ContinueLabel, node.Condition); var breakLabelStatement = new BoundLabelStatement(node.BreakLabel); var result = new BoundBlockStatement(ImmutableArray.Create <BoundStatement>( continueLabelStatement, node.Body, gotoTrue, breakLabelStatement )); return(RewriteStatement(result)); }
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)); }
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)); }
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 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)); }