Author: ankit
Date: 2006-06-02 06:46:42 -0400 (Fri, 02 Jun 2006)
New Revision: 61399

Modified:
   branches/mono-1-1-13/mono/mono/dis/ChangeLog
   branches/mono-1-1-13/mono/mono/dis/get.c
   branches/mono-1-1-13/mono/mono/dis/main.c
Log:
* get.c (get_typedef): Return NULL for <Module> type.
(get_escaped_class_name): Likewise.
(dis_stringify_object_with_class): Likewise.

(dis_stringify_type): Return NULL if the type name is NULL.
(get_escaped_name): Don't try to escape a NULL name.

(get_fieldref_signature): Type name can be null.
(get_field): Likewise.
(get_method_core): Likewise.
(get_methoddef): Likewise.

* main.c (dis_method_list): Print correct message for global methods.
(dis_globals): Don't print '<Module>' for global methods/fields.


Modified: branches/mono-1-1-13/mono/mono/dis/ChangeLog
===================================================================
--- branches/mono-1-1-13/mono/mono/dis/ChangeLog        2006-06-02 10:42:32 UTC 
(rev 61398)
+++ branches/mono-1-1-13/mono/mono/dis/ChangeLog        2006-06-02 10:46:42 UTC 
(rev 61399)
@@ -1,3 +1,20 @@
+2006-06-02  Ankit Jain  <[EMAIL PROTECTED]>
+
+       * get.c (get_typedef): Return NULL for <Module> type.
+       (get_escaped_class_name): Likewise.
+       (dis_stringify_object_with_class): Likewise.
+
+       (dis_stringify_type): Return NULL if the type name is NULL.
+       (get_escaped_name): Don't try to escape a NULL name.
+
+       (get_fieldref_signature): Type name can be null.
+       (get_field): Likewise.
+       (get_method_core): Likewise.
+       (get_methoddef): Likewise.
+       
+       * main.c (dis_method_list): Print correct message for global methods.
+       (dis_globals): Don't print '<Module>' for global methods/fields.
+
 2006-06-01  Ankit Jain  <[EMAIL PROTECTED]>
 
        * declsec.c (dump_declsec_entry20): Fix a warning.

Modified: branches/mono-1-1-13/mono/mono/dis/get.c
===================================================================
--- branches/mono-1-1-13/mono/mono/dis/get.c    2006-06-02 10:42:32 UTC (rev 
61398)
+++ branches/mono-1-1-13/mono/mono/dis/get.c    2006-06-02 10:46:42 UTC (rev 
61399)
@@ -45,6 +45,10 @@
        char *tstring, *result;
         guint32 token;
         
+       if (idx == 1)
+               /* <Module> */
+               return NULL;
+
        mono_metadata_decode_row (&m->tables [MONO_TABLE_TYPEDEF], idx - 1, 
cols, MONO_TYPEDEF_SIZE);
 
         ns = mono_metadata_string_heap (m, cols [MONO_TYPEDEF_NAMESPACE]);
