public StructSortMapping(CompilationInfo info, INamedTypeSymbol symbol)
            : base(info)
        {
            Symbol = symbol;
            // The order of the following array fixes the order of the fields in the tuple
            FieldSymbols = Symbol.GetMembers().OfType <IFieldSymbol>().ToArray();
            if (!FieldSymbols.All(s => !s.IsStatic))
            {
                throw new SyntaxErrorException("Static fields are not supported");
            }
            // Get the sort mappings for the fields
            var fieldInfo = FieldSymbols.Select(s => new { Symbol = s, Mapping = Mapper.GetSortMapping(s.Type) });

            // Create the tuplesort with the fields' sorts
            Sort = Ctx.MkTupleSort(Mapper.CreateZ3Symbol(Symbol),
                                   fieldInfo.Select(x => Mapper.CreateZ3Symbol(x.Symbol)).ToArray(),
                                   fieldInfo.Select(x => x.Mapping.Sort).ToArray());
            FieldSortMappings = fieldInfo.Select(x => x.Mapping).ToArray();
            Mapper.RegisterStructSortMapping(this);
        }
        public override Mutator MutatorForDefaultValue()
        {
            // The declaration of the struct is processed to find any field initializations. Fields get their initial values from
            // the declaration, or if no initial value is declared then the default value for the type is used.
            var fieldMutators = new List <Mutator>();
            var evaluator     = new DefaultValueEvaluator(_info);

            foreach (var field in FieldSymbols.Zip(FieldSortMappings, (Symbol, SortMapping) => new { Symbol, SortMapping }))
            {
                Mutator fieldMutator;
                var     declarations = field.Symbol.DeclaringSyntaxReferences.Select(r => r.GetSyntax()).OfType <VariableDeclaratorSyntax>().ToList();

                if (declarations.Count > 1)
                {
                    throw new SyntaxErrorException("Multiple declarations found for " + field + " in " + Symbol);
                }
                else if (declarations.Count == 0)
                {
                    throw new SyntaxErrorException("Declaration of field " + field + " in " + Symbol + " not found");
                }
                var declaration = declarations[0];
                if (declaration.Initializer != null)
                {
                    fieldMutator = evaluator.Visit(declaration.Initializer) as Mutator;
                    if (fieldMutator == null)
                    {
                        throw new SyntaxErrorException("Unsupported syntax: " + declaration);
                    }
                }
                else
                {
                    fieldMutator = field.SortMapping.MutatorForDefaultValue();
                }
                fieldMutators.Add(fieldMutator);
            }
            return(new StructMutator(this, fieldMutators));
        }