2004-06-11 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Fri, 11 Jun 2004 18:46:39 +0000 (18:46 -0000)
committerMartin Baulig <martin@novell.com>
Fri, 11 Jun 2004 18:46:39 +0000 (18:46 -0000)
* class.h (MonoInflatedField): New type.
(MonoClassField): Replaced `MonoType *generic_type' with
`MonoInflatedField *generic_info'.

* icall.c
(ves_icall_MonoField_Mono_GetGenericFieldDefinition): New icall.

svn path=/trunk/mono/; revision=29370

mono/metadata/ChangeLog
mono/metadata/class.c
mono/metadata/class.h
mono/metadata/icall.c
mono/metadata/reflection.c

index fffcea6664a55506a36def768e831980ca8610b0..e4cd8d63c5b82574890e2d1369b2dd3d6785133e 100644 (file)
@@ -1,3 +1,12 @@
+2004-06-11  Martin Baulig  <martin@ximian.com>
+
+       * class.h (MonoInflatedField): New type.
+       (MonoClassField): Replaced `MonoType *generic_type' with
+       `MonoInflatedField *generic_info'.
+
+       * icall.c
+       (ves_icall_MonoField_Mono_GetGenericFieldDefinition): New icall.
+
 2004-06-11  Martin Baulig  <martin@ximian.com>
 
        * reflection.c (mono_image_create_method_token): Correctly encode
