#endif
static void
-append_class_name (GString *res, MonoClass *class, gboolean include_namespace)
+append_class_name (GString *res, MonoClass *klass, gboolean include_namespace)
{
- if (!class) {
+ if (!klass) {
g_string_append (res, "Unknown");
return;
}
- if (class->nested_in) {
- append_class_name (res, class->nested_in, include_namespace);
+ if (klass->nested_in) {
+ append_class_name (res, klass->nested_in, include_namespace);
g_string_append_c (res, '/');
}
- if (include_namespace && *(class->name_space)) {
- g_string_append (res, class->name_space);
+ if (include_namespace && *(klass->name_space)) {
+ g_string_append (res, klass->name_space);
g_string_append_c (res, '.');
}
- g_string_append (res, class->name);
+ g_string_append (res, klass->name);
}
static MonoClass*
return result;
}
+char*
+mono_signature_full_name (MonoMethodSignature *sig)
+{
+ int i;
+ char *result;
+ GString *res;
+
+ if (!sig)
+ return g_strdup ("<invalid signature>");
+
+ res = g_string_new ("");
+
+ mono_type_get_desc (res, sig->ret, TRUE);
+ g_string_append_c (res, '(');
+ for (i = 0; i < sig->param_count; ++i) {
+ if (i > 0)
+ g_string_append_c (res, ',');
+ mono_type_get_desc (res, sig->params [i], TRUE);
+ }
+ g_string_append_c (res, ')');
+ result = res->str;
+ g_string_free (res, FALSE);
+ return result;
+}
+
static void
ginst_get_desc (GString *str, MonoGenericInst *ginst)
{
g_free (desc);
}
-/*
+/**
+ * mono_method_descr_match:
+ * @desc: MonoMethoDescription
+ * @method: MonoMethod to test
+ *
+ * Determines whether the specified @method matches the provided @desc description.
+ *
* namespace and class are supposed to match already if this function is used.
+ * Returns: True if the method matches the description, false otherwise.
*/
gboolean
mono_method_desc_match (MonoMethodDesc *desc, MonoMethod *method)
}
if (desc->name_space && desc->klass) {
- klass = mono_class_from_name (image, desc->name_space, desc->klass);
+ klass = mono_class_try_load_from_name (image, desc->name_space, desc->klass);
if (!klass)
return NULL;
return mono_method_desc_search_in_class (desc, klass);
mono_image_get_table_info (image, MONO_TABLE_TYPEDEF);
methods = mono_image_get_table_info (image, MONO_TABLE_METHOD);
for (i = 0; i < mono_table_info_get_rows (methods); ++i) {
+ MonoError error;
guint32 token = mono_metadata_decode_row_col (methods, i, MONO_METHOD_NAME);
const char *n = mono_metadata_string_heap (image, token);
if (strcmp (n, desc->name))
continue;
- method = mono_get_method (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL);
+ method = mono_get_method_checked (image, MONO_TOKEN_METHOD_DEF | (i + 1), NULL, NULL, &error);
+ if (!method) {
+ mono_error_cleanup (&error);
+ continue;
+ }
if (mono_method_desc_full_match (desc, method))
return method;
}
return result;
}
+/**
+ * mono_field_full_name:
+ * @field: field to retrieve information for
+ *
+ * Returns: the full name for the field, made up of the namespace, type name and the field name.
+ */
char *
mono_field_full_name (MonoClassField *field)
{
}
char *
-mono_method_get_name_full (MonoMethod *method, gboolean signature, MonoTypeNameFormat format)
+mono_method_get_name_full (MonoMethod *method, gboolean signature, gboolean ret, MonoTypeNameFormat format)
{
char *res;
char wrapper [64];
sprintf (wrapper, "(wrapper %s) ", wrapper_type_to_str (method->wrapper_type));
else
strcpy (wrapper, "");
- res = g_strdup_printf ("%s%s:%s%s (%s)", wrapper, klass_desc,
- method->name, inst_desc ? inst_desc : "", tmpsig);
+ if (ret) {
+ char *ret_str = mono_type_full_name (mono_method_signature (method)->ret);
+ res = g_strdup_printf ("%s%s %s:%s%s (%s)", wrapper, ret_str, klass_desc,
+ method->name, inst_desc ? inst_desc : "", tmpsig);
+ g_free (ret_str);
+ } else {
+ res = g_strdup_printf ("%s%s:%s%s (%s)", wrapper, klass_desc,
+ method->name, inst_desc ? inst_desc : "", tmpsig);
+ }
g_free (tmpsig);
} else {
res = g_strdup_printf ("%s%s:%s%s", wrapper, klass_desc,
char *
mono_method_full_name (MonoMethod *method, gboolean signature)
{
- return mono_method_get_name_full (method, signature, MONO_TYPE_NAME_FORMAT_IL);
+ return mono_method_get_name_full (method, signature, FALSE, MONO_TYPE_NAME_FORMAT_IL);
+}
+
+char *
+mono_method_get_full_name (MonoMethod *method)
+{
+ return mono_method_get_name_full (method, TRUE, TRUE, MONO_TYPE_NAME_FORMAT_IL);
}
static const char*
}
static void
-objval_describe (MonoClass *class, const char *addr)
+objval_describe (MonoClass *klass, const char *addr)
{
MonoClassField *field;
MonoClass *p;
const char *field_ptr;
gssize type_offset = 0;
- if (class->valuetype)
+
+ if (klass->valuetype)
type_offset = -sizeof (MonoObject);
- for (p = class; p != NULL; p = p->parent) {
+ for (p = klass; p != NULL; p = p->parent) {
gpointer iter = NULL;
int printed_header = FALSE;
while ((field = mono_class_get_fields (p, &iter))) {
if (field->type->attrs & (FIELD_ATTRIBUTE_STATIC | FIELD_ATTRIBUTE_HAS_FIELD_RVA))
continue;
- if (p != class && !printed_header) {
+ if (p != klass && !printed_header) {
const char *sep;
g_print ("In class ");
sep = print_name_space (p);
void
mono_object_describe_fields (MonoObject *obj)
{
- MonoClass *class = mono_object_class (obj);
- objval_describe (class, (char*)obj);
+ MonoClass *klass = mono_object_class (obj);
+ objval_describe (klass, (char*)obj);
}
/**
if (!vtable)
return;
- if (!(addr = mono_vtable_get_static_field_data (vtable)))
+ if (!(addr = (const char *)mono_vtable_get_static_field_data (vtable)))
return;
for (p = klass; p != NULL; p = p->parent) {
continue;
if (!(field->type->attrs & (FIELD_ATTRIBUTE_STATIC | FIELD_ATTRIBUTE_HAS_FIELD_RVA)))
continue;
- // Special static fields don't have a domain-level static slot
- if (mono_class_field_is_special_static (field))
- continue;
field_ptr = (const char*)addr + field->offset;