In System.Reflection.Emit:
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 16 Jul 2008 17:22:30 +0000 (17:22 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Wed, 16 Jul 2008 17:22:30 +0000 (17:22 -0000)
2008-07-16  Rodrigo Kumpera  <rkumpera@novell.com>

* MethodOnTypeBuilderInst.cs: Special case all methods
under compiler context as needed by mcs.

* MethodBuilder.cs: Change the visibility of some fields
to internal so MethodOnTypeBuilderInst can use it.

In System.Reflection:
2008-07-16  Rodrigo Kumpera  <rkumpera@novell.com>

* MonoGenericClass.cs (GetMethod): Use the new codepath for compiler
context.

* MonoGenericClass.cs: New InflateType method, used to inflate
managed types.

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

mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/MethodBuilder.cs
mcs/class/corlib/System.Reflection.Emit/MethodOnTypeBuilderInst.cs
mcs/class/corlib/System.Reflection/ChangeLog
mcs/class/corlib/System.Reflection/MonoGenericClass.cs

index d1fc3f8197636ef7e229543fe2ba70c8095cb3da..eb0b842f9e1e88146a02e4f438e1ce981c15da91 100644 (file)
@@ -1,3 +1,11 @@
+2008-07-16  Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * MethodOnTypeBuilderInst.cs: Special case all methods
+       under compiler context as needed by mcs. 
+
+       * MethodBuilder.cs: Change the visibility of some fields
+       to internal so MethodOnTypeBuilderInst can use it.
+
 2008-07-11  Marek Safar  <marek.safar@gmail.com>
 
        * ModuleBuilder.cs: Couple of micro optimizations.
index 33a72019fefc5a31ea3ba33a5ba252e28f301c0e..e923d1da2caf2c6f224ec2d8dadae02106b0025a 100644 (file)
@@ -51,7 +51,7 @@ namespace System.Reflection.Emit
        {
                private RuntimeMethodHandle mhandle;
                private Type rtype;
-               private Type[] parameters;
+               internal Type[] parameters;
                private MethodAttributes attrs; /* It's used directly by MCS */
                private MethodImplAttributes iattrs;
                private string name;
@@ -59,7 +59,7 @@ namespace System.Reflection.Emit
                private byte[] code;
                private ILGenerator ilgen;
                private TypeBuilder type;
-               private ParameterBuilder[] pinfo;
+               internal ParameterBuilder[] pinfo;
                private CustomAttributeBuilder[] cattrs;
                private MethodInfo override_method;
                private string pi_dll;
index edade52c47aee5f443a9ee8872f89010853e9e25..f334b8462bfb5f2c65020726f8249cf1e0956a2c 100644 (file)
@@ -74,7 +74,11 @@ namespace System.Reflection.Emit
                }
 
                public override Type ReturnType {
-                       get { return mb.ReturnType; }
+                       get { 
+                               if (!((ModuleBuilder)mb.Module).assemblyb.IsCompilerContext)
+                                       return mb.ReturnType;
+                               return instantiation.InflateType (mb.ReturnType);
+                       }
                }
 
                public override bool IsDefined (Type attributeType, bool inherit)
@@ -103,7 +107,23 @@ namespace System.Reflection.Emit
 
                public override ParameterInfo [] GetParameters ()
                {
-                       throw new NotSupportedException ();
+                       if (!((ModuleBuilder)mb.Module).assemblyb.IsCompilerContext)
+                               throw new NotSupportedException ();
+
+                       ParameterInfo [] res = new ParameterInfo [mb.parameters.Length];
+                       for (int i = 0; i < mb.parameters.Length; i++) {
+                               Type type = instantiation.InflateType (mb.parameters [i]);
+                               res [i] = new ParameterInfo (mb.pinfo == null ? null : mb.pinfo [i + 1], type, this, i + 1);
+                       }
+                       return res;
+               }
+
+               public override int MetadataToken {
+                       get {
+                               if (!((ModuleBuilder)mb.Module).assemblyb.IsCompilerContext)
+                                       return base.MetadataToken;
+                               return mb.MetadataToken;
+                       }
                }
 
                internal override int GetParameterCount ()
@@ -136,6 +156,7 @@ namespace System.Reflection.Emit
 
                public override Type [] GetGenericArguments ()
                {
+                       //FIXME test that once we support generic methods 
                        return mb.GetGenericArguments ();
                }
 
@@ -152,12 +173,14 @@ namespace System.Reflection.Emit
 
                public override bool IsGenericMethodDefinition {
                        get {
+                               //FIXME test that once we support generic methods 
                                return mb.IsGenericMethodDefinition;
                        }
                }
 
                public override bool IsGenericMethod {
                        get {
+                               //FIXME test that once we support generic methods 
                                return mb.IsGenericMethod;
                        }
                }
index 5db0f325f4d4658dce8110c60b7291ee160ce778..916052952eef16919f4a96f065e33f0e70145ca9 100644 (file)
@@ -1,8 +1,16 @@
+2008-07-16  Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * MonoGenericClass.cs (GetMethod): Use the new codepath for compiler
+       context.
+
+       * MonoGenericClass.cs: New InflateType method, used to inflate
+       managed types.
+
 2008-07-11  Marek Safar  <marek.safar@gmail.com>
 
        * MonoGenericClass.cs (GetField): Put back removed code.
 
-2008-07-04  Rodrigo Kumpera  <rkumpera@n ovell.com>
+2008-07-04  Rodrigo Kumpera  <rkumpera@novell.com>
 
        * MethodBase.cs (GetMethodFromHandle): Fix a warning in
        the 1.0 build.
index 030fe8e497918cf346d9afef2aa901c8b4dad207..2facf3a159b85ccdcee35b6f89e9b0ca24b0cdf5 100644 (file)
@@ -115,6 +115,16 @@ namespace System.Reflection
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                protected extern Type GetParentType ();
 
+               [MethodImplAttribute(MethodImplOptions.InternalCall)]
+               private extern Type InflateType_internal (Type type);
+
+               internal Type InflateType (Type type)
+               {
+                       if (!type.IsGenericParameter && !type.ContainsGenericParameters)
+                               return type;
+                       return InflateType_internal (type);
+               }
+               
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                protected extern MonoGenericClass[] GetInterfaces_internal ();
 
@@ -149,7 +159,7 @@ namespace System.Reflection
                                // MethodOnTypeBuilderInst objects
                                // Also, mono_image_get_method_on_inst_token () can't handle generic
                                // methods
-                               if (!((ModuleBuilder)mb.Module).assemblyb.IsCompilerContext && !mb.IsGenericMethodDefinition) {
+                               if (!mb.IsGenericMethodDefinition) {
                                        if (methods == null)
                                                methods = new Hashtable ();
                                        if (!methods.ContainsKey (mb))