Author: zoltan
Date: 2008-01-22 06:23:02 -0500 (Tue, 22 Jan 2008)
New Revision: 93506

Modified:
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/icall.c
   trunk/mono/mono/metadata/object-internals.h
   trunk/mono/mono/metadata/reflection.c
Log:
2008-01-22  Zoltan Varga  <[EMAIL PROTECTED]>

        * object-internals.h (MonoReflectionGenericClass): Make the 
'generic_type' field
        a MonoReflectionTypeBuilder since it is always of that type.

        * reflection.c (mono_type_get_object): Remove an unneccesary check.     

        * reflection.c (mono_generic_class_get_object): Simplify this a bit.

        * reflection.c (mono_reflection_bind_generic_parameters): Ditto.
        
        * icall.c (ves_icall_MonoGenericClass_GetParentType): Ditto.

        * icall.c (ves_icall_MonoGenericClass_GetInterfaces): Ditto.


Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2008-01-22 11:01:50 UTC (rev 93505)
+++ trunk/mono/mono/metadata/ChangeLog  2008-01-22 11:23:02 UTC (rev 93506)
@@ -1,5 +1,18 @@
 2008-01-22  Zoltan Varga  <[EMAIL PROTECTED]>
 
+       * object-internals.h (MonoReflectionGenericClass): Make the 
'generic_type' field
+       a MonoReflectionTypeBuilder since it is always of that type.
+
+       * reflection.c (mono_type_get_object): Remove an unneccesary check.     
+
+       * reflection.c (mono_generic_class_get_object): Simplify this a bit.
+
+       * reflection.c (mono_reflection_bind_generic_parameters): Ditto.
+       
+       * icall.c (ves_icall_MonoGenericClass_GetParentType): Ditto.
+
+       * icall.c (ves_icall_MonoGenericClass_GetInterfaces): Ditto.
+
        * reflection.c (mono_reflection_create_runtime_class): Remove already 
created
        instantiations from the type cache.
 

Modified: trunk/mono/mono/metadata/icall.c
===================================================================
--- trunk/mono/mono/metadata/icall.c    2008-01-22 11:01:50 UTC (rev 93505)
+++ trunk/mono/mono/metadata/icall.c    2008-01-22 11:23:02 UTC (rev 93506)
@@ -2297,22 +2297,12 @@
        gclass = (MonoDynamicGenericClass *) 
type->type.type->data.generic_class;
 
        domain = mono_object_domain (type);
-       klass = mono_class_from_mono_type (type->generic_type->type);
+       klass = mono_class_from_mono_type (type->generic_type->type.type);
 
        if (!klass->generic_class && !klass->generic_container)
                return NULL;
 
-       if (!strcmp (type->generic_type->object.vtable->klass->name, 
"TypeBuilder")) {
-               MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *) 
type->generic_type;
-               parent = tb->parent;
-       } else if (klass->wastypebuilder) {
-               MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder *) 
type->generic_type;
-               parent = tb->parent;
-       } else {
-               MonoClass *pklass = klass->parent;
-               if (pklass)
-                       parent = mono_type_get_object (domain, 
&pklass->byval_arg);
-       }
+       parent = type->generic_type->parent;
 
        if (!parent || (parent->type->type != MONO_TYPE_GENERICINST))
                return NULL;
@@ -2347,14 +2337,8 @@
        gclass = type->type.type->data.generic_class;
        g_assert (gclass->is_dynamic);
 
-       if (!strcmp (type->generic_type->object.vtable->klass->name, 
"TypeBuilder")) {
-               tb = (MonoReflectionTypeBuilder *) type->generic_type;
-               icount = tb->interfaces ? mono_array_length (tb->interfaces) : 
0;
-       } else {
-               klass = gclass->container_class;
-               mono_class_init (klass);
-               icount = klass->interface_count;
-       }
+       tb = type->generic_type;
+       icount = tb->interfaces ? mono_array_length (tb->interfaces) : 0;
 
        res = mono_array_new (domain, System_Reflection_MonoGenericClass, 
icount);
 

Modified: trunk/mono/mono/metadata/object-internals.h
===================================================================
--- trunk/mono/mono/metadata/object-internals.h 2008-01-22 11:01:50 UTC (rev 
93505)
+++ trunk/mono/mono/metadata/object-internals.h 2008-01-22 11:23:02 UTC (rev 
93506)
@@ -936,7 +936,7 @@
 typedef struct _MonoReflectionGenericClass MonoReflectionGenericClass;
 struct _MonoReflectionGenericClass {
        MonoReflectionType type;
-       MonoReflectionType *generic_type;
+       MonoReflectionTypeBuilder *generic_type;
        guint32 initialized;
 };
 

Modified: trunk/mono/mono/metadata/reflection.c
===================================================================
--- trunk/mono/mono/metadata/reflection.c       2008-01-22 11:01:50 UTC (rev 
93505)
+++ trunk/mono/mono/metadata/reflection.c       2008-01-22 11:23:02 UTC (rev 
93506)
@@ -5494,10 +5494,9 @@
 #endif
 
        res->type.type = geninst;
-       if (gklass->wastypebuilder && gklass->reflection_info)
-               MONO_OBJECT_SETREF (res, generic_type, gklass->reflection_info);
-       else
-               MONO_OBJECT_SETREF (res, generic_type, mono_type_get_object 
(domain, &gklass->byval_arg));
+       g_assert (gklass->reflection_info);
+       g_assert (!strcmp 
(((MonoObject*)gklass->reflection_info)->vtable->klass->name, "TypeBuilder"));
+       MONO_OBJECT_SETREF (res, generic_type, gklass->reflection_info);
 
        return res;
 }
@@ -5552,7 +5551,8 @@
                mono_domain_unlock (domain);
                return res;
        }
-       if ((type->type == MONO_TYPE_GENERICINST) && 
type->data.generic_class->is_dynamic && 
!(type->data.generic_class->container_class && 
type->data.generic_class->container_class->wastypebuilder)) {
+       /* Create a MonoGenericClass object for instantiations of not finished 
TypeBuilders */
+       if ((type->type == MONO_TYPE_GENERICINST) && 
type->data.generic_class->is_dynamic && 
!type->data.generic_class->container_class->wastypebuilder) {
                res = (MonoReflectionType *)mono_generic_class_get_object 
(domain, type);
                mono_g_hash_table_insert (domain->type_hash, type, res);
                mono_domain_unlock (domain);
@@ -8905,11 +8905,8 @@
                is_dynamic = TRUE;
        } else if (!strcmp (((MonoObject *) type)->vtable->klass->name, 
"MonoGenericClass")) {
                MonoReflectionGenericClass *rgi = (MonoReflectionGenericClass 
*) type;
-               MonoReflectionType *rgt = rgi->generic_type;
 
-               g_assert (!strcmp (((MonoObject *) rgt)->vtable->klass->name, 
"TypeBuilder"));
-               tb = (MonoReflectionTypeBuilder *) rgt;
-
+               tb = rgi->generic_type;
                is_dynamic = TRUE;
        }
 
@@ -9039,7 +9036,7 @@
        MonoMethod *method;
        MonoClass *gklass;
 
-       gklass = mono_class_from_mono_type (type->generic_type->type);
+       gklass = mono_class_from_mono_type (type->generic_type->type.type);
 
        if (!strcmp (obj->vtable->klass->name, "MethodBuilder"))
                method = methodbuilder_to_mono_method (gklass, 
(MonoReflectionMethodBuilder *) obj);

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to