Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--mono/metadata/ChangeLog9
-rw-r--r--mono/metadata/class-internals.h8
-rw-r--r--mono/metadata/metadata-internals.h5
-rw-r--r--mono/metadata/metadata.c121
4 files changed, 21 insertions, 122 deletions
diff --git a/mono/metadata/ChangeLog b/mono/metadata/ChangeLog
index bb1bdc00499..05c560bc223 100644
--- a/mono/metadata/ChangeLog
+++ b/mono/metadata/ChangeLog
@@ -1,3 +1,12 @@
+2006-02-19 Raja R Harinath <harinath@gmail.com>
+
+ * metadata.c (mono_type_create_from_typespec): Rename from
+ mono_type_create_from_typespec_full. Remove MonoGenericContainer*
+ argument and caching of types in the generic container.
+ (unwrap_arrays, find_generic_param): Remove.
+ * metadata-internals.h: Update.
+ * class-internals.h (_MonoGenericContainer): Remove 'types' field.
+
2006-02-18 Zoltan Varga <vargaz@gmail.com>
* class.c (mono_class_get_exception_for_failure): Fix a warning.
diff --git a/mono/metadata/class-internals.h b/mono/metadata/class-internals.h
index 51bf71e41a4..de9be455653 100644
--- a/mono/metadata/class-internals.h
+++ b/mono/metadata/class-internals.h
@@ -439,7 +439,7 @@ struct _MonoGenericMethod {
*/
struct _MonoGenericContext {
/*
- * The current container:
+ * The container which has been instantiated.
*
* If we're in a generic method, the generic method definition's container.
* Otherwise the generic type's container.
@@ -458,7 +458,8 @@ struct _MonoGenericContext {
*/
struct _MonoGenericContainer {
MonoGenericContext context;
- /* If we're a generic method definition, the containing class'es context. */
+ /* If we're a generic method definition in a generic type definition,
+ the generic container of the containing class. */
MonoGenericContainer *parent;
/* If we're a generic method definition, caches all their instantiations. */
GHashTable *method_hash;
@@ -466,11 +467,10 @@ struct _MonoGenericContainer {
MonoClass *klass;
int type_argc : 6;
/* If true, we're a generic method, otherwise a generic type definition. */
+ /* Invariant: parent != NULL => is_method */
int is_method : 1;
/* Our type parameters. */
MonoGenericParam *type_params;
- /* Cache for MonoTypes */
- MonoType **types;
};
/*
diff --git a/mono/metadata/metadata-internals.h b/mono/metadata/metadata-internals.h
index 32c24a0dd06..82ed773f554 100644
--- a/mono/metadata/metadata-internals.h
+++ b/mono/metadata/metadata-internals.h
@@ -283,11 +283,6 @@ mono_metadata_parse_type_full (MonoImage *image,
const char *ptr,
const char **rptr);
-MonoType *
-mono_type_create_from_typespec_full (MonoImage *image,
- MonoGenericContainer *container,
- guint32 type_spec);
-
MonoMethodSignature *
mono_metadata_parse_signature_full (MonoImage *image,
MonoGenericContainer *generic_container,
diff --git a/mono/metadata/metadata.c b/mono/metadata/metadata.c
index d065b382ad7..d908256b6d6 100644
--- a/mono/metadata/metadata.c
+++ b/mono/metadata/metadata.c
@@ -9,7 +9,7 @@
*/
#include <config.h>
-#include <stdio.h>
+#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
@@ -3686,62 +3686,6 @@ mono_metadata_implmap_from_method (MonoImage *meta, guint32 method_idx)
}
/**
- * @ptr: MonoType to unwrap
- *
- * Recurses in array/szarray to get the element type.
- * Returns the element MonoType or the @ptr itself if its not an array/szarray.
- */
-static MonoType*
-unwrap_arrays (MonoType *ptr)
-{
- for (;;) {
- if (ptr->type == MONO_TYPE_ARRAY)
- ptr = &ptr->data.array->eklass->byval_arg;
- else if (ptr->type == MONO_TYPE_SZARRAY)
- ptr = &ptr->data.klass->byval_arg;
- else
- return ptr;
- }
-}
-
-/**
- * @inst: MonoGenericClass to search in
- * @prefer_mvar: Whether to try harder to find an MVAR
- *
- * Return some occurance of a generic parameter in this instantiation, if any. Return NULL otherwise.
- * If @prefer_mvar is set, it tries to find if there's an MVAR generic parameter, and returns that
- * in preference to any VAR generic parameter.
- */
-static MonoType *
-find_generic_param (MonoGenericClass *gclass, gboolean prefer_mvar)
-{
- int i = 0, count = gclass->inst->type_argc;
- MonoType **ptr = gclass->inst->type_argv;
- MonoType *fallback = NULL;
-
- g_assert (gclass->inst->is_open);
-
- for (i = 0; i < count; i++) {
- MonoType *ctype = unwrap_arrays (ptr [i]);
-
- if (ctype->type == MONO_TYPE_GENERICINST && ctype->data.generic_class->inst->is_open)
- ctype = find_generic_param (ctype->data.generic_class, prefer_mvar);
-
- if (ctype->type == MONO_TYPE_MVAR)
- return ctype;
-
- if (ctype->type == MONO_TYPE_VAR) {
- if (prefer_mvar)
- fallback = ctype;
- else
- return ctype;
- }
- }
-
- return fallback;
-}
-
-/**
* @image: context where the image is created
* @type_spec: typespec token
*
@@ -3749,99 +3693,50 @@ find_generic_param (MonoGenericClass *gclass, gboolean prefer_mvar)
* token.
*/
MonoType *
-mono_type_create_from_typespec_full (MonoImage *image, MonoGenericContainer *container, guint32 type_spec)
+mono_type_create_from_typespec (MonoImage *image, guint32 type_spec)
{
guint32 idx = mono_metadata_token_index (type_spec);
MonoTableInfo *t;
- guint32 cols [MONO_TYPESPEC_SIZE];
+ guint32 cols [MONO_TYPESPEC_SIZE];
const char *ptr;
guint32 len;
MonoType *type;
- gboolean cache_type = TRUE;
- MonoGenericContainer *gc = container;
mono_loader_lock ();
type = g_hash_table_lookup (image->typespec_cache, GUINT_TO_POINTER (type_spec));
-
- if (type && type->type == MONO_TYPE_GENERICINST && type->data.generic_class->inst->is_open) {
- MonoType *gtype = find_generic_param (type->data.generic_class, gc ? gc->is_method : FALSE);
- gc = select_container (gc, gtype->type);
- if (gtype->data.generic_param->owner != gc)
- type = NULL;
- }
-
- if (type && (type->type == MONO_TYPE_VAR || type->type == MONO_TYPE_MVAR)) {
- gc = select_container (gc, type->type);
- if (gc) {
- /* 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;
-
- /* Either way, some other variant of this generic-parameter is already in the typespec cache. */
- cache_type = FALSE;
- } else if (type->data.generic_param->owner) {
- /*
- * We need a null-owner generic-parameter, but the one in the cache has an owner.
- * Ensure that the null-owner generic-parameter goes into the cache.
- *
- * Together with the 'cache_type = FALSE;' line in the other arm of this condition,
- * this ensures that a null-owner generic-parameter, once created, doesn't need to be re-created.
- * The generic-parameters with owners are cached in their respective owners, and thus don't
- * need to be re-created either.
- */
- type = NULL;
- }
- }
-
if (type) {
mono_loader_unlock ();
return type;
}
t = &image->tables [MONO_TABLE_TYPESPEC];
-
+
mono_metadata_decode_row (t, idx-1, cols, MONO_TYPESPEC_SIZE);
ptr = mono_metadata_blob_heap (image, cols [MONO_TYPESPEC_SIGNATURE]);
len = mono_metadata_decode_value (ptr, &ptr);
type = g_new0 (MonoType, 1);
- if (cache_type)
- g_hash_table_insert (image->typespec_cache, GUINT_TO_POINTER (type_spec), type);
+ g_hash_table_insert (image->typespec_cache, GUINT_TO_POINTER (type_spec), type);
if (*ptr == MONO_TYPE_BYREF) {
- type->byref = 1;
+ type->byref = 1;
ptr++;
}
- if (!do_mono_metadata_parse_type (type, image, container, ptr, &ptr)) {
- if (cache_type)
- g_hash_table_remove (image->typespec_cache, GUINT_TO_POINTER (type_spec));
+ if (!do_mono_metadata_parse_type (type, image, NULL, ptr, &ptr)) {
+ g_hash_table_remove (image->typespec_cache, GUINT_TO_POINTER (type_spec));
g_free (type);
mono_loader_unlock ();
return NULL;
}
- if ((type->type == MONO_TYPE_VAR || type->type == MONO_TYPE_MVAR) && type->data.generic_param->owner) {
- MonoGenericContainer *owner = type->data.generic_param->owner;
-
- if (!owner->types)
- owner->types = g_new0 (MonoType*, owner->type_argc);
-
- owner->types [type->data.generic_param->num] = type;
- }
-
mono_loader_unlock ();
return type;
}
-MonoType *
-mono_type_create_from_typespec (MonoImage *image, guint32 type_spec)
-{
- return mono_type_create_from_typespec_full (image, NULL, type_spec);
-}
-
MonoMarshalSpec *
mono_metadata_parse_marshal_spec (MonoImage *image, const char *ptr)
{