Skip to content

Commit

Permalink
[runtime] Mark mono_exception_from_token_two_strings external only
Browse files Browse the repository at this point in the history
Runtime should use mono_exception_from_token_two_strings_checked
  • Loading branch information
lambdageek committed Jun 2, 2016
1 parent aa0c3ca commit 1a3d55d
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 8 deletions.
5 changes: 5 additions & 0 deletions mono/metadata/exception-internals.h
Expand Up @@ -20,4 +20,9 @@ mono_exception_from_name_two_strings_checked (MonoImage *image, const char *name
const char *name, MonoString *a1, MonoString *a2,
MonoError *error);

MonoException *
mono_exception_from_token_two_strings_checked (MonoImage *image, uint32_t token,
MonoString *a1, MonoString *a2,
MonoError *error);

#endif
27 changes: 21 additions & 6 deletions mono/metadata/exception.c
Expand Up @@ -245,16 +245,31 @@ mono_exception_from_token_two_strings (MonoImage *image, guint32 token,
MonoString *a1, MonoString *a2)
{
MonoError error;
MonoClass *klass;
MonoException *ret;
ret = mono_exception_from_token_two_strings_checked (image, token, a1, a2, &error);
mono_error_cleanup (&error);
return ret;
}

klass = mono_class_get_checked (image, token, &error);
mono_error_assert_ok (&error); /* FIXME handle the error. */
/**
* mono_exception_from_token_two_strings_checked:
*
* Same as mono_exception_from_name_two_strings, but lookup the exception class using
* IMAGE and TOKEN.
*/
MonoException *
mono_exception_from_token_two_strings_checked (MonoImage *image, guint32 token,
MonoString *a1, MonoString *a2,
MonoError *error)
{
MonoClass *klass;

ret = create_exception_two_strings (klass, a1, a2, &error);
mono_error_raise_exception (&error); /* FIXME don't raise here */
mono_error_init (error);

return ret;
klass = mono_class_get_checked (image, token, error);
mono_error_assert_ok (error); /* FIXME handle the error. */

return create_exception_two_strings (klass, a1, a2, error);
}

/**
Expand Down
1 change: 1 addition & 0 deletions mono/metadata/exception.h
Expand Up @@ -23,6 +23,7 @@ MONO_API MonoException *
mono_exception_from_name_msg (MonoImage *image, const char *name_space,
const char *name, const char *msg);

MONO_RT_EXTERNAL_ONLY
MONO_API MonoException *
mono_exception_from_token_two_strings (MonoImage *image, uint32_t token,
MonoString *a1, MonoString *a2);
Expand Down
13 changes: 11 additions & 2 deletions mono/mini/jit-icalls.c
Expand Up @@ -19,6 +19,7 @@

#include "jit-icalls.h"
#include <mono/utils/mono-error-internals.h>
#include <mono/metadata/exception-internals.h>
#include <mono/metadata/threads-types.h>
#include <mono/metadata/reflection-internals.h>

Expand Down Expand Up @@ -1189,13 +1190,21 @@ mono_create_corlib_exception_0 (guint32 token)
MonoException *
mono_create_corlib_exception_1 (guint32 token, MonoString *arg)
{
return mono_exception_from_token_two_strings (mono_defaults.corlib, token, arg, NULL);
MonoError error;
MonoException *ret = mono_exception_from_token_two_strings_checked (
mono_defaults.corlib, token, arg, NULL, &error);
mono_error_set_pending_exception (&error);
return ret;
}

MonoException *
mono_create_corlib_exception_2 (guint32 token, MonoString *arg1, MonoString *arg2)
{
return mono_exception_from_token_two_strings (mono_defaults.corlib, token, arg1, arg2);
MonoError error;
MonoException *ret = mono_exception_from_token_two_strings_checked (
mono_defaults.corlib, token, arg1, arg2, &error);
mono_error_set_pending_exception (&error);
return ret;
}

MonoObject*
Expand Down

0 comments on commit 1a3d55d

Please sign in to comment.