Пример #1
0
 public void AppendType(StringBuilder sb, TypeDesc type, bool forceValueClassPrefix = true)
 {
     // Types referenced from the IL show as instantiated over generic parameter.
     // E.g. "initobj !0" becomes "initobj !T"
     TypeDesc typeInContext = type.InstantiateSignature(
         _methodIL.OwningMethod.OwningType.Instantiation, _methodIL.OwningMethod.Instantiation);
     if (typeInContext.HasInstantiation || forceValueClassPrefix)
         this.TypeNameFormatter.AppendNameWithValueClassPrefix(sb, typeInContext);
     else
         this.TypeNameFormatter.AppendName(sb, typeInContext);
 }
Пример #2
0
        public override TypeDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            TypeDesc elementType             = this.ElementType;
            TypeDesc instantiatedElementType = elementType.InstantiateSignature(typeInstantiation, methodInstantiation);

            if (instantiatedElementType != elementType)
            {
                return(Context.GetArrayType(instantiatedElementType, _rank));
            }

            return(this);
        }
Пример #3
0
        public override MethodDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            TypeDesc owningType             = this.OwningType;
            TypeDesc instantiatedOwningType = owningType.InstantiateSignature(typeInstantiation, methodInstantiation);

            if (owningType != instantiatedOwningType)
            {
                return(((ArrayType)instantiatedOwningType).GetArrayMethod(_kind));
            }
            else
            {
                return(this);
            }
        }
Пример #4
0
        public virtual FieldDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            FieldDesc field = this;

            TypeDesc owningType             = field.OwningType;
            TypeDesc instantiatedOwningType = owningType.InstantiateSignature(typeInstantiation, methodInstantiation);

            if (owningType != instantiatedOwningType)
            {
                field = instantiatedOwningType.Context.GetFieldForInstantiatedType(field.GetTypicalFieldDefinition(), (InstantiatedType)instantiatedOwningType);
            }

            return(field);
        }
Пример #5
0
        public MethodSignature ApplySubstitution(Instantiation substitution)
        {
            if (substitution.IsNull)
            {
                return(this);
            }

            bool needsNewMethodSignature = false;

            TypeDesc[] newParameters = _parameters; // Re-use existing array until conflict appears
            TypeDesc   returnTypeNew = _returnType.InstantiateSignature(substitution, default(Instantiation));

            if (returnTypeNew != _returnType)
            {
                needsNewMethodSignature = true;
                newParameters           = (TypeDesc[])_parameters.Clone();
            }

            for (int i = 0; i < newParameters.Length; i++)
            {
                TypeDesc newParameter = newParameters[i].InstantiateSignature(substitution, default(Instantiation));
                if (newParameter != newParameters[i])
                {
                    if (!needsNewMethodSignature)
                    {
                        needsNewMethodSignature = true;
                        newParameters           = (TypeDesc[])_parameters.Clone();
                    }
                    newParameters[i] = newParameter;
                }
            }

            if (needsNewMethodSignature)
            {
                return(new MethodSignature(_flags, _genericParameterCount, returnTypeNew, newParameters, _embeddedSignatureData));
            }
            else
            {
                return(this);
            }
        }
Пример #6
0
        public virtual MethodDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            Instantiation instantiation = Instantiation;

            TypeDesc[] clone = null;

            for (int i = 0; i < instantiation.Length; i++)
            {
                TypeDesc uninst = instantiation[i];
                TypeDesc inst   = uninst.InstantiateSignature(typeInstantiation, methodInstantiation);
                if (inst != uninst)
                {
                    if (clone == null)
                    {
                        clone = new TypeDesc[instantiation.Length];
                        for (int j = 0; j < clone.Length; j++)
                        {
                            clone[j] = instantiation[j];
                        }
                    }
                    clone[i] = inst;
                }
            }

            MethodDesc method = this;

            TypeDesc owningType             = method.OwningType;
            TypeDesc instantiatedOwningType = owningType.InstantiateSignature(typeInstantiation, methodInstantiation);

            if (owningType != instantiatedOwningType)
            {
                method = Context.GetMethodForInstantiatedType(method.GetTypicalMethodDefinition(), (InstantiatedType)instantiatedOwningType);
                if (clone == null && instantiation.Length != 0)
                {
                    return(Context.GetInstantiatedMethod(method, instantiation));
                }
            }

            return((clone == null) ? method : Context.GetInstantiatedMethod(method.GetMethodDefinition(), new Instantiation(clone)));
        }
Пример #7
0
        public override TypeDesc InstantiateSignature(Instantiation typeInstantiation, Instantiation methodInstantiation)
        {
            TypeDesc[] clone = null;

            for (int i = 0; i < _instantiation.Length; i++)
            {
                TypeDesc uninst = _instantiation[i];
                TypeDesc inst   = uninst.InstantiateSignature(typeInstantiation, methodInstantiation);
                if (inst != uninst)
                {
                    if (clone == null)
                    {
                        clone = new TypeDesc[_instantiation.Length];
                        for (int j = 0; j < clone.Length; j++)
                        {
                            clone[j] = _instantiation[j];
                        }
                    }
                    clone[i] = inst;
                }
            }

            return((clone == null) ? this : _typeDef.Context.GetInstantiatedType(_typeDef, new Instantiation(clone)));
        }
 private TypeDesc Instantiate(TypeDesc type)
 {
     return(type.InstantiateSignature(_instantiatedType.Instantiation, new Instantiation()));
 }
Пример #9
0
 private TypeDesc Instantiate(TypeDesc type)
 {
     return type.InstantiateSignature(new Instantiation(), _instantiation);
 }
Пример #10
0
 private TypeDesc Instantiate(TypeDesc type)
 {
     return(type.InstantiateSignature(new Instantiation(), _instantiation));
 }
 private TypeDesc Instantiate(TypeDesc type)
 {
     return type.InstantiateSignature(_instantiatedType.Instantiation, new Instantiation());
 }