Beispiel #1
0
 TypeInstanceResolver getTypeInstance(TypeReference typeReference)
 {
     var key = new TypeReferenceKey(typeReference);
     TypeInstanceResolver instance;
     if (!typeRefToInstance.TryGetValue(key, out instance))
         typeRefToInstance[key] = instance = new TypeInstanceResolver(type, typeReference);
     return instance;
 }
Beispiel #2
0
        public void initializeFrom(InterfaceMethodInfos other, GenericInstanceType git)
        {
            foreach (var pair in other.interfaceMethods) {
                var oldTypeInfo = pair.Value.IFace;
                var newTypeInfo = new TypeInfo(oldTypeInfo, git);
                var oldKey = new TypeReferenceKey(oldTypeInfo.typeReference);
                var newKey = new TypeReferenceKey(newTypeInfo.typeReference);

                InterfaceMethodInfo newMethodsInfo = new InterfaceMethodInfo(newTypeInfo, other.interfaceMethods[oldKey]);
                if (interfaceMethods.ContainsKey(newKey))
                    newMethodsInfo.merge(interfaceMethods[newKey]);
                interfaceMethods[newKey] = newMethodsInfo;
            }
        }
Beispiel #3
0
 public void addMethodIfEmpty(TypeInfo iface, MethodDef ifaceMethod, MethodDef classMethod)
 {
     InterfaceMethodInfo info;
     var key = new TypeReferenceKey(iface.typeReference);
     if (!interfaceMethods.TryGetValue(key, out info))
         throw new ApplicationException("Could not find interface");
     info.addMethodIfEmpty(ifaceMethod, classMethod);
 }
Beispiel #4
0
 public void addInterface(TypeInfo iface)
 {
     var key = new TypeReferenceKey(iface.typeReference);
     if (!interfaceMethods.ContainsKey(key))
         interfaceMethods[key] = new InterfaceMethodInfo(iface);
 }
Beispiel #5
0
 void init()
 {
     foreach (var type in module.GetTypes()) {
         var key = new TypeReferenceKey(type);
         typeRefToDef[key] = type;
     }
 }
Beispiel #6
0
        TypeDef resolveOther(TypeReference type)
        {
            if (type == null)
                return null;
            type = type.GetElementType();

            TypeDef typeDef;
            var key = new TypeReferenceKey(type);
            if (otherTypesDict.TryGetValue(key, out typeDef))
                return typeDef;
            otherTypesDict[key] = null;	// In case of a circular reference

            TypeDefinition typeDefinition = externalAssemblies.resolve(type);
            if (typeDefinition == null)
                return null;

            typeDef = new TypeDef(typeDefinition, null, 0);
            typeDef.addMembers();
            foreach (var iface in typeDef.TypeDefinition.Interfaces) {
                var ifaceDef = resolveOther(iface);
                if (ifaceDef == null)
                    continue;
                typeDef.addInterface(ifaceDef, iface);
            }
            var baseDef = resolveOther(typeDef.TypeDefinition.BaseType);
            if (baseDef != null)
                typeDef.addBaseType(baseDef, typeDef.TypeDefinition.BaseType);
            return otherTypesDict[key] = typeDef;
        }
 TypeReference add(bool isValueType, TypeReference typeRef)
 {
     var key = new TypeReferenceKey(typeRef);
     TypeReference createdTypeRef;
     if (createdTypes.TryGetValue(key, out createdTypeRef)) {
         if (createdTypeRef.IsValueType != isValueType)
             throw new ApplicationException(string.Format("Type {0}'s IsValueType is not correct", createdTypeRef));
         return createdTypeRef;
     }
     createdTypes[key] = typeRef;
     return typeRef;
 }