[runtime] Introduce mono_get_method_checked.
authorRodrigo Kumpera <kumpera@gmail.com>
Wed, 10 Dec 2014 16:30:48 +0000 (11:30 -0500)
committerRodrigo Kumpera <kumpera@gmail.com>
Tue, 20 Jan 2015 17:50:48 +0000 (12:50 -0500)
mono/metadata/loader.c
mono/metadata/metadata-internals.h

index 29ca1880d1cc9aaa69a98a2792e11490b7b08cec..3a062cfaaf2823b512b110447cda79d1103e765c 100644 (file)
@@ -1904,11 +1904,25 @@ mono_get_method_full (MonoImage *image, guint32 token, MonoClass *klass,
                      MonoGenericContext *context)
 {
        MonoError error;
+       MonoMethod *result = mono_get_method_checked (image, token, klass, context, &error);
+       g_assert (!mono_loader_get_last_error ());
+       if (!mono_error_ok (&error)) {
+               mono_loader_set_error_from_mono_error (&error);
+               mono_error_cleanup (&error);
+       }
+       return result;
+}
+
+MonoMethod *
+mono_get_method_checked (MonoImage *image, guint32 token, MonoClass *klass, MonoGenericContext *context, MonoError *error)
+{
        MonoMethod *result = NULL;
        gboolean used_context = FALSE;
 
        /* We do everything inside the lock to prevent creation races */
 
+       mono_error_init (error);
+
        mono_image_lock (image);
 
        if (mono_metadata_token_table (token) == MONO_TABLE_METHOD) {
@@ -1926,12 +1940,9 @@ mono_get_method_full (MonoImage *image, guint32 token, MonoClass *klass,
                return result;
 
 
-       result = mono_get_method_from_token (image, token, klass, context, &used_context, &error);
-       if (!result) {
-               mono_loader_set_error_from_mono_error (&error);
-               mono_error_cleanup (&error);
+       result = mono_get_method_from_token (image, token, klass, context, &used_context, error);
+       if (!result)
                return NULL;
-       }
 
        mono_image_lock (image);
        if (!used_context && !result->is_inflated) {
index ca7b4077ed926c8909ba632eddaf009ffa413f32..413a942ea7f70192033b792db5dd5f2039b61683 100644 (file)
@@ -808,6 +808,8 @@ mono_type_create_from_typespec_checked (MonoImage *image, guint32 type_spec, Mon
 MonoMethodSignature*
 mono_method_get_signature_checked (MonoMethod *method, MonoImage *image, guint32 token, MonoGenericContext *context, MonoError *error) MONO_INTERNAL;
        
+MonoMethod *
+mono_get_method_checked (MonoImage *image, guint32 token, MonoClass *klass, MonoGenericContext *context, MonoError *error) MONO_INTERNAL;
 
 #endif /* __MONO_METADATA_INTERNALS_H__ */