Author: raja
Date: 2006-01-20 06:56:17 -0500 (Fri, 20 Jan 2006)
New Revision: 55829

Modified:
   trunk/mono/mono/dis/ChangeLog
   trunk/mono/mono/dis/main.c
   trunk/mono/mono/metadata/ChangeLog
   trunk/mono/mono/metadata/class.c
Log:
* dis/main.c (monodis_assembly_load_hook): New.
(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.


Modified: trunk/mono/mono/dis/ChangeLog
===================================================================
--- trunk/mono/mono/dis/ChangeLog       2006-01-20 10:22:57 UTC (rev 55828)
+++ trunk/mono/mono/dis/ChangeLog       2006-01-20 11:56:17 UTC (rev 55829)
@@ -1,3 +1,9 @@
+2006-01-20  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * 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  <[EMAIL PROTECTED]>
 
        * main.c (dis_type): Dump custom attributes for a type before doing the 
same

Modified: trunk/mono/mono/dis/main.c
===================================================================
--- trunk/mono/mono/dis/main.c  2006-01-20 10:22:57 UTC (rev 55828)
+++ trunk/mono/mono/dis/main.c  2006-01-20 11:56:17 UTC (rev 55829)
@@ -1745,8 +1745,28 @@
        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)
 {
        GString *args = g_string_new ("[--output=filename] [--filter=filename] 
[--help] [--mscorlib]\n");
@@ -1819,6 +1839,9 @@
        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.
         */

Modified: trunk/mono/mono/metadata/ChangeLog
===================================================================
--- trunk/mono/mono/metadata/ChangeLog  2006-01-20 10:22:57 UTC (rev 55828)
+++ trunk/mono/mono/metadata/ChangeLog  2006-01-20 11:56:17 UTC (rev 55829)
@@ -1,3 +1,8 @@
+2006-01-20  Raja R Harinath  <[EMAIL PROTECTED]>
+
+       * class.c (mono_class_from_typeref): Add a sanity test to help
+       catch lack of assembly load/search hooks.
+
 2006-01-19  Zoltan Varga  <[EMAIL PROTECTED]>
 
        * marshal.c (emit_struct_conv): Relax the fields with same offset

Modified: trunk/mono/mono/metadata/class.c
===================================================================
--- trunk/mono/mono/metadata/class.c    2006-01-20 10:22:57 UTC (rev 55828)
+++ trunk/mono/mono/metadata/class.c    2006-01-20 11:56:17 UTC (rev 55829)
@@ -104,14 +104,15 @@
        }
 
        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*

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to