* dis/main.c (monodis_assembly_load_hook): New.
authorRaja R Harinath <harinath@hurrynot.org>
Fri, 20 Jan 2006 11:56:17 +0000 (11:56 -0000)
committerRaja R Harinath <harinath@hurrynot.org>
Fri, 20 Jan 2006 11:56:17 +0000 (11:56 -0000)
(monodis_assembly_search_hook): New.
(main): Install them as hooks into the assembly loading core.
* metadata/class.c (mono_class_from_typeref): Add a sanity test to help
catch lack of assembly load/search hooks.

svn path=/trunk/mono/; revision=55829

mono/dis/ChangeLog
mono/dis/main.c
mono/metadata/ChangeLog
mono/metadata/class.c

index 0e1944b8662f7b8974c07742960e0209095c566d..b92194968478736aa5df060cc7d47966594f6e04 100644 (file)
@@ -1,3 +1,9 @@
+2006-01-20  Raja R Harinath  <rharinath@novell.com>
+
+       * main.c (monodis_assembly_load_hook): New.
+       (monodis_assembly_search_hook): New.
+       (main): Install them as hooks into the assembly loading core.
+
 2006-01-19  Ankit Jain  <jankit@novell.com>
 
        * main.c (dis_type): Dump custom attributes for a type before doing the same
index c17a34b9d7c205e6e90b376e26beb60bd12a7e87..c35aa774e2d8f18233af82d9b8b0b92da8b25c62 100644 (file)
@@ -1745,6 +1745,26 @@ monodis_preload (MonoAssemblyName *aname,
        return result;
 }
 
+static GList *loaded_assemblies = NULL;
+
+static void
+monodis_assembly_load_hook (MonoAssembly *assembly, gpointer user_data)
+{
+       loaded_assemblies = g_list_prepend (loaded_assemblies, assembly);
+}
+
+static MonoAssembly *
+monodis_assembly_search_hook (MonoAssemblyName *aname, gpointer user_data)
+{
+        GList *tmp;
+
+       for (tmp = loaded_assemblies; tmp; tmp = tmp->next) {
+               MonoAssembly *ass = tmp->data;
+               if (mono_assembly_names_equal (aname, &ass->aname))
+                      return ass;
+       }
+       return NULL;
+}
 
 static void
 usage (void)
@@ -1819,6 +1839,9 @@ main (int argc, char *argv [])
        if (input_files == NULL)
                usage ();
 
+       mono_install_assembly_load_hook (monodis_assembly_load_hook, NULL);
+       mono_install_assembly_search_hook (monodis_assembly_search_hook, NULL);
+
        /*
         * If we just have one file, use the corlib version it requires.
         */
index 751d784843f5b8e0a79d019707583c39040d700d..3647d24d34ed9ea0da1fa2dfce33ac47f6e2cd21 100644 (file)
@@ -1,3 +1,8 @@
+2006-01-20  Raja R Harinath  <rharinath@novell.com>
+
+       * class.c (mono_class_from_typeref): Add a sanity test to help
+       catch lack of assembly load/search hooks.
+
 2006-01-19  Zoltan Varga  <vargaz@gmail.com>
 
        * marshal.c (emit_struct_conv): Relax the fields with same offset
index 8da61d87b00f226d1a760517876db388134a150b..48700848bb6ad2118d0e9dd2b68d7a88fc5482cb 100644 (file)
@@ -104,14 +104,15 @@ mono_class_from_typeref (MonoImage *image, guint32 type_token)
        }
 
        references = image->references;
-       if (!references [idx-1])
+       if (!references [idx - 1])
                mono_assembly_load_reference (image, idx - 1);
+       /* If this assert fails, it probably means that you haven't installed an assembly load/search hook */
+       g_assert (references == image->references);
+       g_assert (references [idx - 1]);
        if (references [idx - 1] == (gpointer)-1)
                return NULL;
 
-       image = references [idx-1]->image;
-
-       return mono_class_from_name (image, nspace, name);
+       return mono_class_from_name (references [idx - 1]->image, nspace, name);
 }
 
 static inline MonoType*