Exemplo n.º 1
0
        public override string VisitStructValueExpr(AstStructValueExpr str, int data = 0)
        {
            const int maxOnOneLine = 4;

            var sep = ", ";

            if (str.MemberInitializers.Count() > maxOnOneLine)
            {
                sep = "\n";
            }
            var body = string.Join(sep, str.MemberInitializers.Select(m => m.Name != null ? $"{m.Name.Accept(this)} = {m.Value.Accept(this, 0)}" : m.Value.Accept(this, 0)));

            if (str.MemberInitializers.Count() > maxOnOneLine)
            {
                body = $"{{\n{body.Indent(4)}\n}}";
            }
            else
            {
                body = $"{{ {body} }}";
            }

            if (str.TypeExpr != null)
            {
                return($"new {str.TypeExpr.Accept(this)} {body}");
            }
            else
            {
                return($"new {body}");
            }
        }
Exemplo n.º 2
0
 public virtual ReturnType VisitStructValueExpr(AstStructValueExpr expr, DataType data = default) => default;