Beispiel #1
0
        protected virtual BoundStatement RewriteMatchStatement(BoundMatchStatement node)
        {
            var expr            = this.RewriteExpression(node.Expression);
            var patternSections = this.RewritePatternSectionStatements(node.PatternSections);

            if (expr == node.Expression && patternSections.SequenceEqual(node.PatternSections))
            {
                return(node);
            }

            return(new BoundMatchStatement(node.Syntax, expr, patternSections));
        }
Beispiel #2
0
        private static void WriteMatchStatement(BoundMatchStatement node, IndentedTextWriter writer)
        {
            writer.WriteKeyword(SyntaxKind.MatchKeyword);
            writer.WriteSpace();
            node.Expression.WriteTo(writer);
            writer.WriteLine();
            writer.WriteKeyword(SyntaxKind.OpenBraceToken);
            writer.Indent++;

            foreach (var patternSection in node.PatternSections)
            {
                patternSection.WriteTo(writer);
            }

            writer.Indent--;
            writer.WriteKeyword(SyntaxKind.CloseBraceToken);
        }