Esempio n. 1
0
 IMethodDefinition CreateMethod(
   uint methodDefRowId,
   TypeBase parentModuleType
 ) {
   Debug.Assert(methodDefRowId > 0 && methodDefRowId <= this.PEFileReader.MethodTable.NumberOfRows);
   MethodRow methodRow = this.PEFileReader.MethodTable[methodDefRowId];
   IName methodName = this.GetNameFromOffset(methodRow.Name);
   if ((methodRow.Flags & MethodFlags.AccessMask) == MethodFlags.CompilerControlledAccess) {
     //Methods that are compiler controlled access are excempted from duplicate checking and may thus have names that cause
     //their intern keys to clash with other methods. Avoid this by mangling the names of such methods.
     //compiler controlled methods are always referred to via their tokens, so this renaming is safe to do.
     methodName = NameTable.GetNameFor(methodName.Value+"$PST"+((int)TableIndices.Method+methodDefRowId));
   }
   uint genericParamRowIdStart;
   uint genericParamRowIdEnd;
   this.GetGenericParamInfoForMethod(methodDefRowId, out genericParamRowIdStart, out genericParamRowIdEnd);
   IMethodDefinition moduleMethod;
   if (genericParamRowIdStart == 0) {
     moduleMethod = new NonGenericMethod(this, methodName, parentModuleType, methodDefRowId, methodRow.Flags, methodRow.ImplFlags);
   } else {
     moduleMethod = new GenericMethod(this, methodName, parentModuleType, methodDefRowId, methodRow.Flags, methodRow.ImplFlags, genericParamRowIdStart, genericParamRowIdEnd);
   }
   if (methodName.UniqueKey != this.ModuleReader._Deleted_.UniqueKey) {
     moduleMethod = this.ModuleReader.metadataReaderHost.Rewrite(this.Module, moduleMethod);
     parentModuleType.AddMember(moduleMethod);
   }
   return moduleMethod;
 }
Esempio n. 2
0
 MethodDefinition CreateMethod(
   uint methodDefRowId,
   TypeBase parentModuleType
 ) {
   Debug.Assert(methodDefRowId > 0 && methodDefRowId <= this.PEFileReader.MethodTable.NumberOfRows);
   MethodRow methodRow = this.PEFileReader.MethodTable[methodDefRowId];
   IName methodName = this.GetNameFromOffset(methodRow.Name);
   uint genericParamRowIdStart;
   uint genericParamRowIdEnd;
   this.GetGenericParamInfoForMethod(methodDefRowId, out genericParamRowIdStart, out genericParamRowIdEnd);
   MethodDefinition moduleMethod;
   if (genericParamRowIdStart == 0) {
     moduleMethod = new NonGenericMethod(this, methodName, parentModuleType, methodDefRowId, methodRow.Flags, methodRow.ImplFlags);
   } else {
     moduleMethod = new GenericMethod(this, methodName, parentModuleType, methodDefRowId, methodRow.Flags, methodRow.ImplFlags, genericParamRowIdStart, genericParamRowIdEnd);
   }
   if (methodName.UniqueKey != this.ModuleReader._Deleted_.UniqueKey) {
     parentModuleType.AddMember(moduleMethod);
   }
   return moduleMethod;
 }