Wed Aug 29 18:37:37 CEST 2007 Paolo Molaro <lupus@ximian.com>
[mono.git] / mono / metadata / debug-helpers.c
index a351c6ad2d4bb32b964d4b207e3d737d1d72bbd3..3a79e24fae8c75e68eb9c70c6461f62ba19708a2 100644 (file)
@@ -298,13 +298,50 @@ mono_method_desc_match (MonoMethodDesc *desc, MonoMethod *method)
        return TRUE;
 }
 
+static const char *
+my_strrchr (const char *str, char ch, int *len)
+{
+       int pos;
+
+       for (pos = (*len)-1; pos >= 0; pos--) {
+               if (str [pos] != ch)
+                       continue;
+
+               *len = pos;
+               return str + pos;
+       }
+
+       return NULL;
+}
+
+static gboolean
+match_class (MonoMethodDesc *desc, int pos, MonoClass *klass)
+{
+       const char *p;
+
+       p = my_strrchr (desc->klass, '/', &pos);
+       if (!p) {
+               if (strncmp (desc->klass, klass->name, pos))
+                       return FALSE;
+               if (desc->namespace && strcmp (desc->namespace, klass->name_space))
+                       return FALSE;
+               return TRUE;
+       }
+
+       if (strcmp (p+1, klass->name))
+               return FALSE;
+       if (!klass->nested_in)
+               return FALSE;
+
+       return match_class (desc, pos, klass->nested_in);
+}
+
 gboolean
 mono_method_desc_full_match (MonoMethodDesc *desc, MonoMethod *method)
 {
-       if (strcmp (desc->klass, method->klass->name))
-               return FALSE;
-       if (desc->namespace && strcmp (desc->namespace, method->klass->name_space))
+       if (!match_class (desc, strlen (desc->klass), method->klass))
                return FALSE;
+
        return mono_method_desc_match (desc, method);
 }
 
@@ -520,6 +557,18 @@ mono_disasm_code (MonoDisHelper *dh, MonoMethod *method, const guchar *ip, const
        return result;
 }
 
+char *
+mono_field_full_name (MonoClassField *field)
+{
+       char *res;
+       const char *nspace = field->parent->name_space;
+
+       res = g_strdup_printf ("%s%s%s:%s", nspace, *nspace ? "." : "",
+                                                  field->parent->name, field->name);
+
+       return res;
+}
+
 char *
 mono_method_full_name (MonoMethod *method, gboolean signature)
 {