diff options
Diffstat (limited to 'external/cecil/Mono.Cecil/ModuleDefinition.cs')
-rw-r--r-- | external/cecil/Mono.Cecil/ModuleDefinition.cs | 123 |
1 files changed, 32 insertions, 91 deletions
diff --git a/external/cecil/Mono.Cecil/ModuleDefinition.cs b/external/cecil/Mono.Cecil/ModuleDefinition.cs index 66ac0270e0..7f75cbd17e 100644 --- a/external/cecil/Mono.Cecil/ModuleDefinition.cs +++ b/external/cecil/Mono.Cecil/ModuleDefinition.cs @@ -208,6 +208,7 @@ namespace Mono.Cecil { TargetRuntime runtime; TargetArchitecture architecture; ModuleAttributes attributes; + ModuleCharacteristics characteristics; Guid mvid; internal AssemblyDefinition assembly; @@ -247,6 +248,11 @@ namespace Mono.Cecil { set { attributes = value; } } + public ModuleCharacteristics Characteristics { + get { return characteristics; } + set { characteristics = value; } + } + public string FullyQualifiedName { get { return fq_name; } } @@ -442,6 +448,7 @@ namespace Mono.Cecil { this.runtime = image.Runtime; this.architecture = image.Architecture; this.attributes = image.Attributes; + this.characteristics = image.Characteristics; this.fq_name = image.FileName; this.reader = new MetadataReader (this); @@ -616,89 +623,57 @@ namespace Mono.Cecil { throw new ArgumentException (); } -#if !CF - public TypeReference Import (Type type) + static ImportGenericContext GenericContextFor (IGenericParameterProvider context) { - CheckType (type); - - return MetadataImporter.ImportType (type, null, ImportGenericKind.Definition); + return context != null ? new ImportGenericContext (context) : default (ImportGenericContext); } - public TypeReference Import (Type type, TypeReference context) - { - return Import (type, (IGenericParameterProvider) context); - } +#if !CF - public TypeReference Import (Type type, MethodReference context) + public TypeReference Import (Type type) { - return Import (type, (IGenericParameterProvider) context); + return Import (type, null); } - TypeReference Import (Type type, IGenericParameterProvider context) + public TypeReference Import (Type type, IGenericParameterProvider context) { CheckType (type); CheckContext (context, this); return MetadataImporter.ImportType ( type, - (IGenericContext) context, - context != null - ? ImportGenericKind.Open - : ImportGenericKind.Definition); + GenericContextFor (context), + context != null ? ImportGenericKind.Open : ImportGenericKind.Definition); } public FieldReference Import (SR.FieldInfo field) { - CheckField (field); - - return MetadataImporter.ImportField (field, null); - } - - public FieldReference Import (SR.FieldInfo field, TypeReference context) - { - return Import (field, (IGenericParameterProvider) context); - } - - public FieldReference Import (SR.FieldInfo field, MethodReference context) - { - return Import (field, (IGenericParameterProvider) context); + return Import (field, null); } - FieldReference Import (SR.FieldInfo field, IGenericParameterProvider context) + public FieldReference Import (SR.FieldInfo field, IGenericParameterProvider context) { CheckField (field); CheckContext (context, this); - return MetadataImporter.ImportField (field, (IGenericContext) context); + return MetadataImporter.ImportField (field, GenericContextFor (context)); } public MethodReference Import (SR.MethodBase method) { CheckMethod (method); - return MetadataImporter.ImportMethod (method, null, ImportGenericKind.Definition); - } - - public MethodReference Import (SR.MethodBase method, TypeReference context) - { - return Import (method, (IGenericParameterProvider) context); - } - - public MethodReference Import (SR.MethodBase method, MethodReference context) - { - return Import (method, (IGenericParameterProvider) context); + return MetadataImporter.ImportMethod (method, default (ImportGenericContext), ImportGenericKind.Definition); } - MethodReference Import (SR.MethodBase method, IGenericParameterProvider context) + public MethodReference Import (SR.MethodBase method, IGenericParameterProvider context) { CheckMethod (method); CheckContext (context, this); return MetadataImporter.ImportMethod (method, - (IGenericContext) context, - context != null - ? ImportGenericKind.Open - : ImportGenericKind.Definition); + GenericContextFor (context), + context != null ? ImportGenericKind.Open : ImportGenericKind.Definition); } #endif @@ -709,20 +684,10 @@ namespace Mono.Cecil { if (type.Module == this) return type; - return MetadataImporter.ImportType (type, null); + return MetadataImporter.ImportType (type, default (ImportGenericContext)); } - public TypeReference Import (TypeReference type, TypeReference context) - { - return Import (type, (IGenericParameterProvider) context); - } - - public TypeReference Import (TypeReference type, MethodReference context) - { - return Import (type, (IGenericParameterProvider) context); - } - - TypeReference Import (TypeReference type, IGenericParameterProvider context) + public TypeReference Import (TypeReference type, IGenericParameterProvider context) { CheckType (type); @@ -731,7 +696,7 @@ namespace Mono.Cecil { CheckContext (context, this); - return MetadataImporter.ImportType (type, (IGenericContext) context); + return MetadataImporter.ImportType (type, GenericContextFor (context)); } public FieldReference Import (FieldReference field) @@ -741,20 +706,10 @@ namespace Mono.Cecil { if (field.Module == this) return field; - return MetadataImporter.ImportField (field, null); - } - - public FieldReference Import (FieldReference field, TypeReference context) - { - return Import (field, (IGenericParameterProvider) context); - } - - public FieldReference Import (FieldReference field, MethodReference context) - { - return Import (field, (IGenericParameterProvider) context); + return MetadataImporter.ImportField (field, default (ImportGenericContext)); } - FieldReference Import (FieldReference field, IGenericParameterProvider context) + public FieldReference Import (FieldReference field, IGenericParameterProvider context) { CheckField (field); @@ -763,30 +718,15 @@ namespace Mono.Cecil { CheckContext (context, this); - return MetadataImporter.ImportField (field, (IGenericContext) context); + return MetadataImporter.ImportField (field, GenericContextFor (context)); } public MethodReference Import (MethodReference method) { - CheckMethod (method); - - if (method.Module == this) - return method; - - return MetadataImporter.ImportMethod (method, null); - } - - public MethodReference Import (MethodReference method, TypeReference context) - { - return Import (method, (IGenericParameterProvider) context); - } - - public MethodReference Import (MethodReference method, MethodReference context) - { - return Import (method, (IGenericParameterProvider) context); + return Import (method, null); } - MethodReference Import (MethodReference method, IGenericParameterProvider context) + public MethodReference Import (MethodReference method, IGenericParameterProvider context) { CheckMethod (method); @@ -795,7 +735,7 @@ namespace Mono.Cecil { CheckContext (context, this); - return MetadataImporter.ImportMethod (method, (IGenericContext) context); + return MetadataImporter.ImportMethod (method, GenericContextFor (context)); } #endif @@ -866,6 +806,7 @@ namespace Mono.Cecil { architecture = parameters.Architecture, mvid = Guid.NewGuid (), Attributes = ModuleAttributes.ILOnly, + Characteristics = (ModuleCharacteristics) 0x8540, }; if (parameters.AssemblyResolver != null) |