internal IMetadataReaderNamedTypeReference GetPredefinedTypeRefReferenceAtRowWorker( uint typeRefRowId, MetadataReaderSignatureTypeCode signatureTypeCode ) { Debug.Assert(typeRefRowId > 0 && typeRefRowId <= this.PEFileReader.TypeRefTable.NumberOfRows); Debug.Assert( this.ModuleTypeRefReferenceLoadState[typeRefRowId] == LoadState.Uninitialized && this.ModuleTypeRefReferenceArray[typeRefRowId] == null ); this.ModuleTypeRefReferenceLoadState[typeRefRowId] = LoadState.Loading; TypeRefRow typeRefRow = this.PEFileReader.TypeRefTable[typeRefRowId]; uint resolutionScopeKind = (typeRefRow.ResolutionScope & TokenTypeIds.TokenTypeMask); uint resolutionScopeRowId = (typeRefRow.ResolutionScope & TokenTypeIds.RIDMask); Debug.Assert(resolutionScopeKind == TokenTypeIds.AssemblyRef); // TODO: MD Error var result = this.CreateTypeRefReference(typeRefRowId, typeRefRow, null, this.AssemblyReferenceArray[resolutionScopeRowId], signatureTypeCode); this.ModuleTypeRefReferenceArray[typeRefRowId] = result; this.ModuleTypeRefReferenceLoadState[typeRefRowId] = LoadState.Loaded; return result; }
//^ invariant this.PEFileReader.TypeSpecTable.NumberOfRows >= 1 ==> this.ModuleTypeSpecHashtable != null; TypeRefReference CreateTypeRefReference( uint typeRefRowId, TypeRefRow typeRefRow, IMetadataReaderNamedTypeReference/*?*/ parentModuleTypeReference, IMetadataReaderModuleReference moduleReference, MetadataReaderSignatureTypeCode signatureTypeCode ) { IName mangledTypeName = this.GetNameFromOffset(typeRefRow.Name); ushort genericParamCount; string typeName; TypeCache.SplitMangledTypeName(mangledTypeName.Value, out typeName, out genericParamCount); TypeRefReference moduleTypeRefReference; if (parentModuleTypeReference == null) { IName namespaceFullName = this.GetNameFromOffset(typeRefRow.Namespace); NamespaceReference namespaceReference = this.GetNamespaceReferenceForString(moduleReference, namespaceFullName); if (genericParamCount == 0) { if (signatureTypeCode == MetadataReaderSignatureTypeCode.NotModulePrimitive) { moduleTypeRefReference = new NamespaceTypeRefReferenceWithoutPrimitiveTypeCode( this, mangledTypeName, typeRefRowId, moduleReference, namespaceReference, signatureTypeCode == MetadataReaderSignatureTypeCode.ValueType ); } else { moduleTypeRefReference = new NamespaceTypeRefReferenceWithPrimitiveTypeCode( this, mangledTypeName, typeRefRowId, moduleReference, namespaceReference, signatureTypeCode ); } } else { IName iTypeName = this.NameTable.GetNameFor(typeName); moduleTypeRefReference = new GenericNamespaceTypeRefReference( this, iTypeName, typeRefRowId, moduleReference, namespaceReference, mangledTypeName, genericParamCount, signatureTypeCode == MetadataReaderSignatureTypeCode.ValueType ); } } else { if (genericParamCount == 0) { moduleTypeRefReference = new NonGenericNestedTypeRefReference( this, mangledTypeName, typeRefRowId, moduleReference, parentModuleTypeReference, signatureTypeCode == MetadataReaderSignatureTypeCode.ValueType ); } else { IName iTypeName = this.NameTable.GetNameFor(typeName); moduleTypeRefReference = new GenericNestedTypeRefReference( this, iTypeName, typeRefRowId, moduleReference, parentModuleTypeReference, mangledTypeName, genericParamCount, signatureTypeCode == MetadataReaderSignatureTypeCode.ValueType ); } } return moduleTypeRefReference; }
NamespaceType CreateModuleNamespaceType( uint typeDefRowId, TypeDefRow typeDefRow, Namespace moduleNamespace, MetadataReaderSignatureTypeCode signatureTypeCode ) { IName typeName = this.GetNameFromOffset(typeDefRow.Name); uint genericParamRowIdStart; uint genericParamRowIdEnd; this.GetGenericParamInfoForType(typeDefRowId, out genericParamRowIdStart, out genericParamRowIdEnd); NamespaceType type; if (genericParamRowIdStart == 0) { if (signatureTypeCode == MetadataReaderSignatureTypeCode.NotModulePrimitive) type = new NonGenericNamespaceTypeWithoutPrimitiveType(this, typeName, typeDefRowId, typeDefRow.Flags, moduleNamespace); else type = new NonGenericNamespaceTypeWithPrimitiveType(this, typeName, typeDefRowId, typeDefRow.Flags, moduleNamespace, signatureTypeCode); } else { IName unmangledTypeName = this.GetUnmangledNameFromOffset(typeDefRow.Name); type = new GenericNamespaceType(this, unmangledTypeName, typeDefRowId, typeDefRow.Flags, moduleNamespace, typeName, genericParamRowIdStart, genericParamRowIdEnd); } return type; }
internal NamespaceType GetPredefinedTypeDefinitionAtRowWorker( uint typeDefRowId, MetadataReaderSignatureTypeCode signatureTypeCode ) { if (this.ModuleTypeDefLoadState[typeDefRowId] == LoadState.Uninitialized) { Debug.Assert(this.ModuleTypeDefArray[typeDefRowId] == null); TypeDefRow typeDefRow = this.PEFileReader.TypeDefTable[typeDefRowId]; Debug.Assert(!typeDefRow.IsNested); // TODO: MD Error if this happens Namespace parentNamespace = this.GetNamespaceForNameOffset(typeDefRow.Namespace); var type = this.CreateModuleNamespaceType(typeDefRowId, typeDefRow, parentNamespace, signatureTypeCode); parentNamespace.AddMember(type); this.ModuleTypeDefArray[typeDefRowId] = type; this.RedirectedTypeDefArray[typeDefRowId] = type; this.ModuleTypeDefLoadState[typeDefRowId] = LoadState.Loaded; } return (NamespaceType)this.ModuleTypeDefArray[typeDefRowId]; }
internal TypeBase GetPredefinedTypeDefinitionAtRowWorker( uint typeDefRowId, MetadataReaderSignatureTypeCode signatureTypeCode ) { if (this.ModuleTypeDefLoadState[typeDefRowId] == LoadState.Uninitialized) { Debug.Assert(this.ModuleTypeDefArray[typeDefRowId] == null); TypeDefRow typeDefRow = this.PEFileReader.TypeDefTable[typeDefRowId]; Debug.Assert(!typeDefRow.IsNested); // TODO: MD Error if this happens Namespace parentNamespace = this.GetNamespaceForNameOffset(typeDefRow.Namespace); this.ModuleTypeDefArray[typeDefRowId] = this.CreateModuleNamespaceType(typeDefRowId, typeDefRow, parentNamespace, signatureTypeCode); this.ModuleTypeDefLoadState[typeDefRowId] = LoadState.Loaded; } TypeBase /*?*/ mt = this.ModuleTypeDefArray[typeDefRowId]; //^ assert mt != null; return mt; }