index 04268a2522803ea0391122b21b8d319865c6dae8..8c630fdf3b7c3d1fa8b06319edd230f567f3450c 100644 (file)
@@ -1328,8 +1328,11 @@ mono_class_init (MonoClass *class)
                class->fields = g_new0 (MonoClassField, class->field.count);
 
                for (i = 0; i < class->field.count; i++) {
+                       MonoInflatedField *ifield = g_new0 (MonoInflatedField, 1);
+                       ifield->generic_type = gklass->fields [i].type;
+
                        class->fields [i] = gklass->fields [i];
-                       class->fields [i].generic_type = gklass->fields [i].type;
+                       class->fields [i].generic_info = ifield;
                        class->fields [i].parent = class;
                        class->fields [i].type = mono_class_inflate_generic_type (
                                class->fields [i].type, ginst->context);
index 538d5b6606d91360549a049a8f15ee02f2a927dd..a635adc7a5c6702ff87e486617a33ca869c0723f 100644 (file)
@@ -17,6 +17,11 @@ typedef struct {
        gpointer value;
 } MonoConstant;
 
+typedef struct {
+       MonoType *generic_type;
+       gpointer reflection_info;
+} MonoInflatedField;
+
 /*
  * MonoClassField is just a runtime representation of the metadata for
  * field, it doesn't contain the data directly.  Static fields are
@@ -31,7 +36,7 @@ typedef struct {
         * "original" type, ie. the MONO_TYPE_VAR or MONO_TYPE_GENERICINST
         * it was instantiated from.
         */
-       MonoType        *generic_type;
+       MonoInflatedField  *generic_info;
 
        /*
         * Offset where this field is stored; if it is an instance
index c3dd2cf48db5b94b8c78004a6a157cb0adb4f6f7..4c0a4d3d722ae2b87259362135424d4b4ab2ebcb 100644 (file)
@@ -908,7 +908,8 @@ ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilder *mb,
 {
        MONO_ARCH_SAVE_REGS;
 
-       return mono_image_create_method_token (mb->dynamic_image, method, opt_param_types);
+       return mono_image_create_method_token (
+               mb->dynamic_image, (MonoObject *) method, opt_param_types);
 }
 
 static gint32
@@ -1369,6 +1370,17 @@ ves_icall_FieldInfo_SetValueInternal (MonoReflectionField *field, MonoObject *ob
        }
 }
 
+static MonoReflectionField*
+ves_icall_MonoField_Mono_GetGenericFieldDefinition (MonoReflectionField *field)
+{
+       MONO_ARCH_SAVE_REGS;
+
+       if (field->field->generic_info && field->field->generic_info->reflection_info)
+               return field->field->generic_info->reflection_info;
+
+       return field;
+}
+
 /* From MonoProperty.cs */
 typedef enum {
        PInfo_Attributes = 1,
@@ -5339,6 +5351,7 @@ static const IcallEntry monoeventinfo_icalls [] = {
 static const IcallEntry monofield_icalls [] = {
        {"GetParentType", ves_icall_MonoField_GetParentType},
        {"GetValueInternal", ves_icall_MonoField_GetValueInternal},
+       {"Mono_GetGenericFieldDefinition", ves_icall_MonoField_Mono_GetGenericFieldDefinition},
        {"SetValueInternal", ves_icall_FieldInfo_SetValueInternal}
 };
 
index 51df1e67f3d6988b4b6d5b502e27f2c89b1a87a8..4ad5faa5275e005966ce531da18a0a00b86eb699 100644 (file)
@@ -2313,7 +2313,7 @@ mono_image_get_fieldref_token (MonoDynamicImage *assembly, MonoReflectionField *
        if (token)
                return token;
        g_assert (f->field->parent);
-       type = f->field->generic_type ? f->field->generic_type : f->field->type;
+       type = f->field->generic_info ? f->field->generic_info->generic_type : f->field->type;
        token = mono_image_get_memberref_token (assembly, &f->klass->byval_arg, 
                f->field->name,  fieldref_encode_signature (assembly, type));
        g_hash_table_insert (assembly->handleref, f, GUINT_TO_POINTER(token));
@@ -3397,7 +3397,7 @@ fixup_method (MonoReflectionILGen *ilgen, gpointer value, MonoDynamicImage *asse
                                continue;
                        } else if (!strcmp (iltoken->member->vtable->klass->name, "MonoField")) {
                                MonoClassField *f = ((MonoReflectionField*)iltoken->member)->field;
-                               g_assert (f->generic_type);
+                               g_assert (f->generic_info);
                                continue;
                        } else if (!strcmp (iltoken->member->vtable->klass->name, "MethodBuilder")) {
                                continue;
@@ -3986,7 +3986,7 @@ mono_image_create_token (MonoDynamicImage *assembly, MonoObject *obj)
        }
        else if (strcmp (klass->name, "MonoField") == 0) {
                MonoReflectionField *f = (MonoReflectionField *)obj;
-               if ((f->klass->image == &assembly->image) && !f->field->generic_type) {
+               if ((f->klass->image == &assembly->image) && !f->field->generic_info) {
                        static guint32 field_table_idx = 0xffffff;
                        field_table_idx --;
                        token = MONO_TOKEN_FIELD_DEF | field_table_idx;
@@ -7437,6 +7437,7 @@ mono_reflection_generic_inst_initialize (MonoReflectionGenericInst *type,
        for (i = 0; i < dginst->count_fields; i++) {
                MonoObject *obj = mono_array_get (fields, gpointer, i);
                MonoClassField *field;
+               MonoInflatedField *ifield;
 
                if (!strcmp (obj->vtable->klass->name, "FieldBuilder"))
                        field = fieldbuilder_to_mono_class_field (klass, (MonoReflectionFieldBuilder *) obj);
@@ -7447,8 +7448,12 @@ mono_reflection_generic_inst_initialize (MonoReflectionGenericInst *type,
                        g_assert_not_reached ();
                }
 
+               ifield = g_new0 (MonoInflatedField, 1);
+               ifield->generic_type = field->type;
+               ifield->reflection_info = obj;
+
                dginst->fields [i] = *field;
-               dginst->fields [i].generic_type = field->type;
+               dginst->fields [i].generic_info = ifield;
                dginst->fields [i].type = mono_class_inflate_generic_type (field->type, ginst->context);
        }