+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.
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:
*
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);
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);
}