* 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
+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
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);
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
* "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
{
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
}
}
+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,
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}
};
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));
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;
}
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;
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);
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);
}