public static StatementSyntax Transpile(this Syntax.IfStatementSyntax ifStatementNode) { _ = ifStatementNode ?? throw new ArgumentNullException(nameof(ifStatementNode)); var ifStatement = SyntaxFactory.IfStatement( ifStatementNode.ConditionExpressionNode.Transpile(), SyntaxFactory.Block(ifStatementNode.StatementListNode.Transpile())); return(ifStatementNode.EmptyElseClauseNode is null ? ifStatement.WithElse(ifStatementNode.ElseClauseNode.Transpile()) : ifStatement); }
public static void Transpile(this Syntax.IfStatementSyntax ifStatementNode, ref StringBuilder sb) { _ = ifStatementNode ?? throw new ArgumentNullException(nameof(ifStatementNode)); sb.Append("if "); ifStatementNode.ConditionExpressionNode.Transpile(ref sb); sb.Append(" then"); sb.AppendLine(); ifStatementNode.StatementListNode.Transpile(ref sb); if (ifStatementNode.EmptyElseClauseNode is null) { ifStatementNode.ElseClauseNode.Transpile(ref sb); } else { sb.Append("end"); } }