Beispiel #1
0
        internal unsafe SharpLangTypeDefinition ResolveTypeDef(SharpLangEEType *eeType, TypeDefinitionHandle typeDefHandle)
        {
            var typeDef = new SharpLangEETypeDefinition(this, typeDefHandle);

            lock (SystemTypeLock)
            {
                // Check if type has already been instantiated
                SharpLangTypeDefinition sharpLangType;
                if (typeDefinitions.TryGetValue(typeDef, out sharpLangType))
                {
                    return(sharpLangType);
                }

                if (eeType == null)
                {
                    var sharpLangTypeSearchKey = new SharpLangEETypeComparer.SharpLangTypeSearchKey
                    {
                        Kind           = SharpLangEEType.Kind.TypeDef,
                        TypeDefinition = typeDef,
                    };
                    var typeIndex = SharpLangEETypeComparer.BinarySearch(types, ref sharpLangTypeSearchKey);
                    if (typeIndex >= 0)
                    {
                        eeType = types[typeIndex];
                    }
                }

                sharpLangType = new SharpLangTypeDefinition(eeType, typeDef.Module, typeDef.Handle);
                typeDefinitions.Add(typeDef, sharpLangType);

                if (eeType != null)
                {
                    eeType->CachedTypeField = (IntPtr)SharpLangHelper.GetObjectPointer(sharpLangType);
                }

                return(sharpLangType);
            }
        }
Beispiel #2
0
 unsafe public SharpLangTypeGeneric(SharpLangEEType *eeType, SharpLangTypeDefinition definition, SharpLangType[] arguments) : base(eeType)
 {
     this.definition = definition;
     this.arguments  = arguments;
 }
 unsafe public SharpLangTypeGeneric(SharpLangEEType* eeType, SharpLangTypeDefinition definition, SharpLangType[] arguments) : base(eeType)
 {
     this.definition = definition;
     this.arguments = arguments;
 }
Beispiel #4
0
        internal static unsafe SharpLangTypeGeneric ResolveGenericType(SharpLangEEType *eeType, SharpLangTypeDefinition genericTypeDefinition, SharpLangType[] genericArguments)
        {
            var genericTypeKey = new GenericKey(genericTypeDefinition, genericArguments);

            lock (SystemTypeLock)
            {
                SharpLangTypeGeneric sharpLangType;
                if (genericTypes.TryGetValue(genericTypeKey, out sharpLangType))
                {
                    return(sharpLangType);
                }

                if (eeType == null)
                {
                    var sharpLangTypeSearchKey = new SharpLangEETypeComparer.SharpLangTypeSearchKey
                    {
                        Kind           = SharpLangEEType.Kind.TypeDef,
                        TypeDefinition = new SharpLangEETypeDefinition
                        {
                            Module = genericTypeDefinition.InternalModule,
                            Handle = genericTypeDefinition.InternalHandle,
                        },
                        GenericArguments = genericArguments,
                    };
                    var typeIndex = SharpLangEETypeComparer.BinarySearch(types, ref sharpLangTypeSearchKey);
                    if (typeIndex >= 0)
                    {
                        eeType = types[typeIndex];
                    }
                }

                sharpLangType = new SharpLangTypeGeneric(eeType, genericTypeDefinition, genericArguments);
                genericTypes.Add(genericTypeKey, sharpLangType);

                if (eeType != null)
                {
                    eeType->CachedTypeField = (IntPtr)SharpLangHelper.GetObjectPointer(sharpLangType);
                }

                return(sharpLangType);
            }
        }