Example #1
0
        private void RegisterType(Type type)
        {
            Contract.Requires(type != null);
            if (KnownTypes.Contains(type))
            {
                return;
            }

            if (type.IsMap && CommandLineOptions.Clo.TypeEncodingMethod == CommandLineOptions.TypeEncoding.Monomorphic)
            {
                KnownTypes.Add(type);
                MapType mapType = type.AsMap;
                Contract.Assert(mapType != null);

                foreach (Type t in mapType.Arguments)
                {
                    Contract.Assert(t != null);
                    RegisterType(t);
                }
                RegisterType(mapType.Result);

                if (!CommandLineOptions.Clo.UseArrayTheory)
                {
                    AddDeclaration("(declare-sort " + TypeToString(type) + " 0)");
                }

                return;
            }

            if (type.IsBool || type.IsInt || type.IsReal || type.IsBv || type.IsFloat || type.IsRMode || type.IsString || type.IsRegEx)
            {
                return;
            }

            CtorType ctorType = type as CtorType;

            if (ctorType != null)
            {
                // Check if this is a built-in type.  If so, no declaration is needed.
                string decl = ctorType.GetBuiltin();
                if (decl != null)
                {
                    KnownTypes.Add(type);
                    return;
                }
                if (ctorType.IsDatatype())
                {
                    return;
                }
            }

            if (CommandLineOptions.Clo.TypeEncodingMethod == CommandLineOptions.TypeEncoding.Monomorphic)
            {
                AddDeclaration("(declare-sort " + TypeToString(type) + " 0)");
                KnownTypes.Add(type);
                return;
            }
        }