You've already forked linux-packaging-mono
Imported Upstream version 5.4.0.199
Former-commit-id: f4d318e4b2f128fa9f4d31b37bb3839a3fc0dfb2
This commit is contained in:
parent
536cd135cc
commit
5924117973
41
external/linker/cecil/Mono.Cecil/Import.cs
vendored
41
external/linker/cecil/Mono.Cecil/Import.cs
vendored
@@ -24,6 +24,7 @@ namespace Mono.Cecil {
|
||||
}
|
||||
|
||||
public interface IMetadataImporter {
|
||||
AssemblyNameReference ImportReference (AssemblyNameReference reference);
|
||||
TypeReference ImportReference (TypeReference type, IGenericParameterProvider context);
|
||||
FieldReference ImportReference (FieldReference field, IGenericParameterProvider context);
|
||||
MethodReference ImportReference (MethodReference method, IGenericParameterProvider context);
|
||||
@@ -34,6 +35,7 @@ namespace Mono.Cecil {
|
||||
}
|
||||
|
||||
public interface IReflectionImporter {
|
||||
AssemblyNameReference ImportReference (SR.AssemblyName reference);
|
||||
TypeReference ImportReference (Type type, IGenericParameterProvider context);
|
||||
FieldReference ImportReference (SR.FieldInfo field, IGenericParameterProvider context);
|
||||
MethodReference ImportReference (SR.MethodBase method, IGenericParameterProvider context);
|
||||
@@ -122,11 +124,11 @@ namespace Mono.Cecil {
|
||||
}
|
||||
}
|
||||
|
||||
public class ReflectionImporter : IReflectionImporter {
|
||||
public class DefaultReflectionImporter : IReflectionImporter {
|
||||
|
||||
readonly ModuleDefinition module;
|
||||
readonly protected ModuleDefinition module;
|
||||
|
||||
public ReflectionImporter (ModuleDefinition module)
|
||||
public DefaultReflectionImporter (ModuleDefinition module)
|
||||
{
|
||||
Mixin.CheckModule (module);
|
||||
|
||||
@@ -294,14 +296,19 @@ namespace Mono.Cecil {
|
||||
|
||||
AssemblyNameReference ImportScope (SR.Assembly assembly)
|
||||
{
|
||||
AssemblyNameReference scope;
|
||||
return ImportReference (assembly.GetName ());
|
||||
}
|
||||
|
||||
var name = assembly.GetName ();
|
||||
public virtual AssemblyNameReference ImportReference (SR.AssemblyName name)
|
||||
{
|
||||
Mixin.CheckName (name);
|
||||
|
||||
if (TryGetAssemblyNameReference (name, out scope))
|
||||
return scope;
|
||||
AssemblyNameReference reference;
|
||||
if (TryGetAssemblyNameReference (name, out reference))
|
||||
return reference;
|
||||
|
||||
scope = new AssemblyNameReference (name.Name, name.Version) {
|
||||
reference = new AssemblyNameReference (name.Name, name.Version)
|
||||
{
|
||||
PublicKeyToken = name.GetPublicKeyToken (),
|
||||
#if !NET_CORE
|
||||
Culture = name.CultureInfo.Name,
|
||||
@@ -309,9 +316,9 @@ namespace Mono.Cecil {
|
||||
#endif
|
||||
};
|
||||
|
||||
module.AssemblyReferences.Add (scope);
|
||||
module.AssemblyReferences.Add (reference);
|
||||
|
||||
return scope;
|
||||
return reference;
|
||||
}
|
||||
|
||||
bool TryGetAssemblyNameReference (SR.AssemblyName name, out AssemblyNameReference assembly_reference)
|
||||
@@ -477,11 +484,11 @@ namespace Mono.Cecil {
|
||||
}
|
||||
}
|
||||
|
||||
public class MetadataImporter : IMetadataImporter {
|
||||
public class DefaultMetadataImporter : IMetadataImporter {
|
||||
|
||||
readonly ModuleDefinition module;
|
||||
readonly protected ModuleDefinition module;
|
||||
|
||||
public MetadataImporter (ModuleDefinition module)
|
||||
public DefaultMetadataImporter (ModuleDefinition module)
|
||||
{
|
||||
Mixin.CheckModule (module);
|
||||
|
||||
@@ -515,10 +522,10 @@ namespace Mono.Cecil {
|
||||
{
|
||||
switch (scope.MetadataScopeType) {
|
||||
case MetadataScopeType.AssemblyNameReference:
|
||||
return ImportAssemblyName ((AssemblyNameReference) scope);
|
||||
return ImportReference ((AssemblyNameReference) scope);
|
||||
case MetadataScopeType.ModuleDefinition:
|
||||
if (scope == module) return scope;
|
||||
return ImportAssemblyName (((ModuleDefinition) scope).Assembly.Name);
|
||||
return ImportReference (((ModuleDefinition) scope).Assembly.Name);
|
||||
case MetadataScopeType.ModuleReference:
|
||||
throw new NotImplementedException ();
|
||||
}
|
||||
@@ -526,8 +533,10 @@ namespace Mono.Cecil {
|
||||
throw new NotSupportedException ();
|
||||
}
|
||||
|
||||
internal virtual AssemblyNameReference ImportAssemblyName (AssemblyNameReference name)
|
||||
public virtual AssemblyNameReference ImportReference (AssemblyNameReference name)
|
||||
{
|
||||
Mixin.CheckName (name);
|
||||
|
||||
AssemblyNameReference reference;
|
||||
if (module.TryGetAssemblyNameReference (name, out reference))
|
||||
return reference;
|
||||
|
||||
Reference in New Issue
Block a user