From bcd05d91aca4e634776106f9f485771f6cc8c07d Mon Sep 17 00:00:00 2001 From: kumpera Date: Wed, 27 Jan 2010 18:31:46 +0000 Subject: [PATCH] 2010-01-28 Rodrigo Kumpera * mono-error-internals.h: Add mono_error_set_not_verifiable. * mono-error.h: Add MONO_ERROR_NOT_VERIFIABLE. * mono-error.c: Implement mono_error_set_not_verifiable. git-svn-id: svn+ssh://mono-cvs.ximian.com/source/trunk/mono@150306 e3ebcda4-bce8-0310-ba0a-eca2169e7518 --- mono/utils/ChangeLog | 8 ++++++++ mono/utils/mono-error-internals.h | 3 +++ mono/utils/mono-error.c | 35 +++++++++++++++++++++++++++++++++++ mono/utils/mono-error.h | 3 ++- 4 files changed, 48 insertions(+), 1 deletion(-) diff --git a/mono/utils/ChangeLog b/mono/utils/ChangeLog index 598162087..8f67c80e0 100644 --- a/mono/utils/ChangeLog +++ b/mono/utils/ChangeLog @@ -1,3 +1,11 @@ +2010-01-28 Rodrigo Kumpera + + * mono-error-internals.h: Add mono_error_set_not_verifiable. + + * mono-error.h: Add MONO_ERROR_NOT_VERIFIABLE. + + * mono-error.c: Implement mono_error_set_not_verifiable. + 2010-01-26 U-anarquia\miguel * mono-dl.c: Removed debugging messages for the embeddable version diff --git a/mono/utils/mono-error-internals.h b/mono/utils/mono-error-internals.h index 10761e0d1..5c09e6474 100644 --- a/mono/utils/mono-error-internals.h +++ b/mono/utils/mono-error-internals.h @@ -57,6 +57,9 @@ void mono_error_set_argument (MonoError *error, const char *argument, const char *msg_format, ...) MONO_INTERNAL; void +mono_error_set_not_verifiable (MonoError *oerror, MonoMethod *method, const char *msg_format, ...) MONO_INTERNAL; + +void mono_error_set_generic_error (MonoError *error, const char * name_space, const char *name, const char *msg_format, ...) MONO_INTERNAL; MonoException* diff --git a/mono/utils/mono-error.c b/mono/utils/mono-error.c index 9ba165b51..ed080b959 100644 --- a/mono/utils/mono-error.c +++ b/mono/utils/mono-error.c @@ -292,6 +292,21 @@ mono_error_set_argument (MonoError *oerror, const char *argument, const char *ms set_error_message (); } +void +mono_error_set_not_verifiable (MonoError *oerror, MonoMethod *method, const char *msg_format, ...) +{ + MonoErrorInternal *error = (MonoErrorInternal*)oerror; + mono_error_prepare (error); + + error->error_code = MONO_ERROR_NOT_VERIFIABLE; + mono_error_set_class (oerror, method->klass); + if (method) + mono_error_set_member_name (oerror, mono_method_full_name (method, 1)); + + set_error_message (); +} + + static MonoString* get_type_name_as_mono_string (MonoErrorInternal *error, MonoDomain *domain, MonoError *error_out) { @@ -437,6 +452,26 @@ mono_error_prepare_exception (MonoError *oerror, MonoError *error_out) exception = mono_get_exception_argument (error->type_name, mono_internal_error_get_message (error)); break; + case MONO_ERROR_NOT_VERIFIABLE: { + char *type_name = NULL, *message; + if (error->klass) { + type_name = mono_type_get_full_name (error->klass); + if (!type_name) { + mono_error_set_out_of_memory (error_out, "Could not allocate message"); + break; + } + } + message = g_strdup_printf ("Error in %s:%s %s", type_name, error->member_name, mono_internal_error_get_message (error)); + if (!message) { + g_free (type_name); + mono_error_set_out_of_memory (error_out, "Could not allocate message"); + break; + } + exception = mono_exception_from_name_msg (mono_defaults.corlib, "System.Security", "VerificationException", message); + g_free (message); + g_free (type_name); + break; + } case MONO_ERROR_GENERIC: if (!error->exception_name_space || !error->exception_name) mono_error_set_generic_error (error_out, "System", "ExecutionEngineException", "MonoError with generic error but no exception name was supplied"); diff --git a/mono/utils/mono-error.h b/mono/utils/mono-error.h index 75e3df272..6f722cff9 100644 --- a/mono/utils/mono-error.h +++ b/mono/utils/mono-error.h @@ -22,11 +22,12 @@ enum { MONO_ERROR_BAD_IMAGE = 5, MONO_ERROR_OUT_OF_MEMORY = 6, MONO_ERROR_ARGUMENT = 7, + MONO_ERROR_NOT_VERIFIABLE = 8, /* * This is a generic error mechanism is you need to raise an arbitrary corlib exception. * You must pass the exception name otherwise prepare_exception will fail with internal execution. */ - MONO_ERROR_GENERIC = 8 + MONO_ERROR_GENERIC = 9 }; /*Keep in sync with MonoErrorInternal*/ -- 2.11.4.GIT