}
static MonoArray*
-mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **exceptions, MonoBoolean exportedOnly)
+mono_module_get_types (MonoDomain *domain, MonoImage *image, MonoArray **exceptions, MonoBoolean exportedOnly, MonoError *error)
{
- MonoError error;
MonoReflectionType *rt;
MonoArray *res;
MonoClass *klass;
MonoTableInfo *tdef = &image->tables [MONO_TABLE_TYPEDEF];
int i, count;
+ mono_error_init (error);
+
/* we start the count from 1 because we skip the special type <Module> */
if (exportedOnly) {
count = 0;
count = 0;
for (i = 1; i < tdef->rows; ++i) {
if (!exportedOnly || mono_module_type_is_visible (tdef, image, i + 1)) {
- klass = mono_class_get_checked (image, (i + 1) | MONO_TOKEN_TYPE_DEF, &error);
+ klass = mono_class_get_checked (image, (i + 1) | MONO_TOKEN_TYPE_DEF, error);
mono_loader_assert_no_error (); /* Plug any leaks */
- g_assert (mono_error_ok (&error));
+ mono_error_assert_ok (error);
if (klass) {
- rt = mono_type_get_object_checked (domain, &klass->byval_arg, &error);
- mono_error_raise_exception (&error); /* FIXME don't raise here */
+ rt = mono_type_get_object_checked (domain, &klass->byval_arg, error);
+ return_val_if_nok (error, NULL);
mono_array_setref (res, count, rt);
} else {
- MonoException *ex = mono_error_convert_to_exception (&error);
+ MonoException *ex = mono_error_convert_to_exception (error);
mono_array_setref (*exceptions, count, ex);
}
count++;
ICALL_EXPORT MonoArray*
ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly)
{
+ MonoError error;
MonoArray *res = NULL;
MonoArray *exceptions = NULL;
MonoImage *image = NULL;
g_assert (!assembly_is_dynamic (assembly->assembly));
image = assembly->assembly->image;
table = &image->tables [MONO_TABLE_FILE];
- res = mono_module_get_types (domain, image, &exceptions, exportedOnly);
+ res = mono_module_get_types (domain, image, &exceptions, exportedOnly, &error);
+ mono_error_raise_exception (&error);
/* Append data from all modules in the assembly */
for (i = 0; i < table->rows; ++i) {
MonoImage *loaded_image = mono_assembly_load_module (image->assembly, i + 1);
if (loaded_image) {
MonoArray *ex2;
- MonoArray *res2 = mono_module_get_types (domain, loaded_image, &ex2, exportedOnly);
+ MonoArray *res2;
+
+ res2 = mono_module_get_types (domain, loaded_image, &ex2, exportedOnly, &error);
+ mono_error_raise_exception (&error);
+
/* Append the new types to the end of the array */
if (mono_array_length (res2) > 0) {
guint32 len1, len2;
ICALL_EXPORT MonoArray*
ves_icall_System_Reflection_Module_InternalGetTypes (MonoReflectionModule *module)
{
+ MonoError error;
MonoArray *exceptions;
int i;
if (!module->image)
return mono_array_new (mono_object_domain (module), mono_defaults.monotype_class, 0);
else {
- MonoArray *res = mono_module_get_types (mono_object_domain (module), module->image, &exceptions, FALSE);
+ MonoArray *res;
+
+ res = mono_module_get_types (mono_object_domain (module), module->image, &exceptions, FALSE, &error);
+ mono_error_raise_exception (&error);
+
for (i = 0; i < mono_array_length (exceptions); ++i) {
MonoException *ex = mono_array_get (exceptions, MonoException *, i);
if (ex) {