@@ -1024,6 +1028,10 @@
 {
        char *result, *esname;
 
+       if (c->type_token == mono_metadata_make_token (MONO_TABLE_TYPEDEF, 1))
+               /* <Module> */
+               return NULL;
+
        if (c->rank || c->byval_arg.type == MONO_TYPE_PTR) 
                g_assert (0);
 
@@ -1051,6 +1059,10 @@
        const char *otype = type->type == MONO_TYPE_VALUETYPE ? "valuetype " : 
"class " ;
        char *assemblyref = NULL, *result, *esname, *generic = NULL;
        
+       if (c->type_token == mono_metadata_make_token (MONO_TABLE_TYPEDEF, 1))
+               /* <Module> */
+               return NULL;
+
        if (m != c->image) {
                if (c->image->assembly_name) {
                        /* we cheat */
@@ -1208,6 +1220,10 @@
 
        if (type->byref)
                byref = "&";
+       
+       if (!bare)
+               /* bare is NULL, for <Module> */
+               return bare;
                
        result = g_strconcat (bare, byref, pinned, mods ? mods : "", NULL);
 
@@ -1498,6 +1514,9 @@
        const char *s;
        char *ret, *esc;
 
+       if (!name)
+               return NULL;
+
        g_assert (key_table);
 
        if (strlen (name) == 0)
@@ -1695,7 +1714,11 @@
        type = get_memberref_parent (m, cols [MONO_MEMBERREF_CLASS], context);
        esname = get_escaped_name (mono_metadata_string_heap (m, cols 
[MONO_MEMBERREF_NAME]));
 
-        full_sig = g_strdup_printf ("%s %s::%s", sig, type, esname);
+       full_sig = g_strdup_printf ("%s %s%s%s", 
+                       sig, 
+                       type ? type : "", 
+                       type ? "::" : "",
+                       esname);
         g_free (sig);
        g_free (type);
        g_free (esname);
@@ -1741,8 +1764,11 @@
        type = get_typedef (m, type_idx);
        estype = get_escaped_name (type);
        esname = get_escaped_name (mono_metadata_string_heap (m, cols 
[MONO_FIELD_NAME]));
-       res = g_strdup_printf ("%s %s::%s",
-                       sig, estype, esname);
+       res = g_strdup_printf ("%s %s%s%s",
+                       sig, 
+                       estype ? estype : "",
+                       estype ? "::" : "",
+                       esname);
 
        g_free (type);
        g_free (sig);
@@ -1837,9 +1863,9 @@
                esname = get_escaped_name (mh->name);
                sig = dis_stringify_type (m, &mh->klass->byval_arg, TRUE);
                if (show_tokens)
-                       name = g_strdup_printf ("%s/*%08x*/::%s", sig, token, 
esname);
+                       name = g_strdup_printf ("%s/*%08x*/%s%s", sig ? sig : 
"", token, sig ? "::" : "", esname);
                else
-                       name = g_strdup_printf ("%s::%s", sig, esname);
+                       name = g_strdup_printf ("%s%s%s", sig ? sig : "", sig ? 
"::" : "", esname);
                g_free (sig);
                g_free (esname);
        } else
@@ -1856,10 +1882,14 @@
        case MONO_TOKEN_MEMBER_REF: {
                mono_metadata_decode_row (&m->tables [MONO_TABLE_MEMBERREF],
                                          idx - 1, member_cols, 
MONO_MEMBERREF_SIZE);
-               if (!name)
-                       name = g_strdup_printf ("%s::%s",
-                                               get_memberref_parent (m, 
member_cols [MONO_MEMBERREF_CLASS], context),
+               if (!name) {
+                       char *parent = get_memberref_parent (m, member_cols 
[MONO_MEMBERREF_CLASS], context),
+                       name = g_strdup_printf ("%s%s%s",
+                                               parent ? parent : "", 
+                                               parent ? "::" : "",
                                                mono_metadata_string_heap (m, 
member_cols [MONO_MEMBERREF_NAME]));
+                       g_free (parent);
+               }
                if (mh) {
                        int arity = 0;
 
@@ -1932,7 +1962,10 @@
        mh = mono_get_method (m, MONO_TOKEN_METHOD_DEF | idx, NULL);
        if (mh) {
                sig = dis_stringify_type (m, &mh->klass->byval_arg, FALSE);
-               name = g_strdup_printf ("%s::%s", sig, mh->name);
+               name = g_strdup_printf ("%s%s%s", 
+                               sig ? sig : "",
+                               sig ? "::" : "",
+                               mh->name);
                g_free (sig);
        } else
                name = NULL;

Modified: branches/mono-1-1-13/mono/mono/dis/main.c
===================================================================
--- branches/mono-1-1-13/mono/mono/dis/main.c   2006-06-02 10:42:32 UTC (rev 
61398)
+++ branches/mono-1-1-13/mono/mono/dis/main.c   2006-06-02 10:46:42 UTC (rev 
61399)
@@ -904,7 +904,10 @@
                        fprintf (output, "          // Disassembly of native 
methods is not supported\n");
                else
                        dis_code (m, token, cols [MONO_METHOD_RVA], 
method_context);
-               fprintf (output, "    } // end of method %s::%s\n\n", 
klass_name, sig_str);
+               if (klass_name)
+                       fprintf (output, "    } // end of method %s::%s\n\n", 
klass_name, sig_str);
+               else
+                       fprintf (output, "    } // end of global method 
%s\n\n", sig_str);
                mono_metadata_free_method_signature (ms);
                g_free (sig_str);
        }
@@ -1278,10 +1281,7 @@
        guint32 cols [MONO_TYPEDEF_SIZE];
        guint32 cols_next [MONO_TYPEDEF_SIZE];
        gboolean next_is_valid, last;
-        gchar *name;
 
-        name = g_strdup ("<Module>");
-
         mono_metadata_decode_row (t, 0, cols, MONO_TYPEDEF_SIZE);
 
        if (t->rows > 1) {
@@ -1310,7 +1310,7 @@
                last = m->tables [MONO_TABLE_METHOD].rows;
        
        if (cols [MONO_TYPEDEF_METHOD_LIST] && cols [MONO_TYPEDEF_METHOD_LIST] 
<= m->tables [MONO_TABLE_METHOD].rows)
-               dis_method_list (name, m, cols [MONO_TYPEDEF_METHOD_LIST] - 1, 
last, NULL);
+               dis_method_list (NULL, m, cols [MONO_TYPEDEF_METHOD_LIST] - 1, 
last, NULL);
 
 }
 

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

Reply via email to