예제 #1
0
        protected virtual BoundExpression RewriteCallExpression(BoundCallExpression node)
        {
            ImmutableArray <BoundExpression> .Builder builder = null;
            for (var i = 0; i < node.Arguments.Length; ++i)
            {
                var expression = RewriteExpression(node.Arguments[i]);
                if (expression != node.Arguments[i])
                {
                    if (builder == null)
                    {
                        builder = ImmutableArray.CreateBuilder <BoundExpression>(node.Arguments.Length);
                        for (var j = 0; j < i; ++j)
                        {
                            builder.Add(node.Arguments[j]);
                        }
                    }
                }

                if (builder != null)
                {
                    builder.Add(expression);
                }
            }

            if (builder == null)
            {
                return(node);
            }
            return(new BoundCallExpression(node.Function, builder.MoveToImmutable()));
        }
        private static void WriteCallExpression(BoundCallExpression node, IndentedTextWriter writer)
        {
            writer.WriteIdentifier(node.Function.Name);
            writer.WritePunctuation(SyntaxKind.OpenParenthesisToken);

            var isFirst = true;

            foreach (var arg in node.Arguments)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    writer.WritePunctuation(SyntaxKind.CommaToken);
                }

                arg.WriteTo(writer);
            }

            writer.WritePunctuation(SyntaxKind.CloseParenthesisToken);
        }