Revert until Martin is online to debug
[mono.git] / mono / metadata / icall.c
index 1ff52e2a9923682564d4a1c0e66e17b7428ae7d2..ad2580f55928b83d43635f35d23a995c553dabe6 100644 (file)
@@ -92,6 +92,29 @@ mono_double_ParseImpl (char *ptr, double *result)
        return TRUE;
 }
 
+static MonoClass *
+mono_class_get_throw (MonoImage *image, guint32 type_token)
+{
+       MonoClass *class = mono_class_get (image, type_token);
+       MonoLoaderError *error;
+       MonoException *ex;
+       
+       if (class != NULL){
+               if (class->exception_type) {
+                       MonoException *exc = mono_class_get_exception_for_failure (class);
+                       g_assert (exc);
+                       mono_raise_exception (exc);
+               }
+               return class;
+       }
+       error = mono_loader_get_last_error ();
+       g_assert (error != NULL);
+       
+       ex = mono_loader_error_prepare_exception (error);
+       mono_raise_exception (ex);
+       return NULL;
+}
+
 static void
 ves_icall_System_Double_AssertEndianity (double *value)
 {
@@ -4482,8 +4505,7 @@ ves_icall_System_Reflection_Assembly_LoadPermissions (MonoReflectionAssembly *as
 }
 
 static MonoArray*
-mono_module_get_types (MonoDomain *domain, MonoImage *image, 
-                                          MonoBoolean exportedOnly)
+mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoBoolean exportedOnly)
 {
        MonoArray *res;
        MonoClass *klass;
@@ -4509,7 +4531,9 @@ mono_module_get_types (MonoDomain *domain, MonoImage *image,
                attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
                visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
                if (!exportedOnly || (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)) {
-                       klass = mono_class_get (image, (i + 1) | MONO_TOKEN_TYPE_DEF);
+                       klass = mono_class_get_throw (image, (i + 1) | MONO_TOKEN_TYPE_DEF);
+                       if (mono_loader_get_last_error ())
+                               mono_loader_clear_error ();
                        mono_array_setref (res, count, mono_type_get_object (domain, &klass->byval_arg));
                        count++;
                }
@@ -4525,7 +4549,8 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
        MonoImage *image = NULL;
        MonoTableInfo *table = NULL;
        MonoDomain *domain;
-       int i;
+       GList *list = NULL;
+       int i, len;
 
        MONO_ARCH_SAVE_REGS;
 
@@ -4610,42 +4635,41 @@ ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly,
                }
        }
 
-       if (mono_is_security_manager_active ()) {
-               /* the ReflectionTypeLoadException must have all the types (Types property), 
-                * NULL replacing types which throws an exception. The LoaderException must
-                * contains all exceptions for NULL items.
-                */
+       /* the ReflectionTypeLoadException must have all the types (Types property), 
+        * NULL replacing types which throws an exception. The LoaderException must
+        * contain all exceptions for NULL items.
+        */
 
-               guint32 len = mono_array_length (res);
-               GList *list = NULL;
-
-               for (i = 0; i < len; i++) {
-                       MonoReflectionType *t = mono_array_get (res, gpointer, i);
-                       MonoClass *klass = mono_type_get_class (t->type);
-                       if ((klass != NULL) && klass->exception_type) {
-                               /* keep the class in the list */
-                               list = g_list_append (list, klass);
-                               /* and replace Type with NULL */
-                               mono_array_setref (res, i, NULL);
-                       }
+       len = mono_array_length (res);
+
+       for (i = 0; i < len; i++) {
+               MonoReflectionType *t = mono_array_get (res, gpointer, i);
+               MonoClass *klass = mono_type_get_class (t->type);
+               if ((klass != NULL) && klass->exception_type) {
+                       /* keep the class in the list */
+                       list = g_list_append (list, klass);
+                       /* and replace Type with NULL */
+                       mono_array_setref (res, i, NULL);
                }
+       }
 
-               if (list) {
-                       GList *tmp = NULL;
-                       MonoException *exc = NULL;
-                       int length = g_list_length (list);
+       if (list) {
+               GList *tmp = NULL;
+               MonoException *exc = NULL;
+               int length = g_list_length (list);
 
-                       MonoArray *exl = mono_array_new (domain, mono_defaults.exception_class, length);
-                       for (i = 0, tmp = list; i < length; i++, tmp = tmp->next) {
-                               MonoException *exc = mono_class_get_exception_for_failure (tmp->data);
-                               mono_array_setref (exl, i, exc);
-                       }
-                       g_list_free (list);
-                       list = NULL;
+               mono_loader_clear_error ();
 
-                       exc = mono_get_exception_reflection_type_load (res, exl);
-                       mono_raise_exception (exc);
+               MonoArray *exl = mono_array_new (domain, mono_defaults.exception_class, length);
+               for (i = 0, tmp = list; i < length; i++, tmp = tmp->next) {
+                       MonoException *exc = mono_class_get_exception_for_failure (tmp->data);
+                       mono_array_setref (exl, i, exc);
                }
+               g_list_free (list);
+               list = NULL;
+
+               exc = mono_get_exception_reflection_type_load (res, exl);
+               mono_raise_exception (exc);
        }
                
        return res;
@@ -6957,6 +6981,7 @@ static const IcallEntry marshal_icalls [] = {
        {"FreeBSTR", ves_icall_System_Runtime_InteropServices_Marshal_FreeBSTR},
        {"FreeCoTaskMem", ves_icall_System_Runtime_InteropServices_Marshal_FreeCoTaskMem},
        {"FreeHGlobal", ves_icall_System_Runtime_InteropServices_Marshal_FreeHGlobal},
+       {"GetComSlotForMethodInfoInternal", ves_icall_System_Runtime_InteropServices_Marshal_GetComSlotForMethodInfoInternal},
        {"GetDelegateForFunctionPointerInternal", ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal},
        {"GetFunctionPointerForDelegateInternal", mono_delegate_to_ftnptr},
        {"GetLastWin32Error", ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error},