Author: zoltan
Date: 2005-03-23 11:06:42 -0500 (Wed, 23 Mar 2005)
New Revision: 42150
Modified:
trunk/mono/mono/metadata/ChangeLog
trunk/mono/mono/metadata/class-internals.h
trunk/mono/mono/metadata/class.c
trunk/mono/mono/metadata/object-internals.h
trunk/mono/mono/metadata/reflection.c
Log:
2005-03-23 Zoltan Varga <[EMAIL PROTECTED]>
* class-internals.h object-internals.h class.c reflection.c: Extend the
mono_lookup_dynamic_token () function to return the class of the
token as well.
* class.c (mono_ldtoken): Handle MEMBERREFS in the dynamic case as
well. Fixes #73848.
Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog 2005-03-23 15:59:33 UTC (rev 42149)
+++ trunk/mono/mono/metadata/ChangeLog 2005-03-23 16:06:42 UTC (rev 42150)
@@ -1,3 +1,12 @@
+2005-03-23 Zoltan Varga <[EMAIL PROTECTED]>
+
+ * class-internals.h object-internals.h class.c reflection.c: Extend the
+ mono_lookup_dynamic_token () function to return the class of the
+ token as well.
+
+ * class.c (mono_ldtoken): Handle MEMBERREFS in the dynamic case as
+ well. Fixes #73848.
+
2005-03-23 Sebastien Pouliot <[EMAIL PROTECTED]>
* security-manager.c: Skip inheritance checks for intra-corlib
Modified: trunk/mono/mono/metadata/class-internals.h
===================================================================
--- trunk/mono/mono/metadata/class-internals.h 2005-03-23 15:59:33 UTC (rev
42149)
+++ trunk/mono/mono/metadata/class-internals.h 2005-03-23 16:06:42 UTC (rev
42150)
@@ -448,7 +448,7 @@
typedef gpointer (*MonoTrampoline) (MonoMethod *method);
typedef gpointer (*MonoRemotingTrampoline) (MonoMethod *method,
MonoRemotingTarget target);
-typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token);
+typedef gpointer (*MonoLookupDynamicToken) (MonoImage *image, guint32 token,
MonoClass **handle_class);
typedef gboolean (*MonoGetCachedClassInfo) (MonoClass *klass,
MonoCachedClassInfo *res);
@@ -503,6 +503,9 @@
gpointer
mono_lookup_dynamic_token (MonoImage *image, guint32 token);
+gpointer
+mono_lookup_dynamic_token_class (MonoImage *image, guint32 token, MonoClass
**handle_class);
+
void
mono_install_lookup_dynamic_token (MonoLookupDynamicToken func);
Modified: trunk/mono/mono/metadata/class.c
===================================================================
--- trunk/mono/mono/metadata/class.c 2005-03-23 15:59:33 UTC (rev 42149)
+++ trunk/mono/mono/metadata/class.c 2005-03-23 16:06:42 UTC (rev 42150)
@@ -3496,26 +3496,17 @@
MonoGenericContext *context)
{
if (image->dynamic) {
- gpointer obj = mono_lookup_dynamic_token (image, token);
+ MonoClass *tmp_handle_class;
+ gpointer obj = mono_lookup_dynamic_token_class (image, token,
&tmp_handle_class);
- switch (token & 0xff000000) {
- case MONO_TOKEN_TYPE_DEF:
- case MONO_TOKEN_TYPE_REF:
- case MONO_TOKEN_TYPE_SPEC:
- if (handle_class)
- *handle_class = mono_defaults.typehandle_class;
+ g_assert (tmp_handle_class);
+ if (handle_class)
+ *handle_class = tmp_handle_class;
+
+ if (tmp_handle_class == mono_defaults.typehandle_class)
return &((MonoClass*)obj)->byval_arg;
- case MONO_TOKEN_METHOD_DEF:
- if (handle_class)
- *handle_class =
mono_defaults.methodhandle_class;
+ else
return obj;
- case MONO_TOKEN_FIELD_DEF:
- if (handle_class)
- *handle_class = mono_defaults.fieldhandle_class;
- return obj;
- default:
- g_assert_not_reached ();
- }
}
switch (token & 0xff000000) {
@@ -3596,9 +3587,17 @@
gpointer
mono_lookup_dynamic_token (MonoImage *image, guint32 token)
{
- return lookup_dynamic (image, token);
+ MonoClass *handle_class;
+
+ return lookup_dynamic (image, token, &handle_class);
}
+gpointer
+mono_lookup_dynamic_token_class (MonoImage *image, guint32 token, MonoClass
**handle_class)
+{
+ return lookup_dynamic (image, token, handle_class);
+}
+
static MonoGetCachedClassInfo get_cached_class_info = NULL;
void
Modified: trunk/mono/mono/metadata/object-internals.h
===================================================================
--- trunk/mono/mono/metadata/object-internals.h 2005-03-23 15:59:33 UTC (rev
42149)
+++ trunk/mono/mono/metadata/object-internals.h 2005-03-23 16:06:42 UTC (rev
42150)
@@ -1020,7 +1020,7 @@
MonoReflectionMarshal* mono_reflection_marshal_from_marshal_spec (MonoDomain
*domain, MonoClass *klass, MonoMarshalSpec *spec);
gpointer
-mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token);
+mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token,
MonoClass **handle_class);
gboolean
mono_reflection_call_is_assignable_from (MonoClass *klass, MonoClass *oklass);
Modified: trunk/mono/mono/metadata/reflection.c
===================================================================
--- trunk/mono/mono/metadata/reflection.c 2005-03-23 15:59:33 UTC (rev
42149)
+++ trunk/mono/mono/metadata/reflection.c 2005-03-23 16:06:42 UTC (rev
42150)
@@ -134,7 +134,7 @@
static guint32 encode_constant (MonoDynamicImage *assembly, MonoObject *val,
guint32 *ret_type);
static char* type_get_qualified_name (MonoType *type, MonoAssembly *ass);
static void ensure_runtime_vtable (MonoClass *klass);
-static gpointer resolve_object (MonoImage *image, MonoObject *obj);
+static gpointer resolve_object (MonoImage *image, MonoObject *obj, MonoClass
**handle_class);
static void encode_type (MonoDynamicImage *assembly, MonoType *type, char
*p, char **endbuf);
static guint32 type_get_signature_size (MonoType *type);
static void get_default_param_value_blobs (MonoMethod *method, char **blobs);
@@ -8872,8 +8872,9 @@
rmb.nrefs = mb->nrefs;
rmb.refs = g_new0 (gpointer, mb->nrefs + 1);
for (i = 0; i < mb->nrefs; ++i) {
+ MonoClass *handle_class;
gpointer ref = resolve_object (mb->module->image,
- mono_array_get (mb->refs,
MonoObject*, i));
+ mono_array_get (mb->refs,
MonoObject*, i), &handle_class);
if (!ref) {
g_free (rmb.refs);
mono_raise_exception (mono_get_exception_type_load
(NULL));
@@ -8895,10 +8896,11 @@
* mono_reflection_lookup_dynamic_token:
*
* Finish the Builder object pointed to by TOKEN and return the corresponding
- * runtime structure.
+ * runtime structure. HANDLE_CLASS is set to the class required by
+ * mono_ldtoken.
*/
gpointer
-mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token)
+mono_reflection_lookup_dynamic_token (MonoImage *image, guint32 token,
MonoClass **handle_class)
{
MonoDynamicImage *assembly = (MonoDynamicImage*)image;
MonoObject *obj;
@@ -8906,26 +8908,30 @@
obj = mono_g_hash_table_lookup (assembly->tokens, GUINT_TO_POINTER
(token));
g_assert (obj);
- return resolve_object (image, obj);
+ return resolve_object (image, obj, handle_class);
}
static gpointer
-resolve_object (MonoImage *image, MonoObject *obj)
+resolve_object (MonoImage *image, MonoObject *obj, MonoClass **handle_class)
{
gpointer result = NULL;
if (strcmp (obj->vtable->klass->name, "String") == 0) {
result = mono_string_intern ((MonoString*)obj);
+ *handle_class = NULL;
g_assert (result);
} else if (strcmp (obj->vtable->klass->name, "MonoType") == 0) {
MonoReflectionType *tb = (MonoReflectionType*)obj;
result = mono_class_from_mono_type (tb->type);
+ *handle_class = mono_defaults.typehandle_class;
g_assert (result);
} else if (strcmp (obj->vtable->klass->name, "MonoMethod") == 0) {
result = ((MonoReflectionMethod*)obj)->method;
+ *handle_class = mono_defaults.methodhandle_class;
g_assert (result);
} else if (strcmp (obj->vtable->klass->name, "MonoCMethod") == 0) {
result = ((MonoReflectionMethod*)obj)->method;
+ *handle_class = mono_defaults.methodhandle_class;
g_assert (result);
} else if (strcmp (obj->vtable->klass->name, "MethodBuilder") == 0) {
MonoReflectionMethodBuilder *mb =
(MonoReflectionMethodBuilder*)obj;
@@ -8946,6 +8952,7 @@
*/
result = mb->mhandle;
}
+ *handle_class = mono_defaults.methodhandle_class;
} else if (strcmp (obj->vtable->klass->name, "ConstructorBuilder") ==
0) {
MonoReflectionCtorBuilder *cb = (MonoReflectionCtorBuilder*)obj;
@@ -8956,8 +8963,10 @@
mono_domain_try_type_resolve (mono_domain_get (), NULL,
(MonoObject*)tb);
result = cb->mhandle;
}
+ *handle_class = mono_defaults.methodhandle_class;
} else if (strcmp (obj->vtable->klass->name, "MonoField") == 0) {
result = ((MonoReflectionField*)obj)->field;
+ *handle_class = mono_defaults.fieldhandle_class;
g_assert (result);
} else if (strcmp (obj->vtable->klass->name, "FieldBuilder") == 0) {
MonoReflectionFieldBuilder *fb =
(MonoReflectionFieldBuilder*)obj;
@@ -8969,6 +8978,7 @@
mono_domain_try_type_resolve (mono_domain_get (), NULL,
(MonoObject*)tb);
result = fb->handle;
}
+ *handle_class = mono_defaults.fieldhandle_class;
} else if (strcmp (obj->vtable->klass->name, "TypeBuilder") == 0) {
MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder*)obj;
MonoClass *klass;
@@ -8983,6 +8993,7 @@
result = tb->type.type->data.klass;
g_assert (result);
}
+ *handle_class = mono_defaults.typehandle_class;
} else if (strcmp (obj->vtable->klass->name, "SignatureHelper") == 0) {
MonoReflectionSigHelper *helper = (MonoReflectionSigHelper*)obj;
MonoMethodSignature *sig;
@@ -9014,6 +9025,7 @@
}
result = sig;
+ *handle_class = NULL;
} else {
g_print (obj->vtable->klass->name);
g_assert_not_reached ();
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches