protected override BoundExpression RewriteWhileExpression(BoundWhileExpression node) { /* * while <condition> * <body> * * <whileLabel> * gotoIfFalse <condition> <endLabel> * <body> * goto <whileLabel> * <endLabel> */ var body = RewriteExpression(node.Body); var condition = RewriteExpression(node.Condition); return(RewriteExpression( new BoundBlockExpression( node.Syntax, ImmutableArray.Create <BoundStatement>( new BoundLabelStatement(node.Syntax, node.ContinueLabel), new BoundConditionalGotoStatement(node.Syntax, node.BreakLabel, condition), new BoundExpressionStatement(node.Syntax, body), new BoundGotoStatement(node.Syntax, node.ContinueLabel), new BoundLabelStatement(node.Syntax, node.BreakLabel) ), new BoundUnitExpression(node.Syntax) ) )); }
public override void VisitWhileExpression(BoundWhileExpression node) { _writer.WriteKeyword("while "); _writer.WritePunctuation("("); node.Condition.Accept(this); _writer.WritePunctuation(") "); _writer.WriteLine(); WriteNestedExpression(node.Body); }
public virtual void VisitWhileExpression(BoundWhileExpression node) => this.DefaultVisit(node);
protected override BoundExpression RewriteWhileExpression(BoundWhileExpression node) { throw new InvalidProgramException("No `while` expression should exist at this stage"); }