2004-03-30 Martin Baulig <martin@ximian.com>
authorMartin Baulig <martin@novell.com>
Wed, 31 Mar 2004 02:12:49 +0000 (02:12 -0000)
committerMartin Baulig <martin@novell.com>
Wed, 31 Mar 2004 02:12:49 +0000 (02:12 -0000)
* class.c (mono_ldtoken): Added `MonoGenericContext *' argument.
(mono_class_create_from_typespec): Likewise.

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

mono/interpreter/interp.c
mono/metadata/ChangeLog
mono/metadata/class.c
mono/metadata/class.h
mono/metadata/reflection.c
mono/mini/jit-icalls.c
mono/mini/mini.c

index 7793b27971aefcbd37175184ffebef99471fdd67..4c92d7c1d1a1e5833e03ec111f961f88f595d2db 100644 (file)
@@ -3927,7 +3927,7 @@ array_constructed:
                        gpointer handle;
                        MonoClass *handle_class;
                        ++ip;
-                       handle = mono_ldtoken (image, read32 (ip), &handle_class);
+                       handle = mono_ldtoken (image, read32 (ip), &handle_class, generic_context);
                        ip += 4;
                        vt_alloc (&handle_class->byval_arg, sp, FALSE);
                        stackval_from_data (&handle_class->byval_arg, sp, (char*)&handle, FALSE);
index d72568d2a310b9bfa4c03a790dda5be407092e66..eccdcd837e582b9fe90a75b87df5dcb1d318763b 100644 (file)
@@ -1,3 +1,8 @@
+2004-03-30  Martin Baulig  <martin@ximian.com>
+
+       * class.c (mono_ldtoken): Added `MonoGenericContext *' argument.
+       (mono_class_create_from_typespec): Likewise.
+
 2004-03-30  Martin Baulig  <martin@ximian.com>
 
        * reflection.h (MonoReflectionGenericParam): Use MonoBoolean for
index 750c6d8438020599b9ff523a19b02598a3275118..72c7c9144d1086d17b912a3e8d2c140945604fd2 100644 (file)
@@ -2094,9 +2094,10 @@ mono_class_from_mono_type (MonoType *type)
  * @type_spec:  typespec token
  */
 static MonoClass *
-mono_class_create_from_typespec (MonoImage *image, guint32 type_spec)
+mono_class_create_from_typespec (MonoImage *image, guint32 type_spec,
+                                MonoGenericContext *context)
 {
-       MonoType *type;
+       MonoType *type, *inflated;
        MonoClass *class;
 
        type = mono_type_create_from_typespec (image, type_spec);
@@ -2113,7 +2114,7 @@ mono_class_create_from_typespec (MonoImage *image, guint32 type_spec)
                break;
        case MONO_TYPE_GENERICINST:
                g_assert (type->data.generic_inst->klass);
-               return type->data.generic_inst->klass;
+               class = type->data.generic_inst->klass;
                break;
        default:
                /* it seems any type can be stored in TypeSpec as well */
@@ -2121,7 +2122,12 @@ mono_class_create_from_typespec (MonoImage *image, guint32 type_spec)
                break;
        }
 
-       return class;
+       if (!class || !context)
+               return class;
+
+       inflated = mono_class_inflate_generic_type (&class->byval_arg, context);
+
+       return mono_class_from_mono_type (inflated);
 }
 
 /**
@@ -2409,7 +2415,7 @@ mono_class_get (MonoImage *image, guint32 type_token)
                class = mono_class_from_typeref (image, type_token);
                break;
        case MONO_TOKEN_TYPE_SPEC:
-               class = mono_class_create_from_typespec (image, type_token);
+               class = mono_class_create_from_typespec (image, type_token, NULL);
                break;
        default:
                g_warning ("unknown token type %x", type_token & 0xff000000);
@@ -2723,7 +2729,8 @@ mono_array_element_size (MonoClass *ac)
 }
 
 gpointer
-mono_ldtoken (MonoImage *image, guint32 token, MonoClass **handle_class)
+mono_ldtoken (MonoImage *image, guint32 token, MonoClass **handle_class,
+             MonoGenericContext *context)
 {
        if (image->dynamic) {
                gpointer obj = mono_lookup_dynamic_token (image, token);
@@ -2754,7 +2761,7 @@ mono_ldtoken (MonoImage *image, guint32 token, MonoClass **handle_class)
                MonoClass *class;
                if (handle_class)
                        *handle_class = mono_defaults.typehandle_class;
-               class = mono_class_get (image, token);
+               class = mono_class_get_full (image, token, context);
                mono_class_init (class);
                /* We return a MonoType* as handle */
                return &class->byval_arg;
@@ -2763,14 +2770,14 @@ mono_ldtoken (MonoImage *image, guint32 token, MonoClass **handle_class)
                MonoClass *class;
                if (handle_class)
                        *handle_class = mono_defaults.typehandle_class;
-               class = mono_class_create_from_typespec (image, token);
+               class = mono_class_create_from_typespec (image, token, context);
                mono_class_init (class);
                return &class->byval_arg;
        }
        case MONO_TOKEN_FIELD_DEF: {
                MonoClass *class;
                guint32 type = mono_metadata_typedef_from_field (image, mono_metadata_token_index (token));
-               class = mono_class_get (image, MONO_TOKEN_TYPE_DEF | type);
+               class = mono_class_get_full (image, MONO_TOKEN_TYPE_DEF | type, context);
                mono_class_init (class);
                if (handle_class)
                        *handle_class = mono_defaults.fieldhandle_class;
@@ -2778,7 +2785,7 @@ mono_ldtoken (MonoImage *image, guint32 token, MonoClass **handle_class)
        }
        case MONO_TOKEN_METHOD_DEF: {
                MonoMethod *meth;
-               meth = mono_get_method (image, token, NULL);
+               meth = mono_get_method_full (image, token, NULL, context);
                if (handle_class)
                        *handle_class = mono_defaults.methodhandle_class;
                return meth;
@@ -2792,13 +2799,13 @@ mono_ldtoken (MonoImage *image, guint32 token, MonoClass **handle_class)
                if (*sig == 0x6) { /* it's a field */
                        MonoClass *klass;
                        MonoClassField *field;
-                       field = mono_field_from_token (image, token, &klass, NULL);
+                       field = mono_field_from_token (image, token, &klass, context);
                        if (handle_class)
                                *handle_class = mono_defaults.fieldhandle_class;
                        return field;
                } else {
                        MonoMethod *meth;
-                       meth = mono_get_method (image, token, NULL);
+                       meth = mono_get_method_full (image, token, NULL, context);
                        if (handle_class)
                                *handle_class = mono_defaults.methodhandle_class;
                        return meth;
index 44364e782921f1bb4e6df1cea62f36ef5d605e33..849f12423319e6a3d2a5d4f5762be4085fff2599 100644 (file)
@@ -417,7 +417,7 @@ gboolean
 mono_class_needs_cctor_run (MonoClass *klass, MonoMethod *caller);
 
 gpointer
-mono_ldtoken               (MonoImage *image, guint32 token, MonoClass **retclass);
+mono_ldtoken               (MonoImage *image, guint32 token, MonoClass **retclass, MonoGenericContext *context);
 
 char*         
 mono_type_get_name         (MonoType *type);
index 45b62da1a91150ede2751b7b92cad4626bf35a1b..aafd0235a3726851c7ec50a1f2c73c071219e873 100644 (file)
@@ -7736,6 +7736,7 @@ mono_reflection_initialize_generic_parameter (MonoReflectionGenericParam *gparam
        image = (MonoImage*)tb->module->dynamic_image;
 
        param->pklass = mono_class_from_generic_parameter (param, image, mb != NULL);
+       param->pklass->reflection_info = gparam;
 
        gparam->initialized = TRUE;
 }
index cfe5a0edf8e061b63d20650beff135a3aa10919e..9a514c3b4db6b9642f7d472bc902b6895e345919 100644 (file)
@@ -409,7 +409,7 @@ mono_ldtoken_wrapper (MonoImage *image, int token)
        gpointer res;
 
        MONO_ARCH_SAVE_REGS;
-       res = mono_ldtoken (image, token, &handle_class);       
+       res = mono_ldtoken (image, token, &handle_class, NULL); 
        mono_class_init (handle_class);
 
        return res;
index ec0262aec846cbeed261e14a5d63d5e6ba7eb9e1..9a1f4edcece597d813751cc3476f0292ee7aab93 100644 (file)
@@ -4903,7 +4903,7 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
                        CHECK_OPSIZE (5);
                        n = read32 (ip + 1);
 
-                       handle = mono_ldtoken (image, n, &handle_class);
+                       handle = mono_ldtoken (image, n, &handle_class, generic_context);
                        mono_class_init (handle_class);
 
                        if (cfg->opt & MONO_OPT_SHARED) {
@@ -6734,7 +6734,7 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
                MonoClass *handle_class;
 
                handle = mono_ldtoken (patch_info->data.token->image, 
-                                                          patch_info->data.token->token, &handle_class);
+                                      patch_info->data.token->token, &handle_class, NULL);
                mono_class_init (handle_class);
                mono_class_init (mono_class_from_mono_type (handle));
 
@@ -6747,7 +6747,7 @@ mono_resolve_patch_target (MonoMethod *method, MonoDomain *domain, guint8 *code,
                MonoClass *handle_class;
                
                handle = mono_ldtoken (patch_info->data.token->image,
-                                                          patch_info->data.token->token, &handle_class);
+                                      patch_info->data.token->token, &handle_class, NULL);
                mono_class_init (handle_class);
                
                target = handle;