2009-07-23 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Thu, 23 Jul 2009 21:04:50 +0000 (21:04 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Thu, 23 Jul 2009 21:04:50 +0000 (21:04 -0000)
* FieldOnTypeBuilderInst.cs: Implement MetadataToken and FieldToken
for compiler context.

* TypeBuilder.cs: Make FieldBuilder related fields internal.

2009-07-23 Rodrigo Kumpera  <rkumpera@novell.com>

* MonoGenericClass.cs: Kill GetFields_internal and implement it
all in terms of managed code.

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

mcs/class/corlib/System.Reflection.Emit/ChangeLog
mcs/class/corlib/System.Reflection.Emit/FieldOnTypeBuilderInst.cs
mcs/class/corlib/System.Reflection.Emit/TypeBuilder.cs
mcs/class/corlib/System.Reflection/ChangeLog
mcs/class/corlib/System.Reflection/MonoGenericClass.cs

index db458ddbc368c39d1b60a97a1eaa3624149fd2b8..07c173a2be329c2215083605516c7153d7446e4c 100644 (file)
@@ -1,3 +1,10 @@
+2009-07-23 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * FieldOnTypeBuilderInst.cs: Implement MetadataToken and FieldToken
+       for compiler context.
+
+       * TypeBuilder.cs: Make FieldBuilder related fields internal.
+
 2009-07-23 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * PropertyOnTypeBuilderInst.cs: Use TypeBuilder::GetMethod instead of
index 2442db3a7a21cdf29da26ec4b2c781956c619001..17747e60b802f996ec18c386ddc4dce8f1a9c48a 100644 (file)
@@ -100,10 +100,19 @@ namespace System.Reflection.Emit
                        }
                }
 
+               public override int MetadataToken {
+                       get {
+                               if (!((ModuleBuilder)instantiation.generic_type.Module).assemblyb.IsCompilerContext)
+                                       throw new InvalidOperationException ();
+                               return fb.MetadataToken;
+                       } 
+               }
+
                public override Type FieldType {
                        get {
-                               // FIXME:
-                               throw new NotImplementedException ();
+                               if (!((ModuleBuilder)instantiation.generic_type.Module).assemblyb.IsCompilerContext)
+                                       throw new NotSupportedException ();
+                               return instantiation.InflateType (fb.FieldType);
                        }
                }
 
index b0e56fd48aef8283890e6286d7fb22512292c221..f35b0a3db3db48a5c2eed0b1294f706f23e89f23 100644 (file)
@@ -63,8 +63,8 @@ namespace System.Reflection.Emit
                internal MethodBuilder[] methods;
                private ConstructorBuilder[] ctors;
                internal PropertyBuilder[] properties;
-               private int num_fields;
-               private FieldBuilder[] fields;
+               internal int num_fields;
+               internal FieldBuilder[] fields;
                private EventBuilder[] events;
                private CustomAttributeBuilder[] cattrs;
                internal TypeBuilder[] subtypes;
index 71753f4e0e5f10ff56af24d8dfc5ae379d4e565f..56e556949e2bb05413a1bb2c21ac561e6c2dd98c 100644 (file)
@@ -1,3 +1,8 @@
+2009-07-23 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * MonoGenericClass.cs: Kill GetFields_internal and implement it
+       all in terms of managed code.
+
 2009-07-23 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * MonoGenericClass.cs: Kill GetMethods_internal and implement it
index 54a80734ca2530218acfe4afebed69c7ca971b87..aba6c58935b65bcb78bb30376cbe981aa4907bc3 100644 (file)
@@ -83,9 +83,6 @@ namespace System.Reflection
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                protected extern ConstructorInfo[] GetConstructors_internal (Type reflected_type);
 
-               [MethodImplAttribute(MethodImplOptions.InternalCall)]
-               protected extern FieldInfo[] GetFields_internal (Type reflected_type);
-
                [MethodImplAttribute(MethodImplOptions.InternalCall)]
                protected extern EventInfo[] GetEvents_internal (Type reflected_type);
 
@@ -370,7 +367,7 @@ namespace System.Reflection
                        do {
                                MonoGenericClass gi = current_type as MonoGenericClass;
                                if (gi != null)
-                                       l.AddRange (gi.GetFields_impl (bf, this));
+                                       l.AddRange (gi.GetFieldsInternal (bf, this));
                                else if (current_type is TypeBuilder)
                                        l.AddRange (current_type.GetFields (bf));
                                else {
@@ -389,18 +386,19 @@ namespace System.Reflection
                        return result;
                }
 
-               protected FieldInfo[] GetFields_impl (BindingFlags bf, Type reftype)
+               FieldInfo[] GetFieldsInternal (BindingFlags bf, MonoGenericClass reftype)
                {
+                       if (generic_type.num_fields == 0)
+                               return new FieldInfo [0];
+
                        ArrayList l = new ArrayList ();
                        bool match;
                        FieldAttributes fattrs;
 
                        initialize ();
 
-                       FieldInfo[] fields = GetFields_internal (reftype);
-
-                       for (int i = 0; i < fields.Length; i++) {
-                               FieldInfo c = fields [i];
+                       for (int i = 0; i < generic_type.num_fields; i++) {
+                               FieldInfo c = generic_type.fields [i];
 
                                match = false;
                                fattrs = c.Attributes;
@@ -423,8 +421,9 @@ namespace System.Reflection
                                }
                                if (!match)
                                        continue;
-                               l.Add (c);
+                               l.Add (TypeBuilder.GetField (this, c));
                        }
+
                        FieldInfo[] result = new FieldInfo [l.Count];
                        l.CopyTo (result);
                        return result;