예제 #1
0
 //  Caller should lock this.
 internal IModule/*?*/ ResolveModuleRefReference(ModuleReference moduleReference) {
   //  If this is an assembly try to find in referred modules
   if (this.PEFileReader.IsAssembly) {
     Assembly/*?*/ assem = this.Module as Assembly;
     //^ assert assem != null;
     int moduleKey = moduleReference.ModuleIdentity.Name.UniqueKeyIgnoringCase;
     IModule[] containigModules = assem.MemberModules;
     var n = containigModules == null ? 0 : containigModules.Length;
     for (int i = 0; i < n; i++) {
       IModule mod = containigModules[i];
       if (mod.ModuleName.UniqueKeyIgnoringCase == moduleKey) return mod;
     }
   }
   //  If not found or its not an assembly look else where...
   var module = this.ModuleReader.LookupModule(this.Module, moduleReference.ModuleIdentity);
   return module;
 }
예제 #2
0
 /// <summary>
 /// Populates the list of module references.
 /// </summary>
 void LoadModuleReferences()
   //^ ensures this.ModuleReferenceArray != null;
 {
   uint numberOfModuleReferences = this.PEFileReader.ModuleRefTable.NumberOfRows;
   ModuleReference[] moduleRefList = new ModuleReference[numberOfModuleReferences + 1];
   for (uint i = 1; i <= numberOfModuleReferences; ++i) {
     ModuleRefRow moduleRefRow = this.PEFileReader.ModuleRefTable[i];
     IName moduleRefName = this.GetNameFromOffset(moduleRefRow.Name);
     ModuleIdentity moduleIdentity;
     if (this.ContainingAssembly == null) {
       moduleIdentity = new ModuleIdentity(moduleRefName, string.Empty);
     } else {
       moduleIdentity = new ModuleIdentity(moduleRefName, string.Empty, this.ContainingAssembly.AssemblyIdentity);
     }
     ModuleIdentity probedModuleIdentity = this.ModuleReader.metadataReaderHost.ProbeModuleReference(this.Module, moduleIdentity);
     uint internedModuleId = (uint)this.ModuleReader.metadataReaderHost.InternFactory.GetModuleInternedKey(probedModuleIdentity);
     ModuleReference moduleReference = new ModuleReference(this, i, internedModuleId, probedModuleIdentity);
     moduleRefList[i] = moduleReference;
   }
   //^ NonNullType.AssertInitialized(moduleRefList);
   this.ModuleReferenceArray = moduleRefList;
 }