2008-08-20 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Wed, 20 Aug 2008 00:35:34 +0000 (00:35 -0000)
committerZoltan Varga <vargaz@gmail.com>
Wed, 20 Aug 2008 00:35:34 +0000 (00:35 -0000)
* debug-helpers.c (mono_context_get_desc): New helper function to stringify
a generic context.
(mono_type_get_desc): Add the type arguments for GENERICINST.
(mono_method_full_name): Stringify the class name using mono_type_full_name
so it picks up generic arguments.

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

mono/metadata/ChangeLog
mono/metadata/debug-helpers.c
mono/metadata/debug-helpers.h

index 6b03e67b71d63c880061fdd95e4b22beaa522e95..4f2abcf6d9df8d05a2783bda9bf0109b35af2f7b 100644 (file)
@@ -1,3 +1,11 @@
+2008-08-20  Zoltan Varga  <vargaz@gmail.com>
+
+       * debug-helpers.c (mono_context_get_desc): New helper function to stringify
+       a generic context.
+       (mono_type_get_desc): Add the type arguments for GENERICINST.
+       (mono_method_full_name): Stringify the class name using mono_type_full_name
+       so it picks up generic arguments.
+
 2008-08-19  Gert Driesen  <drieseng@users.sourceforge.net>
 
        * console-io.c: Removed debug output.
index 78a821682259885b30c4c42e76f77a452881bd94..5ebf5e2ddfe81ae7616d06a236155d1531067fdf 100644 (file)
@@ -78,7 +78,10 @@ append_class_name (GString *res, MonoClass *class, gboolean include_namespace)
 }
 
 void
-mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace) {
+mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace)
+{
+       int i;
+
        switch (type->type) {
        case MONO_TYPE_VOID:
                g_string_append (res, "void"); break;
@@ -132,9 +135,23 @@ mono_type_get_desc (GString *res, MonoType *type, gboolean include_namespace) {
        case MONO_TYPE_VALUETYPE:
                append_class_name (res, type->data.klass, include_namespace);
                break;
-       case MONO_TYPE_GENERICINST:
+       case MONO_TYPE_GENERICINST: {
+               MonoGenericContext *context;
+
                mono_type_get_desc (res, &type->data.generic_class->container_class->byval_arg, include_namespace);
+               g_string_append (res, "<");
+               context = &type->data.generic_class->context;
+               if (context->class_inst) {
+                       for (i = 0; i < context->class_inst->type_argc; ++i)
+                               mono_type_get_desc (res, context->class_inst->type_argv [i], include_namespace);
+               }
+               if (context->method_inst) {
+                       for (i = 0; i < context->method_inst->type_argc; ++i)
+                               mono_type_get_desc (res, context->method_inst->type_argv [i], include_namespace);
+               }
+               g_string_append (res, ">");
                break;
+       }
        case MONO_TYPE_VAR:
        case MONO_TYPE_MVAR:
                g_string_append (res, type->data.generic_param->name);
@@ -177,6 +194,31 @@ mono_signature_get_desc (MonoMethodSignature *sig, gboolean include_namespace)
        return result;
 }
 
+char*
+mono_context_get_desc (MonoGenericContext *context)
+{
+       GString *str;
+       char *res;
+       int i;
+
+       str = g_string_new ("");
+       g_string_append (str, "<");
+
+       if (context->class_inst) {
+               for (i = 0; i < context->class_inst->type_argc; ++i)
+                       mono_type_get_desc (str, context->class_inst->type_argv [i], TRUE);
+       }
+       if (context->method_inst) {
+               for (i = 0; i < context->method_inst->type_argc; ++i)
+                       mono_type_get_desc (str, context->method_inst->type_argv [i], TRUE);
+       }
+
+       g_string_append (str, ">");
+       res = g_strdup (str->str);
+       g_string_free (str, TRUE);
+       return res;
+}      
+
 /**
  * mono_method_desc_new:
  * @name: the method name.
@@ -574,7 +616,7 @@ mono_method_full_name (MonoMethod *method, gboolean signature)
 {
        char *res;
        char wrapper [64];
-       const char *nspace = method->klass->name_space;
+       char *klass_desc = mono_type_full_name (&method->klass->byval_arg);
 
        if (signature) {
                char *tmpsig = mono_signature_get_desc (mono_method_signature (method), TRUE);
@@ -583,17 +625,17 @@ mono_method_full_name (MonoMethod *method, gboolean signature)
                        sprintf (wrapper, "(wrapper %s) ", wrapper_type_to_str (method->wrapper_type));
                else
                        strcpy (wrapper, "");
-               res = g_strdup_printf ("%s%s%s%s:%s (%s)", wrapper, 
-                                                          nspace, *nspace ? "." : "",
-                                                          method->klass->name, method->name, tmpsig);
+               res = g_strdup_printf ("%s%s:%s (%s)", wrapper, klass_desc, 
+                                                          method->name, tmpsig);
                g_free (tmpsig);
        } else {
 
-               res = g_strdup_printf ("%02d %s%s%s:%s", method->wrapper_type,
-                                                          nspace, *nspace ? "." : "",
-                                                          method->klass->name, method->name);
+               res = g_strdup_printf ("%02d %s:%s", method->wrapper_type, klass_desc,
+                                                          method->name);
        }
 
+       g_free (klass_desc);
+
        return res;
 }
 
index c63fa058409af801c357cefd5db0d8f7277a9c50..6e1d61da40438a058b997a30dc15c1b10268ff51 100644 (file)
@@ -30,8 +30,10 @@ char*           mono_type_full_name (MonoType *type);
 
 char*           mono_signature_get_desc (MonoMethodSignature *sig, gboolean include_namespace);
 
+char*           mono_context_get_desc (MonoGenericContext *context);
+
 MonoMethodDesc* mono_method_desc_new (const char *name, gboolean include_namespace);
-MonoMethodDesc*mono_method_desc_from_method (MonoMethod *method);
+MonoMethodDesc* mono_method_desc_from_method (MonoMethod *method);
 void            mono_method_desc_free (MonoMethodDesc *desc);
 gboolean        mono_method_desc_match (MonoMethodDesc *desc, MonoMethod *method);
 gboolean        mono_method_desc_full_match (MonoMethodDesc *desc, MonoMethod *method);