Пример #1
0
        protected virtual BoundExpression RewriteCallExpression(BoundCallExpression node)
        {
            ImmutableArray <BoundExpression> .Builder builder = null;

            for (int i = 0; i < node.Arguments.Length; i++)
            {
                BoundExpression oldArgument = node.Arguments[i];
                BoundExpression newArgument = RewriteExpression(oldArgument);

                if (newArgument != oldArgument)
                {
                    if (builder == null)
                    {
                        builder = ImmutableArray.CreateBuilder <BoundExpression>(node.Arguments.Length);

                        for (int j = 0; j < i; j++)
                        {
                            builder.Add(node.Arguments[j]);
                        }
                    }
                }

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

            if (builder == null)
            {
                return(node);
            }

            return(new BoundCallExpression(node.Function, builder.MoveToImmutable()));
        }
Пример #2
0
        private static void WriteCallExpression(BoundCallExpression node, IndentedTextWriter writer)
        {
            writer.WriteIdentifier(node.Function.Name);
            writer.WritePunctuation(SyntaxKind.OpenParenthesisToken);

            bool isFirst = true;

            foreach (BoundExpression argument in node.Arguments)
            {
                if (isFirst)
                {
                    isFirst = false;
                }
                else
                {
                    writer.WritePunctuation(SyntaxKind.CommaToken);
                    writer.WriteWhiteSpace();
                }

                argument.WriteTo(writer);
            }

            writer.WritePunctuation(SyntaxKind.CloseParenthesisToken);
        }