2008-03-03 Rodrigo Kumpera <rkumpera@novell.com>
authorRodrigo Kumpera <kumpera@gmail.com>
Mon, 3 Mar 2008 19:01:53 +0000 (19:01 -0000)
committerRodrigo Kumpera <kumpera@gmail.com>
Mon, 3 Mar 2008 19:01:53 +0000 (19:01 -0000)
* reflection.c (mono_reflection_is_valid_dynamic_token): New function,
Test if a token is valid, this remove explicit usage of
MonoDynamicImage::tokens from the verifier code.

* reflection.h: Added mono_reflection_is_valid_dynamic_token.

* verify.c (token_bounds_check): Use mono_reflection_is_valid_dynamic_token
instead of direct access to MonoDynamicImage::tokens.

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

mono/metadata/ChangeLog
mono/metadata/reflection.c
mono/metadata/reflection.h
mono/metadata/verify.c

index 23893452fce128772898a6de6720df470585dbb7..c9caa21e310405ad927458b2f88a96b3de6a3faa 100644 (file)
@@ -1,3 +1,14 @@
+2008-03-03 Rodrigo Kumpera  <rkumpera@novell.com>
+
+       * reflection.c (mono_reflection_is_valid_dynamic_token): New function,
+       Test if a token is valid, this remove explicit usage of 
+       MonoDynamicImage::tokens from the verifier code.
+
+       * reflection.h: Added mono_reflection_is_valid_dynamic_token.
+
+       * verify.c (token_bounds_check): Use mono_reflection_is_valid_dynamic_token
+       instead of direct access to MonoDynamicImage::tokens.
+
 2008-03-03 Rodrigo Kumpera  <rkumpera@novell.com>
 
        * verify.c (token_bounds_check): Fix the build I just broke.
index 14b0ab443b6d52f6f0bf0ebfe187f34ac11e9652..853869b6718ad9927e684e5dda91e867b477b53f 100644 (file)
@@ -9737,6 +9737,19 @@ mono_reflection_destroy_dynamic_method (MonoReflectionDynamicMethod *mb)
                        mono_object_get_domain ((MonoObject*)mb), mb->mhandle);
 }
 
+/**
+ * 
+ * mono_reflection_is_valid_dynamic_token:
+ * 
+ * Returns TRUE if token is valid.
+ * 
+ */
+gboolean
+mono_reflection_is_valid_dynamic_token (MonoDynamicImage *image, guint32 token)
+{
+       return mono_g_hash_table_lookup (image->tokens, GUINT_TO_POINTER (token)) != NULL;
+}
+
 /**
  * mono_reflection_lookup_dynamic_token:
  *
index 89b336088e45d437b3e28a9c781e08e9b651b932..5f1bf4aba637a7187a2cf3c9c03fefdb81fa5d9c 100644 (file)
@@ -53,6 +53,7 @@ MonoType*     mono_reflection_get_type   (MonoImage* image, MonoTypeNameParse *i
 void          mono_reflection_free_type_info (MonoTypeNameParse *info);
 MonoType*     mono_reflection_type_from_name (char *name, MonoImage *image);
 guint32       mono_reflection_get_token (MonoObject *obj);
+gboolean      mono_reflection_is_valid_dynamic_token (MonoDynamicImage *image, guint32 token) MONO_INTERNAL;
 
 MonoReflectionAssembly* mono_assembly_get_object (MonoDomain *domain, MonoAssembly *assembly);
 MonoReflectionModule*   mono_module_get_object   (MonoDomain *domain, MonoImage *image);
index 15446f3a2c899a6d1e74b036ed7fe6f1452bca8e..82b02772a013cd6aea3109c5df89a7429297c5af 100644 (file)
@@ -235,10 +235,8 @@ enum {
 static gboolean
 token_bounds_check (MonoImage *image, guint32 token)
 {
-       if (image->dynamic) {
-               MonoDynamicImage *dyn = (MonoDynamicImage*)image; 
-               return mono_g_hash_table_lookup (dyn->tokens, GUINT_TO_POINTER (token)) != NULL;
-       }
+       if (image->dynamic)
+               return mono_reflection_is_valid_dynamic_token ((MonoDynamicImage*)image, token);
        return image->tables [mono_metadata_token_table (token)].rows >= mono_metadata_token_index (token);
 }