* @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);
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 */
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);
}
/**
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);
}
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);
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;
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;
}
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;
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;
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) {
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));
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;