Ejemplo n.º 1
0
        /////////////////////////////////////////////////////////////////////////////////////////////////////
        public MapType substituteMap(TypeParameterInstantiation instantiation)
        {
            foreach (var tp in typeParameters)
            {
                Debug.Assert(instantiation.map(tp) == null);
            }

//            Debug.Assert(mapTypeArguments.Length == mapTypeArguments.Length);
            bool clone = false;

            var newDomain = new IType[domain.Count()];

            for (int i = 0; i < domain.Count(); i++)
            {
                newDomain[i] = domain[i].substitute(instantiation);
                if (newDomain[i] != domain[i])
                {
                    clone = true;
                }
            }
            IType newRange = range.substitute(instantiation);

            if (newRange != range)
            {
                clone = true;
            }

            TypeConstructorInstance newOriginalType = substituteOriginalType(instantiation);

            if (newOriginalType != originalType)
            {
                clone = true;
            }

            MapType result;

            if (clone)
            {
                result = new MapType((TypeVariable[])typeParameters.Clone(), newDomain, newRange, newOriginalType);
                result.originalSubstitution = this;
            }
            else
            {
                result = this;
            }

            return(result);
        }
Ejemplo n.º 2
0
        public MapType(TypeVariable[] typeParameters, IEnumerable <IType> domain, IType range,
                       TypeConstructorInstance originalType)
        {
            Debug.Assert(typeParameters != null);
            Debug.Assert(domain != null);
            Debug.Assert(range != null);
            Debug.Assert(domain.All(xx => xx != null));


            this.typeParameters = new TypeVariable[typeParameters.Length];
            for (int i = 0; i < typeParameters.Length; i++)
            {
                this.typeParameters[i] = typeParameters[i];
            }

            this.domain = TypeTuple.make(domain);
            this.range  = range;

            this.originalType = originalType;
        }