private TypeReference ImportGenericInstance(Type type, ImportGenericContext context) { TypeReference reference2; TypeReference reference = this.ImportType(type.GetGenericTypeDefinition(), context, ImportGenericKind.Definition); GenericInstanceType type2 = new GenericInstanceType(reference); Type[] genericArguments = type.GetGenericArguments(); Collection <TypeReference> collection = type2.GenericArguments; context.Push(reference); try { int index = 0; while (true) { if (index >= genericArguments.Length) { reference2 = type2; break; } collection.Add(this.ImportType(genericArguments[index], context)); index++; } } finally { context.Pop(); } return(reference2); }
MethodReference ImportMethodSpecification(SR.MethodBase method, ImportGenericContext context) { var method_info = method as SR.MethodInfo; if (method_info == null) { throw new InvalidOperationException(); } var element_method = ImportMethod(method_info.GetGenericMethodDefinition(), context, ImportGenericKind.Definition); var instance = new GenericInstanceMethod(element_method); var arguments = method.GetGenericArguments(); var instance_arguments = instance.GenericArguments; context.Push(element_method); try { for (int i = 0; i < arguments.Length; i++) { instance_arguments.Add(ImportType(arguments [i], context)); } return(instance); } finally { context.Pop(); } }
public FieldReference ImportField(FieldInfo field, ImportGenericContext context) { FieldReference fieldReference; TypeReference typeReference = this.ImportType(field.DeclaringType, context); if (MetadataImporter.IsGenericInstance(field.DeclaringType)) { field = MetadataImporter.ResolveFieldDefinition(field); } context.Push(typeReference); try { fieldReference = new FieldReference() { Name = field.Name, DeclaringType = typeReference, FieldType = this.ImportType(field.FieldType, context) }; } finally { context.Pop(); } return(fieldReference); }
private MethodReference ImportMethodSpecification(MethodBase method, ImportGenericContext context) { MethodInfo methodInfo = method as MethodInfo; if (methodInfo == (MethodInfo)null) { throw new InvalidOperationException(); } MethodReference methodReference = ImportMethod(methodInfo.GetGenericMethodDefinition(), context, ImportGenericKind.Definition); GenericInstanceMethod genericInstanceMethod = new GenericInstanceMethod(methodReference); Type[] genericArguments = method.GetGenericArguments(); Collection <TypeReference> genericArguments2 = genericInstanceMethod.GenericArguments; context.Push(methodReference); try { for (int i = 0; i < genericArguments.Length; i++) { genericArguments2.Add(ImportType(genericArguments[i], context)); } return(genericInstanceMethod); } finally { context.Pop(); } }
public MethodReference ImportMethod(SR.MethodBase method, ImportGenericContext context, ImportGenericKind import_kind) { if (IsMethodSpecification(method) || ImportOpenGenericMethod(method, import_kind)) { return(ImportMethodSpecification(method, context)); } var declaring_type = ImportType(method.DeclaringType, context); if (IsGenericInstance(method.DeclaringType)) { method = method.Module.ResolveMethod(method.MetadataToken); } var reference = new MethodReference(method.Name, module.Import(typeof(void))) { Name = method.Name, HasThis = HasCallingConvention(method, SR.CallingConventions.HasThis), ExplicitThis = HasCallingConvention(method, SR.CallingConventions.ExplicitThis), DeclaringType = ImportType(method.DeclaringType, context, ImportGenericKind.Definition), }; if (HasCallingConvention(method, SR.CallingConventions.VarArgs)) { reference.CallingConvention &= MethodCallingConvention.VarArg; } if (method.IsGenericMethod) { ImportGenericParameters(reference, method.GetGenericArguments()); } context.Push(reference); try { var method_info = method as SR.MethodInfo; reference.ReturnType = method_info != null ? ImportType(method_info.ReturnType, context) : ImportType(typeof(void), default(ImportGenericContext)); var parameters = method.GetParameters(); var reference_parameters = reference.Parameters; for (int i = 0; i < parameters.Length; i++) { reference_parameters.Add( new ParameterDefinition(ImportType(parameters[i].ParameterType, context))); } reference.DeclaringType = declaring_type; return(reference); } finally { context.Pop(); } }
public MethodReference ImportMethod(MethodBase method, ImportGenericContext context, ImportGenericKind import_kind) { MethodReference methodReference; if (MetadataImporter.IsMethodSpecification(method) || MetadataImporter.ImportOpenGenericMethod(method, import_kind)) { return(this.ImportMethodSpecification(method, context)); } TypeReference typeReference = this.ImportType(method.DeclaringType, context); if (MetadataImporter.IsGenericInstance(method.DeclaringType)) { method = method.Module.ResolveMethod(method.MetadataToken); } MethodReference methodReference1 = new MethodReference() { Name = method.Name, HasThis = MetadataImporter.HasCallingConvention(method, CallingConventions.HasThis), ExplicitThis = MetadataImporter.HasCallingConvention(method, CallingConventions.ExplicitThis), DeclaringType = this.ImportType(method.DeclaringType, context, ImportGenericKind.Definition) }; if (MetadataImporter.HasCallingConvention(method, CallingConventions.VarArgs)) { MethodReference callingConvention = methodReference1; callingConvention.CallingConvention = callingConvention.CallingConvention & MethodCallingConvention.VarArg; } if (method.IsGenericMethod) { MetadataImporter.ImportGenericParameters(methodReference1, method.GetGenericArguments()); } context.Push(methodReference1); try { MethodInfo methodInfo = method as MethodInfo; methodReference1.ReturnType = (methodInfo != null ? this.ImportType(methodInfo.ReturnType, context) : this.ImportType(typeof(void), new ImportGenericContext())); ParameterInfo[] parameters = method.GetParameters(); Collection <ParameterDefinition> parameterDefinitions = methodReference1.Parameters; for (int i = 0; i < (int)parameters.Length; i++) { parameterDefinitions.Add(new ParameterDefinition(this.ImportType(parameters[i].ParameterType, context))); } methodReference1.DeclaringType = typeReference; methodReference = methodReference1; } finally { context.Pop(); } return(methodReference); }
public MethodReference ImportMethod(MethodReference method, ImportGenericContext context) { MethodReference reference4; if (method.IsGenericInstance) { return(this.ImportMethodSpecification(method, context)); } MethodReference imported = new MethodReference { Name = method.Name, HasThis = method.HasThis, ExplicitThis = method.ExplicitThis, DeclaringType = this.ImportType(method.DeclaringType, context), CallingConvention = method.CallingConvention }; if (method.HasGenericParameters) { ImportGenericParameters(imported, method); } context.Push(imported); try { imported.ReturnType = this.ImportType(method.ReturnType, context); if (!method.HasParameters) { reference4 = imported; } else { Collection <ParameterDefinition> parameters = imported.Parameters; Collection <ParameterDefinition> collection2 = method.Parameters; int num = 0; while (true) { if (num >= collection2.Count) { reference4 = imported; break; } parameters.Add(new ParameterDefinition(this.ImportType(collection2[num].ParameterType, context))); num++; } } } finally { context.Pop(); } return(reference4); }
FieldReference ImportField(FieldReference field, ImportGenericContext context) { var declaring_type = ImportType(field.DeclaringType, context); context.Push(declaring_type); try { return(new FieldReference { Name = field.Name, DeclaringType = declaring_type, FieldType = ImportType(field.FieldType, context), }); } finally { context.Pop(); } }
public MethodReference ImportMethod(MethodReference method, ImportGenericContext context) { MethodReference methodReference; if (method.IsGenericInstance) { return(this.ImportMethodSpecification(method, context)); } TypeReference typeReference = this.ImportType(method.DeclaringType, context); MethodReference methodReference1 = new MethodReference() { Name = method.Name, HasThis = method.HasThis, ExplicitThis = method.ExplicitThis, DeclaringType = typeReference, CallingConvention = method.CallingConvention }; if (method.HasGenericParameters) { MetadataImporter.ImportGenericParameters(methodReference1, method); } context.Push(methodReference1); try { methodReference1.ReturnType = this.ImportType(method.ReturnType, context); if (method.HasParameters) { Collection <ParameterDefinition> parameters = methodReference1.Parameters; Collection <ParameterDefinition> parameterDefinitions = method.Parameters; for (int i = 0; i < parameterDefinitions.Count; i++) { parameters.Add(new ParameterDefinition(this.ImportType(parameterDefinitions[i].ParameterType, context))); } methodReference = methodReference1; } else { methodReference = methodReference1; } } finally { context.Pop(); } return(methodReference); }
private MethodReference ImportMethod(MethodBase method, ImportGenericContext context, ImportGenericKind import_kind) { if (!IsMethodSpecification(method) && !ImportOpenGenericMethod(method, import_kind)) { TypeReference declaringType = ImportType(method.DeclaringType, context); if (IsGenericInstance(method.DeclaringType)) { method = ResolveMethodDefinition(method); } MethodReference methodReference = new MethodReference { Name = method.Name, HasThis = HasCallingConvention(method, CallingConventions.HasThis), ExplicitThis = HasCallingConvention(method, CallingConventions.ExplicitThis), DeclaringType = ImportType(method.DeclaringType, context, ImportGenericKind.Definition) }; if (HasCallingConvention(method, CallingConventions.VarArgs)) { methodReference.CallingConvention &= MethodCallingConvention.VarArg; } if (method.IsGenericMethod) { ImportGenericParameters(methodReference, method.GetGenericArguments()); } context.Push(methodReference); try { MethodInfo methodInfo = method as MethodInfo; methodReference.ReturnType = ((methodInfo != (MethodInfo)null) ? ImportType(methodInfo.ReturnType, context) : ImportType(typeof(void), default(ImportGenericContext))); ParameterInfo[] parameters = method.GetParameters(); Collection <ParameterDefinition> parameters2 = methodReference.Parameters; for (int i = 0; i < parameters.Length; i++) { parameters2.Add(new ParameterDefinition(ImportType(parameters[i].ParameterType, context))); } methodReference.DeclaringType = declaringType; return(methodReference); } finally { context.Pop(); } } return(ImportMethodSpecification(method, context)); }
public MethodReference ImportMethod(MethodReference method, ImportGenericContext context) { if (method.IsGenericInstance) { return(ImportMethodSpecification(method, context)); } var declaring_type = ImportType(method.DeclaringType, context); var reference = new MethodReference { Name = method.Name, HasThis = method.HasThis, ExplicitThis = method.ExplicitThis, DeclaringType = declaring_type, CallingConvention = method.CallingConvention, }; if (method.HasGenericParameters) { ImportGenericParameters(reference, method); } context.Push(reference); try { reference.ReturnType = ImportType(method.ReturnType, context); if (!method.HasParameters) { return(reference); } var reference_parameters = reference.Parameters; var parameters = method.Parameters; for (int i = 0; i < parameters.Count; i++) { reference_parameters.Add( new ParameterDefinition(ImportType(parameters [i].ParameterType, context))); } return(reference); } finally { context.Pop(); } }
private FieldReference ImportField(FieldReference field, ImportGenericContext context) { TypeReference typeReference = ImportType(field.DeclaringType, context); context.Push(typeReference); try { return(new FieldReference { Name = field.Name, DeclaringType = typeReference, FieldType = ImportType(field.FieldType, context) }); } finally { context.Pop(); } }
TypeReference ImportGenericInstance(Type type, ImportGenericContext context) { var element_type = ImportType(type.GetGenericTypeDefinition(), context, ImportGenericKind.Definition); var instance = new GenericInstanceType(element_type); var arguments = type.GetGenericArguments(); var instance_arguments = instance.GenericArguments; context.Push(element_type); try { for (int i = 0; i < arguments.Length; i++) { instance_arguments.Add(ImportType(arguments [i], context)); } return(instance); } finally { context.Pop(); } }
public FieldReference ImportField(SR.FieldInfo field, ImportGenericContext context) { var declaring_type = ImportType(field.DeclaringType, context); if (IsGenericInstance(field.DeclaringType)) { field = ResolveFieldDefinition(field); } context.Push(declaring_type); try { return(new FieldReference(field.Name, ImportType(field.FieldType, context), declaring_type)); } finally { context.Pop(); } }
public FieldReference ImportField(FieldReference field, ImportGenericContext context) { FieldReference reference3; TypeReference provider = this.ImportType(field.DeclaringType, context); context.Push(provider); try { reference3 = new FieldReference { Name = field.Name, DeclaringType = provider, FieldType = this.ImportType(field.FieldType, context) }; } finally { context.Pop(); } return(reference3); }
private MethodReference ImportMethod(MethodReference method, ImportGenericContext context) { if (method.IsGenericInstance) { return(ImportMethodSpecification(method, context)); } TypeReference declaringType = ImportType(method.DeclaringType, context); MethodReference methodReference = new MethodReference { Name = method.Name, HasThis = method.HasThis, ExplicitThis = method.ExplicitThis, DeclaringType = declaringType, CallingConvention = method.CallingConvention }; if (method.HasGenericParameters) { ImportGenericParameters(methodReference, method); } context.Push(methodReference); try { methodReference.ReturnType = ImportType(method.ReturnType, context); if (!method.HasParameters) { return(methodReference); } Collection <ParameterDefinition> parameters = method.Parameters; ParameterDefinitionCollection parameterDefinitionCollection = methodReference.parameters = new ParameterDefinitionCollection(methodReference, parameters.Count); for (int i = 0; i < parameters.Count; i++) { parameterDefinitionCollection.Add(new ParameterDefinition(ImportType(parameters[i].ParameterType, context))); } return(methodReference); } finally { context.Pop(); } }
public FieldReference ImportField(FieldReference field, ImportGenericContext context) { FieldReference fieldReference; TypeReference typeReference = this.ImportType(field.DeclaringType, context); context.Push(typeReference); try { fieldReference = new FieldReference() { Name = field.Name, DeclaringType = typeReference, FieldType = this.ImportType(field.FieldType, context) }; } finally { context.Pop(); } return(fieldReference); }
private TypeReference ImportGenericInstance(Type type, ImportGenericContext context) { TypeReference typeReference = ImportType(type.GetGenericTypeDefinition(), context, ImportGenericKind.Definition); GenericInstanceType genericInstanceType = new GenericInstanceType(typeReference); Type[] genericArguments = type.GetGenericArguments(); Collection <TypeReference> genericArguments2 = genericInstanceType.GenericArguments; context.Push(typeReference); try { for (int i = 0; i < genericArguments.Length; i++) { genericArguments2.Add(ImportType(genericArguments[i], context)); } return(genericInstanceType); } finally { context.Pop(); } }
private FieldReference ImportField(FieldInfo field, ImportGenericContext context) { TypeReference typeReference = ImportType(field.DeclaringType, context); if (IsGenericInstance(field.DeclaringType)) { field = ResolveFieldDefinition(field); } context.Push(typeReference); try { return(new FieldReference { Name = field.Name, DeclaringType = typeReference, FieldType = ImportType(field.FieldType, context) }); } finally { context.Pop(); } }
private MethodReference ImportMethodSpecification(MethodBase method, ImportGenericContext context) { MethodReference reference2; MethodInfo info = method as MethodInfo; if (info == null) { throw new InvalidOperationException(); } MethodReference reference = this.ImportMethod(info.GetGenericMethodDefinition(), context, ImportGenericKind.Definition); GenericInstanceMethod method2 = new GenericInstanceMethod(reference); Type[] genericArguments = method.GetGenericArguments(); Collection <TypeReference> collection = method2.GenericArguments; context.Push(reference); try { int index = 0; while (true) { if (index >= genericArguments.Length) { reference2 = method2; break; } collection.Add(this.ImportType(genericArguments[index], context)); index++; } } finally { context.Pop(); } return(reference2); }
public FieldReference ImportField(FieldInfo field, ImportGenericContext context) { FieldReference reference3; TypeReference provider = this.ImportType(field.DeclaringType, context); if (IsGenericInstance(field.DeclaringType)) { field = ResolveFieldDefinition(field); } context.Push(provider); try { reference3 = new FieldReference { Name = field.Name, DeclaringType = provider, FieldType = this.ImportType(field.FieldType, context) }; } finally { context.Pop(); } return(reference3); }
MethodReference ImportMethodSpecification(SR.MethodBase method, ImportGenericContext context) { var method_info = method as SR.MethodInfo; if (method_info == null) throw new InvalidOperationException (); var element_method = ImportMethod (method_info.GetGenericMethodDefinition (), context, ImportGenericKind.Definition); var instance = new GenericInstanceMethod (element_method); var arguments = method.GetGenericArguments (); var instance_arguments = instance.GenericArguments; context.Push (element_method); try { for (int i = 0; i < arguments.Length; i++) instance_arguments.Add (ImportType (arguments [i], context)); return instance; } finally { context.Pop (); } }
public MethodReference ImportMethod(SR.MethodBase method, ImportGenericContext context, ImportGenericKind import_kind) { if (IsMethodSpecification (method) || ImportOpenGenericMethod (method, import_kind)) return ImportMethodSpecification (method, context); var declaring_type = ImportType (method.DeclaringType, context); if (IsGenericInstance (method.DeclaringType)) method = method.Module.ResolveMethod (method.MetadataToken); var reference = new MethodReference { Name = method.Name, HasThis = HasCallingConvention (method, SR.CallingConventions.HasThis), ExplicitThis = HasCallingConvention (method, SR.CallingConventions.ExplicitThis), DeclaringType = ImportType (method.DeclaringType, context, ImportGenericKind.Definition), }; if (HasCallingConvention (method, SR.CallingConventions.VarArgs)) reference.CallingConvention &= MethodCallingConvention.VarArg; if (method.IsGenericMethod) ImportGenericParameters (reference, method.GetGenericArguments ()); context.Push (reference); try { var method_info = method as SR.MethodInfo; reference.ReturnType = method_info != null ? ImportType (method_info.ReturnType, context) : ImportType (typeof (void), default (ImportGenericContext)); var parameters = method.GetParameters (); var reference_parameters = reference.Parameters; for (int i = 0; i < parameters.Length; i++) reference_parameters.Add ( new ParameterDefinition (ImportType (parameters [i].ParameterType, context))); reference.DeclaringType = declaring_type; return reference; } finally { context.Pop (); } }
TypeReference ImportGenericInstance(Type type, ImportGenericContext context) { var element_type = ImportType (type.GetGenericTypeDefinition (), context, ImportGenericKind.Definition); var instance = new GenericInstanceType (element_type); var arguments = type.GetGenericArguments (); var instance_arguments = instance.GenericArguments; context.Push (element_type); try { for (int i = 0; i < arguments.Length; i++) instance_arguments.Add (ImportType (arguments [i], context)); return instance; } finally { context.Pop (); } }
public FieldReference ImportField(SR.FieldInfo field, ImportGenericContext context) { var declaring_type = ImportType (field.DeclaringType, context); if (IsGenericInstance (field.DeclaringType)) field = ResolveFieldDefinition (field); context.Push (declaring_type); try { return new FieldReference { Name = field.Name, DeclaringType = declaring_type, FieldType = ImportType (field.FieldType, context), }; } finally { context.Pop (); } }
public FieldReference ImportField(FieldReference field, ImportGenericContext context) { var declaring_type = ImportType (field.DeclaringType, context); context.Push (declaring_type); try { return new FieldReference { Name = field.Name, DeclaringType = declaring_type, FieldType = ImportType (field.FieldType, context), }; } finally { context.Pop (); } }
public MethodReference ImportMethod(MethodBase method, ImportGenericContext context, ImportGenericKind import_kind) { MethodReference reference4; if (IsMethodSpecification(method) || ImportOpenGenericMethod(method, import_kind)) { return(this.ImportMethodSpecification(method, context)); } TypeReference reference = this.ImportType(method.DeclaringType, context); if (IsGenericInstance(method.DeclaringType)) { method = method.Module.ResolveMethod(method.MetadataToken); } MethodReference provider = new MethodReference { Name = method.Name, HasThis = HasCallingConvention(method, CallingConventions.HasThis), ExplicitThis = HasCallingConvention(method, CallingConventions.ExplicitThis), DeclaringType = this.ImportType(method.DeclaringType, context, ImportGenericKind.Definition) }; if (HasCallingConvention(method, CallingConventions.VarArgs)) { provider.CallingConvention = (MethodCallingConvention)((byte)(provider.CallingConvention & MethodCallingConvention.VarArg)); } if (method.IsGenericMethod) { ImportGenericParameters(provider, method.GetGenericArguments()); } context.Push(provider); try { TypeReference reference1; MethodInfo info = method as MethodInfo; if (info != null) { reference1 = this.ImportType(info.ReturnType, context); } else { ImportGenericContext context2 = new ImportGenericContext(); reference1 = this.ImportType(typeof(void), context2); } provider.ReturnType = reference1; ParameterInfo[] parameters = method.GetParameters(); Collection <ParameterDefinition> collection = provider.Parameters; int index = 0; while (true) { if (index >= parameters.Length) { provider.DeclaringType = reference; reference4 = provider; break; } collection.Add(new ParameterDefinition(this.ImportType(parameters[index].ParameterType, context))); index++; } } finally { context.Pop(); } return(reference4); }
public MethodReference ImportMethod(MethodReference method, ImportGenericContext context) { if (method.IsGenericInstance) return ImportMethodSpecification (method, context); var declaring_type = ImportType (method.DeclaringType, context); var reference = new MethodReference { Name = method.Name, HasThis = method.HasThis, ExplicitThis = method.ExplicitThis, DeclaringType = declaring_type, CallingConvention = method.CallingConvention, }; if (method.HasGenericParameters) ImportGenericParameters (reference, method); context.Push (reference); try { reference.ReturnType = ImportType (method.ReturnType, context); if (!method.HasParameters) return reference; var reference_parameters = reference.Parameters; var parameters = method.Parameters; for (int i = 0; i < parameters.Count; i++) reference_parameters.Add ( new ParameterDefinition (ImportType (parameters [i].ParameterType, context))); return reference; } finally { context.Pop(); } }
internal FieldReference ImportField(FieldReference field, ImportGenericContext context, IImportMapper mapper) { var mapped = mapper.MapField(field); if (mapped == null) mapped = field; var declaring_type = ImportType(mapped.DeclaringType, context, mapper); context.Push (declaring_type); try { return new FieldReference { Name = mapped.Name, DeclaringType = declaring_type, FieldType = ImportType(mapped.FieldType, context, mapper), }; } finally { context.Pop (); } }