Author: raja
Date: 2005-11-28 10:41:18 -0500 (Mon, 28 Nov 2005)
New Revision: 53560
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/class-internals.h
trunk/mono/mono/metadata/loader.c
trunk/mono/mono/metadata/metadata.c
Log:
* class-internals.h (MonoGenericContainer.is_signature): Remove.
* metadata.c (mono_metadata_parse_method_signature_full): Don't
create a temporary signature container.
(mono_metadata_parse_generic_param): Update to changes.
(mono_type_create_from_typespec_full): Update to changes.
* loader.c (method_from_memberref): Don't use a
MonoGenericContainer while parsing a memberref signature.
(method_from_methodspec): Remove dead-store of the 'container'
variable. It's overwritten before use.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2005-11-28 14:48:28 UTC (rev 53559)
+++ trunk/mono/mono/metadata/ChangeLog 2005-11-28 15:41:18 UTC (rev 53560)
@@ -1,5 +1,15 @@
2005-11-28 Raja R Harinath <[EMAIL PROTECTED]>
+ * class-internals.h (MonoGenericContainer.is_signature): Remove.
+ * metadata.c (mono_metadata_parse_method_signature_full): Don't
+ create a temporary signature container.
+ (mono_metadata_parse_generic_param): Update to changes.
+ (mono_type_create_from_typespec_full): Update to changes.
+ * loader.c (method_from_memberref): Don't use a
+ MonoGenericContainer while parsing a memberref signature.
+ (method_from_methodspec): Remove dead-store of the 'container'
+ variable. It's overwritten before use.
+
* metadata.c (mono_type_create_from_typespec_full): Make debugging
checks tighter.
(mono_metadata_parse_generic_param): Likewise.
Modified: trunk/mono/mono/metadata/class-internals.h
===================================================================
--- trunk/mono/mono/metadata/class-internals.h 2005-11-28 14:48:28 UTC (rev
53559)
+++ trunk/mono/mono/metadata/class-internals.h 2005-11-28 15:41:18 UTC (rev
53560)
@@ -464,8 +464,6 @@
int type_argc : 6;
/* If true, we're a generic method, otherwise a generic type
definition. */
int is_method : 1;
- /* If true, we're a temporary container which is used while parsing
signatures. */
- int is_signature : 1;
/* Our type parameters. */
MonoGenericParam *type_params;
/* Cache for MonoTypes */
Modified: trunk/mono/mono/metadata/loader.c
===================================================================
--- trunk/mono/mono/metadata/loader.c 2005-11-28 14:48:28 UTC (rev 53559)
+++ trunk/mono/mono/metadata/loader.c 2005-11-28 15:41:18 UTC (rev 53560)
@@ -477,7 +477,6 @@
guint32 nindex, class;
const char *mname;
MonoMethodSignature *sig;
- MonoGenericContainer *container;
const char *ptr;
mono_metadata_decode_row (&tables [MONO_TABLE_MEMBERREF], idx-1, cols,
3);
@@ -528,30 +527,20 @@
g_assert (klass);
mono_class_init (klass);
- /*
- * Generics: Correctly set the context before parsing the method.
- *
- * For MONO_MEMBERREF_PARENT_TYPEDEF or MONO_MEMBERREF_PARENT_TYPEREF,
our parent
- * is "context-free"; ie. `klass' will always be the same generic
instantation.
- *
- * For MONO_MEMBERREF_PARENT_TYPESPEC, we have to parse the typespec in
the
- * `typespec_context' and thus `klass' may have different generic
instantiations.
- *
- * After parsing the `klass', we have to distinguish two cases:
- * If this class introduces new type parameters (or a new generic
instantiation)
- * we parse the signature in this new context.
- */
- if (klass->generic_class)
- context = klass->generic_class->context;
- else if (klass->generic_container)
- context = (MonoGenericContext *) klass->generic_container;
- container = context ? context->container : NULL;
-
ptr = mono_metadata_blob_heap (image, cols [MONO_MEMBERREF_SIGNATURE]);
mono_metadata_decode_blob_size (ptr, &ptr);
- sig = mono_metadata_parse_method_signature_full (image, container, 0,
ptr, NULL);
- sig = mono_class_inflate_generic_signature (image, sig, context);
+ sig = mono_metadata_parse_method_signature (image, 0, ptr, NULL);
+
+ /* If the class is a generic instantiation, ensure that all VAR
references in the signature
+ are replaced by the corresponding type argument. Note that MVARs
are left alone. */
+ if (klass->generic_class) {
+ MonoMethodSignature *old_sig = sig;
+ sig = mono_class_inflate_generic_signature (image, sig,
klass->generic_class->context);
+ g_assert (sig != old_sig);
+ mono_metadata_free_method_signature (old_sig);
+ }
+
switch (class) {
case MONO_MEMBERREF_PARENT_TYPEREF:
method = find_method (klass, NULL, mname, sig);
@@ -651,17 +640,6 @@
g_assert (param_count);
/*
- * Check whether we're in a generic type or method.
- */
- container = context ? context->container : NULL;
- if (container && (container->is_method || container->is_signature)) {
- /*
- * If we're in a generic method, use the containing class'es
context.
- */
- container = container->parent;
- }
-
- /*
* Be careful with the two contexts here:
*
* ----------------------------------------
Modified: trunk/mono/mono/metadata/metadata.c
===================================================================
--- trunk/mono/mono/metadata/metadata.c 2005-11-28 14:48:28 UTC (rev 53559)
+++ trunk/mono/mono/metadata/metadata.c 2005-11-28 15:41:18 UTC (rev 53560)
@@ -1536,7 +1536,7 @@
* Returns: a MonoMethodSignature describing the signature.
*/
MonoMethodSignature *
-mono_metadata_parse_method_signature_full (MonoImage *m, MonoGenericContainer
*generic_container,
+mono_metadata_parse_method_signature_full (MonoImage *m, MonoGenericContainer
*container,
int def, const char *ptr, const char
**rptr)
{
MonoMethodSignature *method;
@@ -1544,7 +1544,6 @@
guint32 hasthis = 0, explicit_this = 0, call_convention, param_count;
guint32 gen_param_count = 0;
gboolean is_open = FALSE;
- MonoGenericContainer *container;
if (*ptr & 0x10)
gen_param_count = 1;
@@ -1586,25 +1585,6 @@
if (gen_param_count)
method->has_type_parameters = 1;
- if (gen_param_count && (!generic_container ||
!generic_container->is_method)) {
- container = g_new0 (MonoGenericContainer, 1);
-
- container->parent = generic_container;
- container->is_signature = 1;
-
- container->context.container = container;
-
- container->type_argc = gen_param_count;
- container->type_params = g_new0 (MonoGenericParam,
gen_param_count);
-
- for (i = 0; i < gen_param_count; i++) {
- container->type_params [i].owner = container;
- container->type_params [i].num = i;
- }
- } else {
- container = generic_container;
- }
-
if (call_convention != 0xa) {
method->ret = mono_metadata_parse_type_full (m,
(MonoGenericContext *) container, MONO_PARSE_RET, ret_attrs, ptr, &ptr);
is_open = mono_class_is_open_constructed_type (method->ret);
@@ -1901,8 +1881,8 @@
generic_container = generic_container->parent;
/* Ensure that we have the correct type of GenericContainer */
- g_assert (is_mvar || !(generic_container->is_method ||
generic_container->is_signature));
- g_assert (!is_mvar || (generic_container->is_method ||
generic_container->is_signature));
+ g_assert (is_mvar || !generic_container->is_method);
+ g_assert (!is_mvar || generic_container->is_method);
g_assert (index < generic_container->type_argc);
return &generic_container->type_params [index];
@@ -3716,8 +3696,8 @@
if (type->type == MONO_TYPE_VAR && gc->parent)
gc = gc->parent;
- g_assert (type->type != MONO_TYPE_MVAR ||
(gc->is_method || gc->is_signature));
- g_assert (type->type != MONO_TYPE_VAR ||
!(gc->is_method || gc->is_signature));
+ g_assert (type->type != MONO_TYPE_MVAR ||
gc->is_method);
+ g_assert (type->type != MONO_TYPE_VAR ||
!gc->is_method);
/* Use the one already cached in the container, if it
exists. Otherwise, ensure that it's created */
type = gc->types ? gc->types
[type->data.generic_param->num] : NULL;
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches