2009-12-08 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Tue, 8 Dec 2009 14:06:38 +0000 (14:06 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 8 Dec 2009 14:06:38 +0000 (14:06 -0000)
* ParameterInfo.cs: Add constructor that takes an array of ParameterInfo
objects.

2009-12-08 Rodrigo Kumpera  <rkumpera@novell.com>

* MethodOnTypeBuilderInst.cs: Change base_method type from MethodBuilder to
MethodInfo.

svn path=/trunk/mcs/; revision=147850

mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/MethodOnTypeBuilderInst.cs
mcs/class/corlib/System.Reflection/ChangeLog
mcs/class/corlib/System.Reflection/ParameterInfo.cs

index 75ffe9fa4ee7711fd527f92b2e991a144f1f1993..a5e9cb5193db7a18aa53ff9538a8647f121903b8 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-08 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * MethodOnTypeBuilderInst.cs: Change base_method type from MethodBuilder to
+       MethodInfo.
+
 2009-12-08 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * DerivedTypes.cs: Implement IsCompilerContext property and replace
index 1b3cab626072cd3cd364c9071a0b80c4adddf1bd..11873f28399b3b291b0aee73e9da62ee5039b888 100644 (file)
@@ -41,7 +41,7 @@ namespace System.Reflection.Emit
        {
                #region Keep in sync with object-internals.h
                Type instantiation;
-               internal MethodBuilder base_method; /*This is the base method definition, it must be non-inflated and belong to a non-inflated type.*/
+               MethodInfo base_method; /*This is the base method definition, it must be non-inflated and belong to a non-inflated type.*/
                Type[] method_arguments;
                MethodOnTypeBuilderInst generic_method_definition;
                #endregion
@@ -155,13 +155,24 @@ namespace System.Reflection.Emit
 
                public override ParameterInfo [] GetParameters ()
                {
+                       ParameterInfo [] res = null;
                        if (!IsCompilerContext)
                                throw new NotSupportedException ();
 
-                       ParameterInfo [] res = new ParameterInfo [base_method.parameters.Length];
-                       for (int i = 0; i < base_method.parameters.Length; i++) {
-                               Type type = MonoGenericClass.InflateType (base_method.parameters [i], GetTypeArgs (), method_arguments);
-                               res [i] = new ParameterInfo (base_method.pinfo == null ? null : base_method.pinfo [i + 1], type, this, i + 1);
+                       if (base_method is MethodBuilder) {
+                               MethodBuilder mb = (MethodBuilder)base_method;
+                               res = new ParameterInfo [mb.parameters.Length];
+                               for (int i = 0; i < mb.parameters.Length; i++) {
+                                       Type type = MonoGenericClass.InflateType (mb.parameters [i], GetTypeArgs (), method_arguments);
+                                       res [i] = new ParameterInfo (mb.pinfo == null ? null : mb.pinfo [i + 1], type, this, i + 1);
+                               }
+                       } else {
+                               ParameterInfo[] base_params = base_method.GetParameters ();
+                               res = new ParameterInfo [base_params.Length];
+                               for (int i = 0; i < base_params.Length; i++) {
+                                       Type type = MonoGenericClass.InflateType (base_params [i].ParameterType, GetTypeArgs (), method_arguments);
+                                       res [i] = new ParameterInfo (base_params [i], type, this, i + 1);
+                               }
                        }
                        return res;
                }
@@ -204,13 +215,13 @@ namespace System.Reflection.Emit
 
                public override MethodInfo MakeGenericMethod (params Type [] methodInstantiation)
                {
-                       if (base_method.generic_params == null || (method_arguments != null && !IsCompilerContext))
+                       if (!base_method.IsGenericMethodDefinition || (method_arguments != null && !IsCompilerContext))
                                throw new InvalidOperationException ("Method is not a generic method definition");
 
                        if (methodInstantiation == null)
                                throw new ArgumentNullException ("methodInstantiation");
 
-                       if (base_method.generic_params.Length != methodInstantiation.Length)
+                       if (base_method.GetGenericArguments ().Length != methodInstantiation.Length)
                                throw new ArgumentException ("Incorrect length", "methodInstantiation");
 
                        foreach (Type type in methodInstantiation) {
@@ -218,17 +229,14 @@ namespace System.Reflection.Emit
                                        throw new ArgumentNullException ("methodInstantiation");
                        }
 
-                       if (base_method.generic_params.Length != methodInstantiation.Length)
-                               throw new ArgumentException ("Invalid argument array length");
-
                        return new MethodOnTypeBuilderInst (this, methodInstantiation);
                }
 
                public override Type [] GetGenericArguments ()
                {
-                       if (base_method.generic_params == null)
+                       if (!base_method.IsGenericMethodDefinition)
                                return null;
-                       Type[] source = method_arguments ?? base_method.generic_params;
+                       Type[] source = method_arguments ?? base_method.GetGenericArguments ();
                        Type[] result = new Type [source.Length];
                        source.CopyTo (result, 0);
                        return result;
@@ -241,7 +249,7 @@ namespace System.Reflection.Emit
 
                public override bool ContainsGenericParameters {
                        get {
-                               if (base_method.generic_params == null)
+                               if (!base_method.IsGenericMethodDefinition)
                                        throw new NotSupportedException ();
                                if (method_arguments == null)
                                        return true;
@@ -255,13 +263,13 @@ namespace System.Reflection.Emit
 
                public override bool IsGenericMethodDefinition {
                        get {
-                               return base_method.generic_params != null && method_arguments == null;
+                               return base_method.IsGenericMethodDefinition && method_arguments == null;
                        }
                }
 
                public override bool IsGenericMethod {
                        get {
-                               return base_method.generic_params != null;
+                               return base_method.IsGenericMethodDefinition;
                        }
                }
 
index 09b6a30dee9a85b91c57465c2a69a0d70e24ee95..f330b574091145a7fb540059ab240533a0053226 100644 (file)
@@ -1,3 +1,8 @@
+2009-12-08 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * ParameterInfo.cs: Add constructor that takes an array of ParameterInfo
+       objects.
+
 2009-12-08 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * MonoGenericClass.cs: Implement IsCompilerContext property and replace
index 5d0f186dfece131020c052d03e95e307abdb1ca3..f1691484432e8ace7279e95b0720b075430732b8 100644 (file)
@@ -62,6 +62,20 @@ namespace System.Reflection
                        }
                }
 
+               internal ParameterInfo (ParameterInfo pinfo, Type type, MemberInfo member, int position) {
+                       this.ClassImpl = type;
+                       this.MemberImpl = member;
+                       if (pinfo != null) {
+                               this.NameImpl = pinfo.Name;
+                               this.PositionImpl = pinfo.Position - 1; // ParameterInfo.Position is zero-based
+                               this.AttrsImpl = (ParameterAttributes) pinfo.Attributes;
+                       } else {
+                               this.NameImpl = null;
+                               this.PositionImpl = position - 1;
+                               this.AttrsImpl = ParameterAttributes.None;
+                       }
+               }
+
                /* to build a ParameterInfo for the return type of a method */
                internal ParameterInfo (Type type, MemberInfo member, UnmanagedMarshal marshalAs) {
                        this.ClassImpl = type;