2 * get.c: Functions to get stringified values from the metadata tables.
5 * Miguel de Icaza (miguel@ximian.com)
7 * (C) 2001 Ximian, Inc.
8 * Copyright 2012 Xamarin Inc
20 #include <mono/utils/mono-compiler.h>
21 #include <mono/metadata/class.h>
22 #include <mono/metadata/marshal.h>
24 extern gboolean substitute_with_mscorlib_p
;
26 static MonoGenericContainer
*
27 get_memberref_container (MonoImage
*m
, guint32 mrp_token
, MonoGenericContainer
*container
);
30 get_memberref_parent (MonoImage
*m
, guint32 mrp_token
, MonoGenericContainer
*container
);
33 cant_print_generic_param_name (MonoGenericParam
*gparam
);
35 GHashTable
*key_table
= NULL
;
36 GHashTable
*mono_generic_params_with_ambiguous_names
= NULL
;
37 GHashTable
*generic_containers
= NULL
;
38 gboolean show_method_tokens
= FALSE
;
39 gboolean show_tokens
= FALSE
;
42 get_typedef (MonoImage
*m
, int idx
)
44 guint32 cols
[MONO_TYPEDEF_SIZE
];
46 char *tstring
, *result
;
53 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_TYPEDEF
], idx
- 1, cols
, MONO_TYPEDEF_SIZE
);
55 ns
= mono_metadata_string_heap (m
, cols
[MONO_TYPEDEF_NAMESPACE
]);
57 /* Check if this is a nested type */
58 token
= MONO_TOKEN_TYPE_DEF
| (idx
);
59 token
= mono_metadata_nested_in_typedef (m
, token
);
60 tstring
= show_tokens
? g_strdup_printf ("/*%08x*/", token
) : NULL
;
64 outer
= get_typedef (m
, mono_metadata_token_index (token
));
65 result
= g_strdup_printf (
67 mono_metadata_string_heap (m
, cols
[MONO_TYPEDEF_NAME
]),
68 tstring
? tstring
: "");
75 result
= g_strdup_printf (
76 "%s%s%s%s", ns
, *ns
?".":"",
77 mono_metadata_string_heap (m
, cols
[MONO_TYPEDEF_NAME
]),
78 tstring
? tstring
: "");
85 get_module (MonoImage
*m
, int idx
)
87 guint32 cols
[MONO_MODULE_SIZE
];
90 * There MUST BE only one module in the Module table
94 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MODULE
], idx
- 1, cols
, MONO_MODULE_SIZE
);
96 return get_escaped_name (mono_metadata_string_heap (m
, cols
[MONO_MODULE_NAME
]));
100 get_moduleref (MonoImage
*m
, int idx
)
102 guint32 cols
[MONO_MODULEREF_SIZE
];
104 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MODULEREF
], idx
- 1, cols
, MONO_MODULEREF_SIZE
);
106 return get_escaped_name (mono_metadata_string_heap (m
, cols
[MONO_MODULEREF_NAME
]));
110 get_assemblyref (MonoImage
*m
, int idx
)
112 guint32 cols
[MONO_ASSEMBLYREF_SIZE
];
114 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_ASSEMBLYREF
], idx
- 1, cols
, MONO_ASSEMBLYREF_SIZE
);
116 return get_escaped_name (mono_metadata_string_heap (m
, cols
[MONO_ASSEMBLYREF_NAME
]));
120 stringify_array (guint32 rank
, guint32 num_sizes
, guint32 num_lo_bounds
, gint32
*sizes
, gint32
*lo_bounds
)
122 GString
*res
= g_string_new ("[");
125 for (i
= 0; i
< rank
; i
++) {
127 g_string_append_c (res
, ',');
128 if (i
< num_lo_bounds
)
129 g_string_append_printf (res
, "%d...", lo_bounds
[i
]);
131 if (i
< num_lo_bounds
)
132 g_string_append_printf (res
, "%d", lo_bounds
[i
] + sizes
[i
] - 1);
134 g_string_append_printf (res
, "%d", sizes
[i
]);
138 g_string_append (res
, "]");
140 return g_string_free (res
, FALSE
);
145 * Returns a string representing the ArrayShape (22.2.16).
148 get_array_shape (MonoImage
*m
, const char *ptr
, char **result
)
150 guint32 rank
, num_sizes
, num_lo_bounds
;
151 gint32
*sizes
= NULL
, *lo_bounds
= NULL
;
154 rank
= mono_metadata_decode_value (ptr
, &ptr
);
155 num_sizes
= mono_metadata_decode_value (ptr
, &ptr
);
158 sizes
= g_new (gint32
, num_sizes
);
160 for (i
= 0; i
< num_sizes
; i
++)
161 sizes
[i
] = mono_metadata_decode_value (ptr
, &ptr
);
163 num_lo_bounds
= mono_metadata_decode_value (ptr
, &ptr
);
164 if (num_lo_bounds
> 0)
165 lo_bounds
= g_new (gint32
, num_lo_bounds
);
167 for (i
= 0; i
< num_lo_bounds
; i
++)
168 lo_bounds
[i
] = mono_metadata_decode_signed_value (ptr
, &ptr
);
170 *result
= stringify_array (rank
, num_sizes
, num_lo_bounds
, sizes
, lo_bounds
);
180 * @m: metadata context
181 * @blob_idx: index into the blob heap
183 * Returns the stringified representation of a TypeSpec signature (22.2.17)
186 get_typespec (MonoImage
*m
, guint32 idx
, gboolean is_def
, MonoGenericContainer
*container
)
188 guint32 cols
[MONO_TYPESPEC_SIZE
];
191 GString
*res
= g_string_new ("");
192 MonoMethodSignature
*sig
;
194 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_TYPESPEC
], idx
-1, cols
, MONO_TYPESPEC_SIZE
);
195 ptr
= mono_metadata_blob_heap (m
, cols
[MONO_TYPESPEC_SIGNATURE
]);
196 /* len = */ mono_metadata_decode_value (ptr
, &ptr
);
200 ptr
= get_custom_mod (m
, ptr
, &s
);
202 g_string_append (res
, s
);
203 g_string_append_c (res
, ' ');
207 if (*ptr
== MONO_TYPE_VOID
)
208 g_string_append (res
, "void");
210 ptr
= get_type (m
, ptr
, &s
, is_def
, container
);
212 g_string_append (res
, s
);
214 g_string_append (res
, "*");
217 case MONO_TYPE_FNPTR
: {
219 sig
= mono_metadata_parse_method_signature_full (m
, container
, 0, ptr
, &ptr
, &error
);
220 g_assert (mono_error_ok (&error
)); /*FIXME don't swallow the error message*/
221 s
= dis_stringify_function_ptr (m
, sig
);
222 g_string_append (res
, "method ");
223 g_string_append (res
, s
);
227 case MONO_TYPE_ARRAY
:
228 ptr
= get_type (m
, ptr
, &s
, is_def
, container
);
229 g_string_append (res
, s
);
231 g_string_append_c (res
, ' ');
232 ptr
= get_array_shape (m
, ptr
, &s
);
233 g_string_append (res
, s
);
237 case MONO_TYPE_SZARRAY
:
238 ptr
= get_custom_mod (m
, ptr
, &s
);
240 g_string_append (res
, s
);
241 g_string_append_c (res
, ' ');
244 ptr
= get_type (m
, ptr
, &s
, is_def
, container
);
245 g_string_append (res
, s
);
246 g_string_append (res
, "[]");
251 ptr
= get_type (m
, ptr
- 1, &s
, is_def
, container
);
252 g_string_append (res
, s
);
258 int token
= mono_metadata_make_token (MONO_TABLE_TYPESPEC
, idx
);
259 result
= g_strdup_printf ("%s/*%08x*/", res
->str
, token
);
263 g_string_free (res
, FALSE
);
269 get_typeref (MonoImage
*m
, int idx
)
271 guint32 cols
[MONO_TYPEREF_SIZE
];
274 guint32 rs_idx
, table
;
276 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_TYPEREF
], idx
- 1, cols
, MONO_TYPEREF_SIZE
);
278 t
= mono_metadata_string_heap (m
, cols
[MONO_TYPEREF_NAME
]);
279 s
= mono_metadata_string_heap (m
, cols
[MONO_TYPEREF_NAMESPACE
]);
281 rs_idx
= cols
[MONO_TYPEREF_SCOPE
] >> MONO_RESOLTION_SCOPE_BITS
;
282 table
= cols
[MONO_TYPEREF_SCOPE
] & MONO_RESOLTION_SCOPE_MASK
;
285 case MONO_RESOLTION_SCOPE_MODULE
: /* Module */
286 x
= get_module (m
, rs_idx
);
287 ret
= g_strdup_printf ("[%s] %s%s%s", x
, s
, *s
?".":"", t
);
291 case MONO_RESOLTION_SCOPE_MODULEREF
: /* ModuleRef */
292 x
= get_moduleref (m
, rs_idx
);
293 ret
= g_strdup_printf ("[.module %s]%s%s%s", x
, s
, *s
? "." : "", t
);
296 case MONO_RESOLTION_SCOPE_ASSEMBLYREF
: /*
297 * AssemblyRef (ECMA docs claim it is 3, but it looks to
298 * me like it is 2 (tokens are prefixed with 0x23)
300 x
= get_assemblyref (m
, rs_idx
);
301 ret
= g_strdup_printf ("[%s]%s%s%s", x
, s
, *s
?".":"", t
);
305 case MONO_RESOLTION_SCOPE_TYPEREF
: /* TypeRef */
306 x
= get_typeref (m
, rs_idx
);
307 ret
= g_strdup_printf ("%s/%s", x
, t
);
312 ret
= g_strdup_printf ("Unknown table in TypeRef %d", table
);
316 int token
= mono_metadata_make_token (MONO_TABLE_TYPEREF
, idx
);
317 char *temp
= g_strdup_printf ("%s/*%08x*/", ret
, token
);
326 * get_typedef_or_ref:
327 * @m: metadata context
328 * @dor_token: def or ref encoded index
330 * Low two bits contain table to lookup from
331 * high bits contain the index into the def or ref table
333 * Returns: a stringified version of the MethodDef or MethodRef
334 * at (dor_token >> 2)
337 get_typedef_or_ref (MonoImage
*m
, guint32 dor_token
, MonoGenericContainer
*container
)
339 char *temp
= NULL
, *s
= NULL
;
343 * low 2 bits contain encoding
345 table
= dor_token
& MONO_TYPEDEFORREF_MASK
;
346 idx
= dor_token
>> MONO_TYPEDEFORREF_BITS
;
349 case 0: /* TypeDef */
350 temp
= get_typedef (m
, idx
);
351 s
= g_strdup_printf ("%s", temp
);
354 case 1: /* TypeRef */
355 temp
= get_typeref (m
, idx
);
356 s
= g_strdup_printf ("%s", temp
);
359 case 2: /* TypeSpec */
360 s
= get_typespec (m
, idx
, FALSE
, container
);
364 g_error ("Unhandled encoding for typedef-or-ref coded index 0x%08x", dor_token
);
375 * get_type_or_methdef
376 * @m: metadata context
377 * @dor_token: type or method def encoded index
379 * Low bit contains the table to lookup from
380 * high bits contain the index into the type def or method def table
382 * Returns: a stringified version of the TypeOrMethodDef token
385 get_type_or_methdef (MonoImage
*m
, guint32 dor_token
)
387 if (dor_token
& MONO_TYPEORMETHOD_METHOD
) /* MethodDef */
388 return get_methoddef (m
, dor_token
>> MONO_TYPEORMETHOD_BITS
);
390 return get_typedef (m
, dor_token
>> MONO_TYPEORMETHOD_BITS
);
394 * get_encoded_typedef_or_ref:
395 * @m: metadata context
396 * @ptr: location to decode from.
397 * @result: pointer to string where resulting decoded string is stored
399 * result will point to a g_malloc()ed string.
401 * Returns: the new ptr to continue decoding
404 get_encoded_typedef_or_ref (MonoImage
*m
, const char *ptr
, char **result
)
408 token
= mono_metadata_decode_value (ptr
, &ptr
);
410 *result
= get_typedef_or_ref (m
, token
, NULL
);
418 * Decodes a CustomMod (22.2.7)
420 * Returns: updated pointer location
423 get_custom_mod (MonoImage
*m
, const char *ptr
, char **return_value
)
428 *return_value
= NULL
;
429 while ((*ptr
== MONO_TYPE_CMOD_OPT
) ||
430 (*ptr
== MONO_TYPE_CMOD_REQD
)) {
431 mod
= (*ptr
== MONO_TYPE_CMOD_REQD
) ? "modreq" : "modopt";
433 ptr
= get_encoded_typedef_or_ref (m
, ptr
, &s
);
435 if (*return_value
== NULL
)
436 *return_value
= g_strconcat (" ", mod
, " (", s
, ")", NULL
);
438 *return_value
= g_strconcat (*return_value
, " ", mod
, " (", s
, ")", NULL
);
445 static dis_map_t element_type_map
[] = {
446 { MONO_TYPE_END
, "end" },
447 { MONO_TYPE_VOID
, "void" },
448 { MONO_TYPE_BOOLEAN
, "bool" },
449 { MONO_TYPE_CHAR
, "char" },
450 { MONO_TYPE_I1
, "int8" },
451 { MONO_TYPE_U1
, "unsigned int8" },
452 { MONO_TYPE_I2
, "int16" },
453 { MONO_TYPE_U2
, "unsigned int16" },
454 { MONO_TYPE_I4
, "int32" },
455 { MONO_TYPE_U4
, "unsigned int32" },
456 { MONO_TYPE_I8
, "int64" },
457 { MONO_TYPE_U8
, "unsigned int64" },
458 { MONO_TYPE_R4
, "float32" },
459 { MONO_TYPE_R8
, "float64" },
460 { MONO_TYPE_STRING
, "string" },
461 { MONO_TYPE_TYPEDBYREF
, "typedref" },
462 { MONO_TYPE_I
, "native int" },
463 { MONO_TYPE_U
, "native unsigned int" },
464 { MONO_TYPE_OBJECT
, "object" },
468 static dis_map_t call_conv_type_map
[] = {
469 { MONO_CALL_DEFAULT
, "default" },
470 { MONO_CALL_C
, "unmanaged cdecl" },
471 { MONO_CALL_STDCALL
, "unmanaged stdcall" },
472 { MONO_CALL_THISCALL
, "unmanaged thiscall" },
473 { MONO_CALL_FASTCALL
, "unmanaged fastcall" },
474 { MONO_CALL_VARARG
, "vararg" },
479 dis_stringify_token (MonoImage
*m
, guint32 token
)
481 guint idx
= token
& 0xffffff;
482 switch (token
>> 24) {
483 case MONO_TABLE_TYPEDEF
: return get_typedef (m
, idx
);
484 case MONO_TABLE_TYPEREF
: return get_typeref (m
, idx
);
485 case MONO_TABLE_TYPESPEC
: return get_typespec (m
, idx
, FALSE
, NULL
);
489 return g_strdup_printf("0x%08x", token
);
493 dis_stringify_array (MonoImage
*m
, MonoArrayType
*array
, gboolean is_def
)
495 char *type
, *arr_str
, *ret
;
497 type
= dis_stringify_type (m
, &array
->eklass
->byval_arg
, is_def
);
498 arr_str
= stringify_array (array
->rank
, array
->numsizes
, array
->numlobounds
, array
->sizes
, array
->lobounds
);
500 ret
= g_strconcat (type
, arr_str
, NULL
);
508 dis_stringify_modifiers (MonoImage
*m
, int n
, MonoCustomMod
*mod
)
510 GString
*s
= g_string_new("");
513 for (i
= 0; i
< n
; ++i
) {
514 char *tok
= dis_stringify_token (m
, mod
[i
].token
);
516 g_string_append_printf (s
, " ");
517 g_string_append_printf (s
, " %s (%s)", mod
[i
].required
? "modreq": "modopt", tok
);
520 g_string_append_c (s
, ' ');
522 g_string_free (s
, FALSE
);
527 dis_stringify_param (MonoImage
*m
, MonoType
*param
)
532 const char *in
= param
->attrs
& PARAM_ATTRIBUTE_IN
? "[in]" : "";
533 const char *out
= param
->attrs
& PARAM_ATTRIBUTE_OUT
? "[out]": "";
534 const char *opt
= param
->attrs
& PARAM_ATTRIBUTE_OPTIONAL
? "[opt]": "";
535 attribs
= g_strconcat(in
, out
, opt
, NULL
);
536 t
= dis_stringify_type (m
, param
, TRUE
);
537 result
= g_strjoin(attribs
[0] ? " ":"", attribs
, t
, NULL
);
544 dis_stringify_variant_type (MonoMarshalVariant variant
)
547 case MONO_VARIANT_EMPTY
:
548 return g_strdup ("");
549 case MONO_VARIANT_NULL
:
550 return g_strdup ("null");
551 case MONO_VARIANT_I2
:
552 return g_strdup ("int16");
553 case MONO_VARIANT_I4
:
554 return g_strdup ("int32");
555 case MONO_VARIANT_R4
:
556 return g_strdup ("float32");
557 case MONO_VARIANT_R8
:
558 return g_strdup ("float64");
559 case MONO_VARIANT_CY
:
560 return g_strdup ("currency");
561 case MONO_VARIANT_DATE
:
562 return g_strdup ("date");
563 case MONO_VARIANT_BSTR
:
564 return g_strdup ("bstr");
565 case MONO_VARIANT_DISPATCH
:
566 return g_strdup ("idispatch");
567 case MONO_VARIANT_ERROR
:
568 return g_strdup ("error");
569 case MONO_VARIANT_BOOL
:
570 return g_strdup ("bool");
571 case MONO_VARIANT_VARIANT
:
572 return g_strdup ("variant");
573 case MONO_VARIANT_UNKNOWN
:
574 return g_strdup ("iunknown");
575 case MONO_VARIANT_DECIMAL
:
576 return g_strdup ("decimal");
577 case MONO_VARIANT_I1
:
578 return g_strdup ("int8");
579 case MONO_VARIANT_UI1
:
580 return g_strdup ("unsigned int8");
581 case MONO_VARIANT_UI2
:
582 return g_strdup ("unsigned int16");
583 case MONO_VARIANT_UI4
:
584 return g_strdup ("unsigned int32");
585 case MONO_VARIANT_I8
:
586 return g_strdup ("int64");
587 case MONO_VARIANT_UI8
:
588 return g_strdup ("unsigned int64");
589 case MONO_VARIANT_INT
:
590 return g_strdup ("int");
591 case MONO_VARIANT_UINT
:
592 return g_strdup ("unsigned int");
593 case MONO_VARIANT_VOID
:
594 return g_strdup ("void");
595 case MONO_VARIANT_HRESULT
:
596 return g_strdup ("hresult");
597 case MONO_VARIANT_PTR
:
598 return g_strdup ("*");
599 case MONO_VARIANT_SAFEARRAY
:
600 return g_strdup ("safearray");
601 case MONO_VARIANT_CARRAY
:
602 return g_strdup ("carray");
603 case MONO_VARIANT_USERDEFINED
:
604 return g_strdup ("userdefined");
605 case MONO_VARIANT_LPSTR
:
606 return g_strdup ("lpstr");
607 case MONO_VARIANT_LPWSTR
:
608 return g_strdup ("lpwstr");
609 case MONO_VARIANT_RECORD
:
610 return g_strdup ("record");
611 case MONO_VARIANT_FILETIME
:
612 return g_strdup ("filetime");
613 case MONO_VARIANT_BLOB
:
614 return g_strdup ("blob");
615 case MONO_VARIANT_STREAM
:
616 return g_strdup ("stream");
617 case MONO_VARIANT_STORAGE
:
618 return g_strdup ("storage");
619 case MONO_VARIANT_STREAMED_OBJECT
:
620 return g_strdup ("streamed_object");
621 case MONO_VARIANT_STORED_OBJECT
:
622 return g_strdup ("stored_object");
623 case MONO_VARIANT_BLOB_OBJECT
:
624 return g_strdup ("blob_object");
625 case MONO_VARIANT_CF
:
626 return g_strdup ("cf");
627 case MONO_VARIANT_CLSID
:
628 return g_strdup ("clsid");
629 case MONO_VARIANT_VECTOR
:
630 /* FIXME: output: <v_type> vector */
631 return g_strdup ("vector");
632 case MONO_VARIANT_ARRAY
:
633 /* FIXME: output: <v_type> [ ] */
634 return g_strdup ("[]");
635 case MONO_VARIANT_BYREF
:
636 /* FIXME: output: <v_type> & */
637 return g_strdup ("&");
639 return g_strdup ("unknown");
644 dis_stringify_native_type (MonoMarshalNative native
)
647 case MONO_NATIVE_BOOLEAN
:
648 return g_strdup ("bool");
650 return g_strdup ("int8");
652 return g_strdup ("unsigned int8");
654 return g_strdup ("int16");
656 return g_strdup ("unsigned int16");
658 return g_strdup ("int32");
660 return g_strdup ("unsigned int32");
662 return g_strdup ("int64");
664 return g_strdup ("unsigned int64");
666 return g_strdup ("float32");
668 return g_strdup ("float64");
669 case MONO_NATIVE_CURRENCY
:
670 return g_strdup ("currency");
671 case MONO_NATIVE_BSTR
:
672 return g_strdup ("bstr");
673 case MONO_NATIVE_LPSTR
:
674 return g_strdup ("lpstr");
675 case MONO_NATIVE_LPWSTR
:
676 return g_strdup ("lpwstr");
677 case MONO_NATIVE_LPTSTR
:
678 return g_strdup ("lptstr");
679 case MONO_NATIVE_IUNKNOWN
:
680 return g_strdup ("iunknown");
681 case MONO_NATIVE_IDISPATCH
:
682 return g_strdup ("idispatch");
683 case MONO_NATIVE_STRUCT
:
684 return g_strdup ("struct");
685 case MONO_NATIVE_INTERFACE
:
686 return g_strdup ("interface");
687 case MONO_NATIVE_SAFEARRAY
:
688 return g_strdup ("safearray");
689 case MONO_NATIVE_INT
:
690 return g_strdup ("int");
691 case MONO_NATIVE_UINT
:
692 return g_strdup ("unsigned int");
693 case MONO_NATIVE_VBBYREFSTR
:
694 return g_strdup ("vbbyrefstr");
695 case MONO_NATIVE_ANSIBSTR
:
696 return g_strdup ("ansi bstr");
697 case MONO_NATIVE_TBSTR
:
698 return g_strdup ("tbstr");
699 case MONO_NATIVE_VARIANTBOOL
:
700 return g_strdup ("variant bool");
701 case MONO_NATIVE_FUNC
:
702 return g_strdup ("method");
703 case MONO_NATIVE_ASANY
:
704 return g_strdup ("as any");
705 case MONO_NATIVE_LPSTRUCT
:
706 return g_strdup ("lpstruct");
707 case MONO_NATIVE_CUSTOM
:
708 return g_strdup ("custom");
709 case MONO_NATIVE_ERROR
:
710 return g_strdup ("error");
711 case MONO_NATIVE_MAX
:
712 return g_strdup ("");
714 return g_strdup ("unknown");
719 dis_stringify_marshal_spec (MonoMarshalSpec
*spec
)
721 switch (spec
->native
) {
722 case MONO_NATIVE_BYVALTSTR
:
723 return g_strdup_printf (" marshal (fixed sysstring [%d])", spec
->data
.array_data
.num_elem
);
724 case MONO_NATIVE_BYVALARRAY
:
725 return g_strdup_printf (" marshal (fixed array [%d])", spec
->data
.array_data
.num_elem
);
726 case MONO_NATIVE_LPARRAY
: {
727 char *elem_type
, *elems
, *ret
;
728 guint32 num_elem
= spec
->data
.array_data
.num_elem
;
729 guint32 param_num
= spec
->data
.array_data
.param_num
;
731 elem_type
= dis_stringify_native_type (spec
->data
.array_data
.elem_type
);
732 if (num_elem
== -1 && param_num
== -1)
733 elems
= g_strdup ("");
734 else if ((param_num
== -1) || (spec
->data
.array_data
.elem_mult
== 0))
735 elems
= g_strdup_printf ("%d", num_elem
);
736 else if ((num_elem
== -1) || (num_elem
== 0))
737 elems
= g_strdup_printf ("+ %d", param_num
);
739 elems
= g_strdup_printf ("%d + %d", num_elem
, param_num
);
741 ret
= g_strdup_printf (" marshal (%s[%s])", elem_type
, elems
);
746 case MONO_NATIVE_SAFEARRAY
: {
747 char *elem_type
= NULL
, *ret
;
749 if (spec
->data
.safearray_data
.elem_type
!= 0)
750 elem_type
= dis_stringify_variant_type (spec
->data
.safearray_data
.elem_type
);
751 ret
= g_strdup_printf (" marshal (safearray %s)", elem_type
? elem_type
: "");
756 case MONO_NATIVE_CUSTOM
:
757 return g_strdup_printf (" marshal (custom (\"%s\", \"%s\"))",
758 spec
->data
.custom_data
.custom_name
? spec
->data
.custom_data
.custom_name
: "",
759 spec
->data
.custom_data
.cookie
? spec
->data
.custom_data
.cookie
: "");
761 char *native_type
, *ret
;
762 native_type
= dis_stringify_native_type (spec
->native
);
763 ret
= g_strdup_printf (" marshal (%s)", native_type
);
764 g_free (native_type
);
772 * @m: metadata context
773 * @table_type: The type of table we are getting generics for (0 for typedef, 1 for method)
774 * @row: The row in the table
776 * Returns: Allocated stringified generic parameters
779 get_generic_param (MonoImage
*m
, MonoGenericContainer
*container
)
788 result
= g_string_new ("");
790 g_string_append_c (result
, '<');
791 for (i
= 0; i
< container
->type_argc
; i
++) {
792 MonoGenericParam
*param
= mono_generic_container_get_param (container
, i
);
793 MonoGenericParamInfo
*param_info
= mono_generic_param_info (param
);
800 g_string_append (result
, ",");
802 flags
= param_info
->flags
& GENERIC_PARAMETER_ATTRIBUTE_VARIANCE_MASK
;
803 if ((flags
& GENERIC_PARAMETER_ATTRIBUTE_COVARIANT
) == GENERIC_PARAMETER_ATTRIBUTE_COVARIANT
)
804 g_string_append (result
, "+ ");
805 if ((flags
& GENERIC_PARAMETER_ATTRIBUTE_CONTRAVARIANT
) == GENERIC_PARAMETER_ATTRIBUTE_CONTRAVARIANT
)
806 g_string_append (result
, "- ");
808 flags
= param_info
->flags
& GENERIC_PARAMETER_ATTRIBUTE_SPECIAL_CONSTRAINTS_MASK
;
809 if ((flags
& GENERIC_PARAMETER_ATTRIBUTE_REFERENCE_TYPE_CONSTRAINT
) == GENERIC_PARAMETER_ATTRIBUTE_REFERENCE_TYPE_CONSTRAINT
)
810 g_string_append (result
, "class ");
811 if ((flags
& GENERIC_PARAMETER_ATTRIBUTE_VALUE_TYPE_CONSTRAINT
) == GENERIC_PARAMETER_ATTRIBUTE_VALUE_TYPE_CONSTRAINT
)
812 g_string_append (result
, "valuetype ");
813 if ((flags
& GENERIC_PARAMETER_ATTRIBUTE_CONSTRUCTOR_CONSTRAINT
) == GENERIC_PARAMETER_ATTRIBUTE_CONSTRUCTOR_CONSTRAINT
)
814 g_string_append (result
, ".ctor ");
816 for (constr
= param_info
->constraints
; constr
&& *constr
; constr
++) {
820 g_string_append_c (result
, '(');
823 g_string_append (result
, ", ");
824 sig
= dis_stringify_type (m
, &((*constr
)->byval_arg
), TRUE
);
825 g_string_append (result
, sig
);
830 g_string_append (result
, ") ");
832 esname
= get_escaped_name (mono_generic_param_info (param
)->name
);
833 g_string_append (result
, esname
);
837 g_string_append_c (result
, '>');
839 retval
= result
->str
;
840 g_string_free (result
, FALSE
);
845 dis_stringify_method_signature (MonoImage
*m
, MonoMethodSignature
*method
, int methoddef_row
,
846 MonoGenericContainer
*container
, gboolean fully_qualified
)
848 return dis_stringify_method_signature_full (m
, method
, methoddef_row
, container
, fully_qualified
, TRUE
);
852 * @m: metadata context
853 * @method: MonoMethodSignature to dis-stringify
854 * @methoddef_row: row index in the Method table
855 * @context: generic context, generic method's context in case of a Generic method
856 * or a generic type's context. if !@context, treats it as a non-generic method
857 * @fully_qualified: TRUE to print type name also.
859 * Returns: Allocated stringified method signature
862 dis_stringify_method_signature_full (MonoImage
*m
, MonoMethodSignature
*method
, int methoddef_row
,
863 MonoGenericContainer
*container
, gboolean fully_qualified
, gboolean with_marshal_info
)
865 guint32 cols
[MONO_METHOD_SIZE
];
866 guint32 pcols
[MONO_PARAM_SIZE
];
867 guint32 param_index
= 0, next_param_index
= 0;
868 gboolean has_param_row
;
869 const char *method_name
= "";
871 char *retval
, *esname
;
873 char *marshal_info
= NULL
, *ret_marshal_info
= NULL
;
874 char *gen_param
= NULL
;
875 GString
*result
= g_string_new ("");
876 GString
*result_ret
= g_string_new ("");
879 g_assert (method
|| methoddef_row
);
882 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHOD
], methoddef_row
-1, cols
, MONO_METHOD_SIZE
);
883 if (fully_qualified
) {
884 guint32 type_idx
= mono_metadata_typedef_from_method (m
, methoddef_row
);
886 type
= get_typedef (m
, type_idx
);
888 type
= g_strdup ("<invalid>");
890 method_name
= mono_metadata_string_heap (m
, cols
[MONO_METHOD_NAME
]);
891 param_index
= cols
[MONO_METHOD_PARAMLIST
];
894 const char *sig
= mono_metadata_blob_heap (m
, cols
[MONO_METHOD_SIGNATURE
]);
896 container
= mono_metadata_load_generic_params (m
, MONO_TOKEN_METHOD_DEF
| methoddef_row
, container
);
898 mono_metadata_load_generic_param_constraints_checked (m
, MONO_TOKEN_METHOD_DEF
| methoddef_row
, container
, &error
);
899 g_assert (mono_error_ok (&error
)); /*FIXME don't swallow the error message*/
902 mono_metadata_decode_blob_size (sig
, &sig
);
903 method
= mono_metadata_parse_method_signature_full (m
, container
, methoddef_row
, sig
, &sig
, &error
);
904 g_assert (mono_error_ok (&error
)); /*FIXME don't swallow the error message*/
908 if (container
&& container
->is_method
)
909 gen_param
= get_generic_param (m
, container
);
911 if (methoddef_row
< m
->tables
[MONO_TABLE_METHOD
].rows
) {
912 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHOD
], methoddef_row
, cols
, MONO_METHOD_SIZE
);
913 next_param_index
= cols
[MONO_METHOD_PARAMLIST
];
915 next_param_index
= m
->tables
[MONO_TABLE_PARAM
].rows
+ 1;
919 start
= method
->hasthis
? 0 : 1;
920 for (i
= 0; i
< method
->param_count
+ 1; ++i
) {
922 has_param_row
= param_index
&& param_index
< next_param_index
;
925 if (method
->param_count
== 0 && !has_param_row
)
926 /* method has zero parameters, and no row for return val in the PARAM table */
930 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_PARAM
], param_index
- 1, pcols
, MONO_PARAM_SIZE
);
932 if (has_param_row
&& i
== pcols
[MONO_PARAM_SEQUENCE
]) {
934 esname
= get_escaped_name (
935 mono_metadata_string_heap (m
, pcols
[MONO_PARAM_NAME
]));
937 if (with_marshal_info
&& (pcols
[MONO_PARAM_FLAGS
] & PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL
)) {
939 MonoMarshalSpec
*spec
;
940 tp
= mono_metadata_get_marshal_info (m
, param_index
- 1, FALSE
);
942 spec
= mono_metadata_parse_marshal_spec (m
, tp
);
945 marshal_info
= dis_stringify_marshal_spec (spec
);
947 ret_marshal_info
= dis_stringify_marshal_spec (spec
);
950 marshal_info
= g_strdup ("(missing)");
952 ret_marshal_info
= g_strdup ("(missing)");
958 /* A_[0-9]* does not require escaping */
959 esname
= g_strdup_printf ("A_%i", i
- start
);
966 g_string_append (result
, ", ");
968 retval
= dis_stringify_param (m
, method
->params
[i
- 1]);
970 g_string_append_printf (result
, "%s%s %s", retval
, marshal_info
? marshal_info
: "", esname
);
973 g_free (marshal_info
);
975 g_string_append (result
, ") ");
977 retval
= dis_stringify_param (m
, method
->ret
);
980 g_string_append (result_ret
, "instance ");
981 g_string_append (result_ret
, map (method
->call_convention
, call_conv_type_map
));
982 g_string_append_printf (result_ret
, " %s%s ", retval
, ret_marshal_info
? ret_marshal_info
:"");
983 g_free (ret_marshal_info
);
985 char *estype
= get_escaped_name (type
);
986 g_string_append_printf (result_ret
, "%s::", estype
);
990 esname
= get_escaped_name (method_name
);
991 g_string_append (result_ret
, esname
);
994 g_string_append (result_ret
, gen_param
);
997 g_string_append (result_ret
, " (");
1000 g_string_prepend (result
, result_ret
->str
);
1001 g_string_free (result_ret
, FALSE
);
1003 if (show_method_tokens
&& methoddef_row
)
1004 g_string_append_printf (result
, " /* 0x%X */ ",
1005 (methoddef_row
>> MONO_TYPEORMETHOD_BITS
) | MONO_TOKEN_METHOD_DEF
);
1008 mono_metadata_free_method_signature (method
);
1009 retval
= result
->str
;
1010 g_string_free (result
, FALSE
);
1016 dis_stringify_function_ptr (MonoImage
*m
, MonoMethodSignature
*method
)
1019 GString
*result
= g_string_new ("");
1024 g_string_append (result
, map (method
->call_convention
, call_conv_type_map
));
1026 retval
= dis_stringify_param (m
, method
->ret
);
1027 g_string_append_printf (result
, " %s ", retval
);
1030 g_string_append (result
, " *(");
1031 for (i
= 0; i
< method
->param_count
; ++i
) {
1033 g_string_append (result
, ", ");
1034 retval
= dis_stringify_param (m
, method
->params
[i
]);
1035 g_string_append (result
, retval
);
1038 g_string_append (result
, ") ");
1040 retval
= result
->str
;
1041 g_string_free (result
, FALSE
);
1047 get_escaped_class_name (MonoClass
*c
)
1049 char *result
, *esname
;
1051 if (c
->type_token
== mono_metadata_make_token (MONO_TABLE_TYPEDEF
, 1))
1055 if (c
->rank
|| c
->byval_arg
.type
== MONO_TYPE_PTR
)
1058 esname
= get_escaped_name (c
->name
);
1061 char *part_a
= get_escaped_class_name (c
->nested_in
);
1063 result
= g_strdup_printf ("%s/%s", part_a
, esname
);
1065 } else if (*c
->name_space
)
1066 result
= g_strdup_printf ("%s.%s", c
->name_space
, esname
);
1068 result
= g_strdup (esname
);
1075 dis_stringify_object_with_class (MonoImage
*m
, MonoClass
*c
, gboolean prefix
, gboolean is_def
)
1077 /* FIXME: handle MONO_TYPE_OBJECT ... */
1078 MonoType
*type
= &c
->byval_arg
;
1079 const char *otype
= type
->type
== MONO_TYPE_VALUETYPE
? "valuetype " : "class " ;
1080 char *assemblyref
= NULL
, *result
, *esname
, *generic
= NULL
;
1082 if (c
->type_token
== mono_metadata_make_token (MONO_TABLE_TYPEDEF
, 1))
1086 if (m
!= c
->image
) {
1087 if (c
->image
->assembly_name
) {
1089 if (substitute_with_mscorlib_p
&& !strcmp ("corlib", c
->image
->assembly_name
))
1090 assemblyref
= g_strdup_printf ("[%s]", "mscorlib");
1092 char *esc
= get_escaped_name (c
->image
->assembly
->aname
.name
);
1094 assemblyref
= g_strdup_printf ("[%s]", esc
);
1098 assemblyref
= g_strdup_printf ("[.module %s]", c
->image
->module_name
);
1102 esname
= get_escaped_class_name (c
);
1104 if (c
->generic_class
) {
1105 MonoGenericClass
*gclass
= c
->generic_class
;
1106 MonoGenericInst
*inst
= gclass
->context
.class_inst
;
1107 GString
*str
= g_string_new ("");
1110 for (i
= 0; i
< inst
->type_argc
; i
++){
1111 char *t
= dis_stringify_type (m
, inst
->type_argv
[i
], is_def
);
1113 g_string_append (str
, t
);
1114 if (i
+1 != inst
->type_argc
)
1115 g_string_append (str
, ", ");
1118 generic
= g_strdup_printf ("<%s>", str
->str
);
1119 g_string_free (str
, TRUE
);
1123 result
= g_strdup_printf ("%s%s%s%s", prefix
? otype
: "", assemblyref
?assemblyref
:"",
1124 esname
, generic
?generic
:"");
1127 g_free (assemblyref
);
1134 dis_stringify_object (MonoImage
*m
, MonoType
*type
, gboolean is_def
)
1136 MonoClass
*c
= mono_class_from_mono_type (type
);
1137 return dis_stringify_object_with_class (m
, c
, TRUE
, is_def
);
1141 dis_stringify_type (MonoImage
*m
, MonoType
*type
, gboolean is_def
)
1143 const char *pinned
= "", *byref
= "";
1144 char *bare
= NULL
, *mods
= NULL
;
1148 mods
= dis_stringify_modifiers (m
, type
->num_mods
, type
->modifiers
);
1150 switch (type
->type
){
1151 case MONO_TYPE_BOOLEAN
:
1152 case MONO_TYPE_CHAR
:
1165 case MONO_TYPE_STRING
:
1166 case MONO_TYPE_OBJECT
:
1167 case MONO_TYPE_TYPEDBYREF
:
1168 bare
= g_strdup (map (type
->type
, element_type_map
));
1171 case MONO_TYPE_VALUETYPE
:
1172 case MONO_TYPE_CLASS
:
1173 bare
= dis_stringify_object (m
, type
, is_def
);
1175 case MONO_TYPE_FNPTR
: {
1177 child_type
= dis_stringify_function_ptr (m
, type
->data
.method
);
1178 bare
= g_strdup_printf ("method %s", child_type
);
1179 g_free (child_type
);
1182 case MONO_TYPE_PTR
: {
1184 child_type
= dis_stringify_type (m
, type
->data
.type
, is_def
);
1186 bare
= g_strdup_printf ("%s*", child_type
);
1187 g_free (child_type
);
1190 case MONO_TYPE_SZARRAY
: {
1192 child_type
= dis_stringify_type (m
, &type
->data
.klass
->byval_arg
, is_def
);
1194 bare
= g_strdup_printf ("%s[]", child_type
);
1195 g_free (child_type
);
1198 case MONO_TYPE_ARRAY
:
1199 bare
= dis_stringify_array (m
, type
->data
.array
, is_def
);
1201 case MONO_TYPE_VOID
:
1202 bare
= g_strdup ("void");
1204 case MONO_TYPE_MVAR
:
1205 if (is_def
&& !cant_print_generic_param_name (type
->data
.generic_param
))
1206 bare
= g_strdup_printf ("!!%s", get_escaped_name (mono_generic_param_info (type
->data
.generic_param
)->name
));
1208 bare
= g_strdup_printf ("!!%d", mono_type_get_generic_param_num (type
));
1211 if (is_def
&& !cant_print_generic_param_name (type
->data
.generic_param
))
1212 bare
= g_strdup_printf ("!%s", get_escaped_name (mono_generic_param_info (type
->data
.generic_param
)->name
));
1214 bare
= g_strdup_printf ("!%d", mono_type_get_generic_param_num (type
));
1216 case MONO_TYPE_GENERICINST
: {
1217 GString
*str
= g_string_new ("");
1218 MonoGenericInst
*inst
;
1220 char *generic_type
= dis_stringify_type (
1221 m
, &type
->data
.generic_class
->container_class
->byval_arg
, is_def
);
1222 inst
= type
->data
.generic_class
->context
.class_inst
;
1223 for (i
= 0; i
< inst
->type_argc
; i
++){
1224 char *t
= dis_stringify_type (m
, inst
->type_argv
[i
], is_def
);
1226 g_string_append (str
, t
);
1227 if (i
+1 != inst
->type_argc
)
1228 g_string_append (str
, ", ");
1231 bare
= g_strdup_printf ("%s<%s>", generic_type
, str
->str
);
1232 g_string_free (str
, TRUE
);
1237 g_error ("Do not know how to stringify type 0x%x", type
->type
);
1247 /* bare is NULL, for <Module> */
1250 result
= g_strconcat (bare
, byref
, pinned
, mods
? mods
: "", NULL
);
1259 * @m: metadata context
1260 * @ptr: location to decode from.
1261 * @result: pointer to string where resulting decoded string is stored
1263 * This routine returs in @result the stringified type pointed by @ptr.
1266 * Returns: the new ptr to continue decoding
1269 get_type (MonoImage
*m
, const char *ptr
, char **result
, gboolean is_def
, MonoGenericContainer
*container
)
1271 const char *start
= ptr
;
1275 if (*ptr
== MONO_TYPE_BYREF
)
1278 type
= mono_metadata_decode_value (ptr
, &ptr
);
1281 case MONO_TYPE_VALUETYPE
:
1282 case MONO_TYPE_CLASS
: {
1283 guint32 token
= mono_metadata_parse_typedef_or_ref (m
, ptr
, &ptr
);
1284 MonoClass
*klass
= mono_class_get (m
, token
);
1287 temp
= dis_stringify_object_with_class (m
, klass
, TRUE
, FALSE
);
1289 temp
= g_strdup_printf ("<BROKEN CLASS token_%8x>", token
);
1292 *result
= g_strdup_printf ("%s/*%08x*/", temp
, token
);
1299 case MONO_TYPE_GENERICINST
: {
1300 GString
*str
= g_string_new ("");
1304 ptr
= get_type (m
, ptr
, &temp
, is_def
, container
);
1305 g_string_append (str
, temp
);
1308 count
= mono_metadata_decode_value (ptr
, &ptr
);
1309 g_string_append (str
, "<");
1311 for (i
= 0; i
< count
; i
++) {
1313 g_string_append (str
, ",");
1314 ptr
= get_type (m
, ptr
, &temp
, is_def
, container
);
1315 g_string_append (str
, temp
);
1318 g_string_append (str
, ">");
1320 g_string_free (str
, FALSE
);
1325 t
= mono_metadata_parse_type_full (m
, container
, 0, start
, &ptr
);
1327 *result
= dis_stringify_type (m
, t
, is_def
);
1329 GString
*err
= g_string_new ("@!#$<InvalidType>$#!@");
1331 t
= mono_metadata_parse_type_full (m
, NULL
, 0, start
, &ptr
);
1333 char *name
= dis_stringify_type (m
, t
, is_def
);
1334 g_warning ("Encountered a generic type inappropriate for its context");
1335 g_string_append (err
, " // ");
1336 g_string_append (err
, name
);
1339 g_warning ("Encountered an invalid type");
1341 *result
= g_string_free (err
, FALSE
);
1352 * Returns a stringified representation of a FieldSig (22.2.4)
1355 get_field_signature (MonoImage
*m
, guint32 blob_signature
, MonoGenericContainer
*container
)
1357 char *allocated_modifier_string
, *allocated_type_string
;
1358 const char *ptr
= mono_metadata_blob_heap (m
, blob_signature
);
1362 len
= mono_metadata_decode_value (ptr
, &ptr
);
1364 g_assert (*ptr
== 0x06);
1365 /* hex_dump (ptr, 0, len); */
1368 ptr
= get_custom_mod (m
, ptr
, &allocated_modifier_string
);
1369 ptr
= get_type (m
, ptr
, &allocated_type_string
, FALSE
, container
);
1371 res
= g_strdup_printf (
1373 allocated_type_string
,
1374 allocated_modifier_string
? allocated_modifier_string
: "");
1376 if (allocated_modifier_string
)
1377 g_free (allocated_modifier_string
);
1378 if (allocated_type_string
)
1379 g_free (allocated_type_string
);
1385 get_field_literal_type (MonoImage
*m
, guint32 blob_signature
)
1387 const char *ptr
= mono_metadata_blob_heap (m
, blob_signature
);
1389 char *allocated_modifier_string
;
1391 len
= mono_metadata_decode_value (ptr
, &ptr
);
1394 g_assert (*ptr
== 0x06);
1397 ptr
= get_custom_mod (m
, ptr
, &allocated_modifier_string
);
1398 if (allocated_modifier_string
)
1399 g_free (allocated_modifier_string
);
1401 return (MonoTypeEnum
) *ptr
;
1407 * @m: metadata context
1408 * @token: token to decode
1410 * decodes the literal indexed by @token.
1413 decode_literal (MonoImage
*m
, guint32 token
)
1415 return g_strdup ("LITERAL_VALUE");
1420 * @m: metadata context
1421 * @ptr: location to decode from.
1422 * @result: pointer to string where resulting decoded string is stored
1424 * This routine returns in @result the stringified RetType (22.2.11)
1426 * Returns: the new ptr to continue decoding.
1429 get_ret_type (MonoImage
*m
, const char *ptr
, char **ret_type
, MonoGenericContainer
*container
)
1431 GString
*str
= g_string_new ("");
1433 char *allocated_type_string
;
1436 ptr
= get_custom_mod (m
, ptr
, &mod
);
1438 if (*ptr
== MONO_TYPE_TYPEDBYREF
){
1439 g_string_append (str
, "typedref");
1441 } else if (*ptr
== MONO_TYPE_VOID
){
1442 g_string_append (str
, "void");
1445 if (*ptr
== MONO_TYPE_BYREF
){
1450 ptr
= get_type (m
, ptr
, &allocated_type_string
, FALSE
, container
);
1451 g_string_append (str
, allocated_type_string
);
1453 g_string_append (str
, "& ");
1454 g_free (allocated_type_string
);
1458 g_string_append (str
, mod
);
1459 g_string_append_c (str
, ' ');
1463 *ret_type
= str
->str
;
1464 g_string_free (str
, FALSE
);
1471 * @m: metadata context
1472 * @ptr: location to decode from.
1473 * @result: pointer to string where resulting decoded string is stored
1475 * This routine returns in @result the stringified Param (22.2.10)
1477 * Returns: the new ptr to continue decoding.
1480 get_param (MonoImage
*m
, const char *ptr
, char **retval
, MonoGenericContainer
*container
)
1482 GString
*str
= g_string_new ("");
1483 char *allocated_mod_string
, *allocated_type_string
;
1485 ptr
= get_custom_mod (m
, ptr
, &allocated_mod_string
);
1487 if (*ptr
== MONO_TYPE_TYPEDBYREF
){
1488 g_string_append (str
, " typedref ");
1491 gboolean by_ref
= 0;
1492 if (*ptr
== MONO_TYPE_BYREF
){
1493 g_string_append (str
, "[out] ");
1497 ptr
= get_type (m
, ptr
, &allocated_type_string
, FALSE
, container
);
1498 g_string_append (str
, allocated_type_string
);
1500 g_string_append_c (str
, '&');
1501 g_free (allocated_type_string
);
1504 if (allocated_mod_string
){
1505 g_string_append (str
, allocated_mod_string
);
1506 g_string_append_c (str
, ' ');
1507 g_free (allocated_mod_string
);
1511 g_string_free (str
, FALSE
);
1518 * @str: string to process
1519 * @list: list of chars to escape
1521 * Returns: an allocated escaped string.
1524 str_escape (const char *str
, const char *list
)
1526 const char *p
= str
;
1529 res
= g_string_sized_new (strlen (str
));
1532 while (*p
&& !strchr (list
, *p
))
1534 g_string_append_len (res
, str
, p
- str
);
1537 g_string_append_c (res
, '\\');
1542 return g_string_free (res
, FALSE
);
1548 * Returns: An allocated escaped name. A name needs to be escaped
1549 * because it might be an ilasm keyword.
1552 get_escaped_name (const char *name
)
1560 g_assert (key_table
);
1562 if (strlen (name
) == 0)
1563 return g_strdup (name
);
1565 for (s
= name
; *s
; s
++) {
1566 char *first
, *result
;
1571 first
= g_strndup (name
, s
-name
);
1572 result
= g_strdup_printf ("%s/%s", get_escaped_name (first
), get_escaped_name (s
+1));
1578 for (s
= name
; *s
; s
++) {
1579 if (isalnum (*s
) || *s
== '_' || *s
== '$' || *s
== '@' ||
1580 *s
== '?' || (*s
== '.' && s
!= name
) || *s
== 0 || *s
== '!' || *s
== '`')
1583 esc
= str_escape (name
, "'\\");
1584 ret
= g_strdup_printf ("'%s'", esc
);
1589 if (g_hash_table_lookup (key_table
, name
))
1590 return g_strdup_printf ("'%s'", name
);
1592 return str_escape (name
, "'\\");
1595 static dis_map_t param_map
[] = {
1596 { PARAM_ATTRIBUTE_IN
, "[in] " },
1597 { PARAM_ATTRIBUTE_OUT
, "[out] " },
1598 { PARAM_ATTRIBUTE_OPTIONAL
, "optional " },
1599 { PARAM_ATTRIBUTE_HAS_DEFAULT
, "hasdefault " },
1600 { PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL
, "fieldmarshal " },
1605 param_flags (guint32 f
)
1607 return g_strdup (flags (f
, param_map
));
1610 static dis_map_t field_access_map
[] = {
1611 { FIELD_ATTRIBUTE_COMPILER_CONTROLLED
, "privatescope " },
1612 { FIELD_ATTRIBUTE_PRIVATE
, "private " },
1613 { FIELD_ATTRIBUTE_FAM_AND_ASSEM
, "famandassem " },
1614 { FIELD_ATTRIBUTE_ASSEMBLY
, "assembly " },
1615 { FIELD_ATTRIBUTE_FAMILY
, "family " },
1616 { FIELD_ATTRIBUTE_FAM_OR_ASSEM
, "famorassem " },
1617 { FIELD_ATTRIBUTE_PUBLIC
, "public " },
1621 static dis_map_t field_flags_map
[] = {
1622 { FIELD_ATTRIBUTE_STATIC
, "static " },
1623 { FIELD_ATTRIBUTE_INIT_ONLY
, "initonly " },
1624 { FIELD_ATTRIBUTE_LITERAL
, "literal " },
1625 { FIELD_ATTRIBUTE_NOT_SERIALIZED
, "notserialized " },
1626 { FIELD_ATTRIBUTE_SPECIAL_NAME
, "specialname " },
1627 { FIELD_ATTRIBUTE_PINVOKE_IMPL
, "FIXME:pinvokeimpl " },
1628 { FIELD_ATTRIBUTE_RT_SPECIAL_NAME
, "rtspecialname " },
1630 /* This is set when a MarshalAs attribute is seen. FIXME: round-trip? */
1631 { FIELD_ATTRIBUTE_HAS_FIELD_MARSHAL
, "" },
1633 /* This seems to be set if LITERAL is set. FIXME: round-trip? */
1634 { FIELD_ATTRIBUTE_HAS_DEFAULT
, "" },
1636 /* This seems to be set on compiler-generated array initializer fields. FIXME: round-trip? */
1637 { FIELD_ATTRIBUTE_HAS_FIELD_RVA
, "" },
1644 * Returns a stringified version of a Field's flags
1647 field_flags (guint32 f
)
1650 int access
= f
& FIELD_ATTRIBUTE_FIELD_ACCESS_MASK
;
1651 int rest
= f
& ~access
;
1655 strcat (buffer
, map (access
, field_access_map
));
1656 strcat (buffer
, flags (rest
, field_flags_map
));
1657 return g_strdup (buffer
);
1661 * Returns a stringifed representation of a MethodRefSig (22.2.2)
1664 get_methodref_signature (MonoImage
*m
, guint32 blob_signature
, const char *fancy_name
)
1666 GString
*res
= g_string_new ("");
1667 const char *ptr
= mono_metadata_blob_heap (m
, blob_signature
);
1668 char *allocated_ret_type
, *s
;
1669 const char *cconv_str
;
1670 gboolean seen_vararg
= 0;
1672 int i
, gen_count
= 0;
1675 /* signature_len = */ mono_metadata_decode_value (ptr
, &ptr
);
1679 g_string_append (res
, "explicit-this ");
1681 g_string_append (res
, "instance "); /* has-this */
1686 cconv
= *ptr
& 0x0f;
1687 cconv_str
= map (cconv
, call_conv_type_map
);
1688 if (strcmp (cconv_str
, "default") != 0) {
1689 g_string_append (res
, cconv_str
);
1690 g_string_append (res
, " ");
1695 gen_count
= mono_metadata_decode_value (ptr
, &ptr
);
1696 param_count
= mono_metadata_decode_value (ptr
, &ptr
);
1698 ptr
= get_ret_type (m
, ptr
, &allocated_ret_type
, NULL
);
1699 g_string_append (res
, allocated_ret_type
);
1700 g_free (allocated_ret_type
);
1704 g_string_append_c (res
, ' ');
1705 g_string_append (res
, fancy_name
);
1708 g_string_append (res
, "(");
1711 * param_count describes parameters *before* and *after*
1712 * the vararg sentinel
1714 for (i
= 0; i
< param_count
; i
++){
1718 * If ptr is a SENTINEL
1722 g_string_append (res
, "..., ");
1729 ptr
= get_param (m
, ptr
, ¶m
, NULL
);
1730 g_string_append (res
, param
);
1731 if (i
+1 != param_count
)
1732 g_string_append (res
, ", ");
1735 g_string_append (res
, ")");
1738 * cleanup and return
1741 g_string_free (res
, FALSE
);
1746 * Returns a stringifed representation of a field ref
1749 get_fieldref_signature (MonoImage
*m
, int idx
, MonoGenericContainer
*container
)
1751 guint32 cols
[MONO_MEMBERREF_SIZE
];
1752 MonoGenericContainer
*new_container
;
1753 char *type
, *esname
;
1757 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MEMBERREF
],
1758 idx
- 1, cols
, MONO_MEMBERREF_SIZE
);
1760 new_container
= get_memberref_container (m
, cols
[MONO_MEMBERREF_CLASS
], container
);
1761 sig
= get_field_signature (m
, cols
[MONO_MEMBERREF_SIGNATURE
], new_container
);
1763 type
= get_memberref_parent (m
, cols
[MONO_MEMBERREF_CLASS
], container
);
1764 esname
= get_escaped_name (mono_metadata_string_heap (m
, cols
[MONO_MEMBERREF_NAME
]));
1766 full_sig
= g_strdup_printf ("%s %s%s%s",
1780 * @m: metadata context
1781 * @token: a FIELD_DEF token
1783 * This routine has to locate the TypeDef that "owns" this Field.
1784 * Since there is no backpointer in the Field table, we have to scan
1785 * the TypeDef table and locate the actual "owner" of the field
1788 get_field (MonoImage
*m
, guint32 token
, MonoGenericContainer
*container
)
1790 int idx
= mono_metadata_token_index (token
);
1791 guint32 cols
[MONO_FIELD_SIZE
];
1792 char *sig
, *res
, *type
, *estype
, *esname
;
1796 * We can get here also with a MenberRef token (for a field
1797 * defined in another module/assembly, just like in get_method ()
1799 if (mono_metadata_token_code (token
) == MONO_TOKEN_MEMBER_REF
) {
1800 return get_fieldref_signature (m
, idx
, container
);
1802 g_assert (mono_metadata_token_code (token
) == MONO_TOKEN_FIELD_DEF
);
1804 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_FIELD
], idx
- 1, cols
, MONO_FIELD_SIZE
);
1805 sig
= get_field_signature (m
, cols
[MONO_FIELD_SIGNATURE
], container
);
1808 * To locate the actual "container" for this field, we have to scan
1809 * the TypeDef table. LAME!
1811 type_idx
= mono_metadata_typedef_from_field (m
, idx
);
1813 res
= g_strdup_printf ("<invalid> %s", sig
);
1818 type
= get_typedef (m
, type_idx
);
1819 estype
= get_escaped_name (type
);
1820 esname
= get_escaped_name (mono_metadata_string_heap (m
, cols
[MONO_FIELD_NAME
]));
1821 res
= g_strdup_printf ("%s %s%s%s",
1823 estype
? estype
: "",
1835 static MonoGenericContainer
*
1836 get_memberref_container (MonoImage
*m
, guint32 mrp_token
, MonoGenericContainer
*container
)
1841 * mrp_index is a MemberRefParent coded index
1843 guint32 table
= mrp_token
& 7;
1844 guint32 idx
= mrp_token
>> 3;
1847 case 0: /* TypeDef */
1848 return mono_metadata_load_generic_params (m
, MONO_TOKEN_TYPE_DEF
| idx
, NULL
);
1850 case 1: /* TypeRef */
1853 case 4: /* TypeSpec */
1854 klass
= mono_class_get_full (m
, MONO_TOKEN_TYPE_SPEC
| idx
, (MonoGenericContext
*) container
);
1856 return klass
->generic_class
? klass
->generic_class
->container_class
->generic_container
: NULL
;
1858 g_assert_not_reached ();
1863 get_memberref_parent (MonoImage
*m
, guint32 mrp_token
, MonoGenericContainer
*container
)
1866 * mrp_index is a MemberRefParent coded index
1868 guint32 table
= mrp_token
& 7;
1869 guint32 idx
= mrp_token
>> 3;
1872 case 0: /* TypeDef */
1873 return get_typedef (m
, idx
);
1875 case 1: /* TypeRef */
1876 return get_typeref (m
, idx
);
1878 case 2: /* ModuleRef */
1879 return g_strdup_printf ("TODO:MemberRefParent-ModuleRef");
1881 case 3: /* MethodDef */
1882 return g_strdup ("TODO:MethodDef");
1884 case 4: /* TypeSpec */
1885 return get_typespec (m
, idx
, FALSE
, container
);
1887 g_assert_not_reached ();
1893 * @m: metadata context
1894 * @token: a METHOD_DEF or MEMBER_REF token
1896 * This routine has to locate the TypeDef that "owns" this Field.
1897 * Since there is no backpointer in the Field table, we have to scan
1898 * the TypeDef table and locate the actual "owner" of the field
1901 get_method_core (MonoImage
*m
, guint32 token
, gboolean fullsig
, MonoGenericContainer
*container
)
1903 int idx
= mono_metadata_token_index (token
);
1904 guint32 member_cols
[MONO_MEMBERREF_SIZE
], method_cols
[MONO_METHOD_SIZE
];
1905 char *sig
= NULL
, *esname
;
1909 MonoGenericContainer
*type_container
= container
;
1911 mh
= mono_get_method_full (m
, token
, NULL
, (MonoGenericContext
*) container
);
1913 if (mono_method_signature (mh
)->is_inflated
)
1914 container
= mono_method_get_generic_container (((MonoMethodInflated
*) mh
)->declaring
);
1915 esname
= get_escaped_name (mh
->name
);
1916 sig
= dis_stringify_type (m
, &mh
->klass
->byval_arg
, TRUE
);
1918 name
= g_strdup_printf ("%s/*%08x*/%s%s", sig
? sig
: "", token
, sig
? "::" : "", esname
);
1920 name
= g_strdup_printf ("%s%s%s", sig
? sig
: "", sig
? "::" : "", esname
);
1926 switch (mono_metadata_token_code (token
)){
1927 case MONO_TOKEN_METHOD_DEF
:
1928 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHOD
],
1929 idx
- 1, method_cols
, MONO_METHOD_SIZE
);
1931 sig
= get_methodref_signature (m
, method_cols
[MONO_METHOD_SIGNATURE
], name
);
1934 case MONO_TOKEN_MEMBER_REF
: {
1935 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MEMBERREF
],
1936 idx
- 1, member_cols
, MONO_MEMBERREF_SIZE
);
1938 char *parent
= get_memberref_parent (m
, member_cols
[MONO_MEMBERREF_CLASS
], container
);
1939 name
= g_strdup_printf ("%s%s%s",
1940 parent
? parent
: "",
1942 mono_metadata_string_heap (m
, member_cols
[MONO_MEMBERREF_NAME
]));
1949 arity
= mono_method_get_generic_container (mh
)->type_argc
;
1951 if (mh
->is_inflated
&& ((MonoMethodInflated
*)mh
)->declaring
->is_generic
)
1952 arity
= mono_method_get_generic_container (((MonoMethodInflated
*) mh
)->declaring
)->type_argc
;
1955 char *str
= g_strdup_printf ("%s <[%d]>", name
, arity
);
1961 sig
= get_methodref_signature (
1962 m
, member_cols
[MONO_MEMBERREF_SIGNATURE
], name
);
1965 case MONO_TOKEN_METHOD_SPEC
: {
1966 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHODSPEC
],
1967 idx
- 1, member_cols
, MONO_METHODSPEC_SIZE
);
1968 token
= member_cols
[MONO_METHODSPEC_METHOD
];
1969 sig
= get_methodspec (m
, idx
, token
, name
, type_container
);
1974 g_assert_not_reached ();
1985 char *retval
= g_strdup_printf ("%s /* %08x */", sig
, token
);
1993 get_method (MonoImage
*m
, guint32 token
, MonoGenericContainer
*container
)
1995 return get_method_core (m
, token
, TRUE
, container
);
2000 * @m: metadata context
2001 * @idx: index into the method table
2003 * Returns: A stringified version of the method signature.
2006 get_methoddef (MonoImage
*m
, guint32 idx
)
2008 guint32 cols
[MONO_METHOD_SIZE
];
2014 mh
= mono_get_method (m
, MONO_TOKEN_METHOD_DEF
| idx
, NULL
);
2016 sig
= dis_stringify_type (m
, &mh
->klass
->byval_arg
, FALSE
);
2017 name
= g_strdup_printf ("%s%s%s",
2024 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHOD
],
2025 idx
- 1, cols
, MONO_METHOD_SIZE
);
2026 sig
= get_methodref_signature (m
, cols
[MONO_METHOD_SIGNATURE
], name
);
2032 get_method_type_param (MonoImage
*m
, guint32 blob_signature
, MonoGenericContainer
*container
)
2034 GString
*res
= g_string_new ("");
2035 const char *ptr
= mono_metadata_blob_heap (m
, blob_signature
);
2040 mono_metadata_decode_value (ptr
, &ptr
);
2042 param_count
= mono_metadata_decode_value (ptr
, &ptr
);
2044 g_string_append_c (res
, '<');
2046 for (i
= 0; i
< param_count
; i
++){
2049 ptr
= get_param (m
, ptr
, ¶m
, container
);
2050 g_string_append (res
, param
);
2051 if (i
+1 != param_count
)
2052 g_string_append (res
, ", ");
2055 g_string_append_c (res
, '>');
2058 g_string_free (res
, FALSE
);
2065 * Returns: An allocated stringified version of the methodspec signature.
2069 get_methodspec (MonoImage
*m
, int idx
, guint32 token
, const char *fancy_name
, MonoGenericContainer
*type_container
)
2071 GString
*res
= g_string_new ("");
2072 guint32 member_cols
[MONO_MEMBERREF_SIZE
], method_cols
[MONO_METHOD_SIZE
];
2073 char *s
, *type_param
;
2076 int param_count
, cconv
, i
, gen_count
= 0;
2077 MonoGenericContainer
*container
;
2078 MonoMethod
*mh
= NULL
;
2080 switch (token
& MONO_METHODDEFORREF_MASK
) {
2081 case MONO_METHODDEFORREF_METHODDEF
:
2082 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHOD
],
2083 (token
>> MONO_METHODDEFORREF_BITS
) - 1,
2084 method_cols
, MONO_METHOD_SIZE
);
2085 sig
= method_cols
[MONO_METHOD_SIGNATURE
];
2087 case MONO_METHODDEFORREF_METHODREF
:
2088 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MEMBERREF
],
2089 (token
>> MONO_METHODDEFORREF_BITS
) - 1,
2090 member_cols
, MONO_MEMBERREF_SIZE
);
2091 sig
= member_cols
[MONO_MEMBERREF_SIGNATURE
];
2094 g_assert_not_reached ();
2097 ptr
= mono_metadata_blob_heap (m
, sig
);
2098 mono_metadata_decode_value (ptr
, &ptr
);
2100 mh
= mono_get_method_full (m
, method_dor_to_token (token
), NULL
, (MonoGenericContext
*) type_container
);
2102 container
= mono_method_get_generic_container (mh
);
2104 container
= type_container
;
2108 g_string_append (res
, "explicit-this ");
2110 g_string_append (res
, "instance "); /* has-this */
2115 cconv
= *ptr
& 0x0f;
2118 gen_count
= mono_metadata_decode_value (ptr
, &ptr
);
2119 param_count
= mono_metadata_decode_value (ptr
, &ptr
);
2121 char *allocated_ret_type
;
2122 ptr
= get_ret_type (m
, ptr
, &allocated_ret_type
, container
);
2123 g_string_append (res
, allocated_ret_type
);
2124 g_free (allocated_ret_type
);
2128 g_string_append_c (res
, ' ');
2129 g_string_append (res
, fancy_name
);
2132 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHODSPEC
],
2133 idx
- 1, member_cols
, MONO_METHODSPEC_SIZE
);
2134 token
= member_cols
[MONO_METHODSPEC_SIGNATURE
];
2135 type_param
= get_method_type_param (m
, token
, type_container
);
2136 g_string_append (res
, type_param
);
2137 g_string_append (res
, " (");
2140 * methodspecs can not be varargs so we don't need to worry about that here
2143 for (i
= 0; i
< param_count
; i
++){
2146 ptr
= get_param (m
, ptr
, ¶m
, container
);
2147 g_string_append (res
, param
);
2148 if (i
+1 != param_count
)
2149 g_string_append (res
, ", ");
2152 g_string_append (res
, ")");
2155 * cleanup and return
2158 g_string_free (res
, FALSE
);
2163 * get_encoded_user_string_bytearray:
2164 * @ptr: pointer into the US heap
2165 * @len: length of string in the heap.
2167 * Strings on the US heap are encoded using UTF-16. Print a bytearray.
2170 get_encoded_user_string_bytearray (const unsigned char* ptr
, int len
)
2173 int i
, j
, tspaces
= (len
% 16);
2177 return g_strdup_printf ("\"\"");
2179 res
= g_string_new ("bytearray (\n\t");
2181 for (i
= 1; i
<= len
; ++i
) {
2182 g_string_append_printf (res
, "%02x ", ptr
[i
-1]);
2186 g_string_append (res
, ")// ");
2188 g_string_append (res
, " // ");
2190 for(j
= i
- 16; j
< i
; ++j
)
2191 g_string_append_printf (res
, "%c", isprint (ptr
[j
]) ? ptr
[j
] : '.');
2192 g_string_append (res
, "\n\t");
2197 g_string_append (res
, ") ");
2198 for (i
= tspaces
+ 1; i
< 16; ++i
)
2199 g_string_append_printf (res
, " ");
2201 g_string_append (res
, " // ");
2202 for(i
= len
- tspaces
; i
< len
; ++i
)
2203 g_string_append_printf (res
, "%c", isprint (ptr
[i
]) ? ptr
[i
] : '.');
2204 g_string_append (res
, "\n\t");
2208 g_string_free (res
, FALSE
);
2213 * get_encoded_user_string_or_bytearray:
2214 * @ptr: pointer into the US heap
2216 * Strings on the US heap are encoded using UTF-16. Print as string
2217 * if possible, else emit a bytearray.
2220 get_encoded_user_string_or_bytearray (const unsigned char *ptr
, int len
)
2222 char *res
, *eres
, *result
;
2225 res
= g_malloc ((len
>> 1) + 1);
2228 * I should really use some kind of libunicode here
2230 for (i
= 0; i
+ 1 < len
; i
+= 2) {
2232 (!isprint (ptr
[i
]) && ptr
[i
] != '\\' && ptr
[i
] != '"' &&
2233 ptr
[i
] != '\r' && ptr
[i
] != '\n' && ptr
[i
] != '\t')) {
2235 return get_encoded_user_string_bytearray (ptr
, len
);
2238 res
[i
>> 1] = ptr
[i
];
2243 eres
= g_strescape (res
, NULL
);
2244 result
= g_strdup_printf ("\"%s\"", eres
);
2252 stringify_double (double r
)
2256 ret
= g_strdup_printf ("%.17g.", r
);
2257 ptr
= ret
+ strlen (ret
) - 1;
2258 if (strpbrk (ret
, ".eE") != ptr
)
2266 * @m: metadata context
2267 * @blob_index: index into the blob where the constant is stored
2269 * Returns: An allocated value representing a stringified version of the
2273 get_constant (MonoImage
*m
, MonoTypeEnum t
, guint32 blob_index
)
2275 const char *ptr
= mono_metadata_blob_heap (m
, blob_index
);
2278 len
= mono_metadata_decode_value (ptr
, &ptr
);
2281 case MONO_TYPE_BOOLEAN
:
2282 return g_strdup_printf ("%s", *ptr
? "bool(true)" : "bool(false)");
2284 case MONO_TYPE_CHAR
:
2285 return g_strdup_printf ("char(0x%04x)", read16(ptr
));
2289 return g_strdup_printf ("int8(0x%02x)", (int) ((*ptr
) & 0xFF));
2294 return g_strdup_printf ("int16(0x%08x)", (int) read16 (ptr
));
2298 return g_strdup_printf ("int32(0x%08x)", read32 (ptr
));
2301 case MONO_TYPE_I8
: {
2304 high
= read32 (ptr
+ 4);
2305 return g_strdup_printf ("int64(0x%08x%08x)", high
, low
);
2307 case MONO_TYPE_R4
: {
2312 /* Crazy solaris systems doesn't have isnormal */
2313 #ifdef HAVE_ISFINITE
2314 normal
= isfinite (r
);
2316 normal
= !dis_isinf (r
) && !dis_isnan (r
);
2319 return g_strdup_printf ("float32(0x%08x)", read32 (ptr
));
2321 char *str
= stringify_double ((double) r
);
2322 char *ret
= g_strdup_printf ("float32(%s)", str
);
2327 case MONO_TYPE_R8
: {
2332 /* Crazy solaris systems doesn't have isnormal */
2333 #ifdef HAVE_ISFINITE
2334 normal
= isfinite (r
);
2336 normal
= isnormal (r
);
2341 high
= read32 (ptr
+ 4);
2342 return g_strdup_printf ("float64(0x%08x%08x)", high
, low
);
2344 char *str
= stringify_double (r
);
2345 char *ret
= g_strdup_printf ("float64(%s)", str
);
2350 case MONO_TYPE_STRING
:
2351 return get_encoded_user_string_or_bytearray ((const guchar
*)ptr
, len
);
2353 case MONO_TYPE_CLASS
:
2354 return g_strdup ("nullref");
2357 g_error ("Unknown MONO_TYPE (%d) on constant at Blob index (0x%08x)\n",
2358 (int) *ptr
, blob_index
);
2359 return g_strdup_printf ("Unknown");
2366 * @m: metadata context
2367 * @token: token that we want to decode.
2369 * Returns: An allocated value representing a stringified version of the
2373 get_token (MonoImage
*m
, guint32 token
, MonoGenericContainer
*container
)
2375 char *temp
, *result
;
2376 guint32 idx
= mono_metadata_token_index (token
);
2378 switch (mono_metadata_token_code (token
)){
2379 case MONO_TOKEN_FIELD_DEF
:
2380 temp
= get_field (m
, token
, container
);
2381 result
= g_strdup_printf ("field %s", temp
);
2384 case MONO_TOKEN_METHOD_DEF
:
2385 case MONO_TOKEN_METHOD_SPEC
:
2386 temp
= get_method (m
, token
, container
);
2387 result
= g_strdup_printf ("method %s", temp
);
2390 case MONO_TOKEN_TYPE_DEF
:
2391 temp
= get_typedef (m
, idx
);
2392 result
= get_escaped_name (temp
);
2395 case MONO_TOKEN_TYPE_REF
:
2396 return get_typeref (m
, idx
);
2397 case MONO_TOKEN_TYPE_SPEC
:
2398 return get_typespec (m
, idx
, TRUE
, container
);
2399 case MONO_TOKEN_MEMBER_REF
: {
2400 guint32 cols
[MONO_MEMBERREF_SIZE
];
2402 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MEMBERREF
], mono_metadata_token_index (token
) - 1, cols
, MONO_MEMBERREF_SIZE
);
2403 sig
= mono_metadata_blob_heap (m
, cols
[MONO_MEMBERREF_SIGNATURE
]);
2404 mono_metadata_decode_blob_size (sig
, &sig
);
2405 if (*sig
== 0x6) { /* it's a field */
2406 temp
= get_field (m
, token
, container
);
2407 result
= g_strdup_printf ("field %s", temp
);
2411 temp
= get_method (m
, token
, container
);
2412 result
= g_strdup_printf ("method %s", temp
);
2419 g_error ("Do not know how to decode tokens of type 0x%08x", token
);
2422 g_assert_not_reached ();
2423 return g_strdup ("ERROR");
2428 * @m: metadata context
2429 * @token: the token can belong to any of the following tables:
2430 * MONO_TOKEN_TYPE_REF, MONO_TOKEN_TYPE_DEF, MONO_TOKEN_TYPE_SPEC
2432 * Returns: a stringified version of the MethodDef or MethodRef or TypeSpecn
2433 * at (token & 0xffffff)
2436 get_token_type (MonoImage
*m
, guint32 token
, MonoGenericContainer
*container
)
2438 char *temp
= NULL
, *s
= NULL
;
2441 idx
= mono_metadata_token_index (token
);
2443 switch (mono_metadata_token_code (token
)){
2444 case MONO_TOKEN_TYPE_DEF
:
2445 temp
= get_typedef (m
, idx
);
2446 s
= g_strdup_printf ("%s", temp
);
2449 case MONO_TOKEN_TYPE_REF
:
2450 temp
= get_typeref (m
, idx
);
2451 s
= g_strdup_printf ("%s", temp
);
2454 case MONO_TOKEN_TYPE_SPEC
:
2455 s
= get_typespec (m
, idx
, FALSE
, container
);
2459 g_error ("Unhandled encoding for token 0x%08x", token
);
2470 get_guid (MonoImage
*m
, guint32 guid_index
)
2472 const unsigned char *guid
;
2475 guid
= (const guchar
*)mono_metadata_guid_heap (m
, guid_index
);
2477 result
= g_strdup_printf ("{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
2478 guid
[3], guid
[2], guid
[1], guid
[0], guid
[5], guid
[4], guid
[7], guid
[6],
2479 guid
[8], guid
[9], guid
[10], guid
[11], guid
[12], guid
[13], guid
[14], guid
[15]);
2484 dis_get_custom_attrs (MonoImage
*m
, guint32 token
)
2487 guint32 idx
, i
, len
, mtoken
;
2488 guint32 cols
[MONO_CUSTOM_ATTR_SIZE
];
2494 idx
= mono_metadata_token_index (token
);
2495 idx
<<= MONO_CUSTOM_ATTR_BITS
;
2497 switch (mono_metadata_token_table (token
)) {
2498 case MONO_TABLE_TYPEDEF
:
2499 idx
|= MONO_CUSTOM_ATTR_TYPEDEF
;
2501 case MONO_TABLE_ASSEMBLY
:
2502 idx
|= MONO_CUSTOM_ATTR_ASSEMBLY
;
2504 case MONO_TABLE_ASSEMBLYREF
:
2505 idx
|= MONO_CUSTOM_ATTR_ASSEMBLYREF
;
2507 case MONO_TABLE_MODULE
:
2508 idx
|= MONO_CUSTOM_ATTR_MODULE
;
2510 case MONO_TABLE_PROPERTY
:
2511 idx
|= MONO_CUSTOM_ATTR_PROPERTY
;
2513 case MONO_TABLE_EVENT
:
2514 idx
|= MONO_CUSTOM_ATTR_EVENT
;
2516 case MONO_TABLE_FIELD
:
2517 idx
|= MONO_CUSTOM_ATTR_FIELDDEF
;
2519 case MONO_TABLE_METHOD
:
2520 idx
|= MONO_CUSTOM_ATTR_METHODDEF
;
2522 case MONO_TABLE_PARAM
:
2523 idx
|= MONO_CUSTOM_ATTR_PARAMDEF
;
2525 case MONO_TABLE_GENERICPARAM
:
2526 idx
|= MONO_CUSTOM_ATTR_GENERICPAR
;
2529 g_print ("Missing custom attr get support for token 0x%08x\n", token
);
2533 ca
= &m
->tables
[MONO_TABLE_CUSTOMATTRIBUTE
];
2534 /* the table is not sorted */
2535 for (i
= 0; i
< ca
->rows
; ++i
) {
2537 mono_metadata_decode_row (ca
, i
, cols
, MONO_CUSTOM_ATTR_SIZE
);
2538 if (cols
[MONO_CUSTOM_ATTR_PARENT
] != idx
)
2540 mtoken
= cols
[MONO_CUSTOM_ATTR_TYPE
] >> MONO_CUSTOM_ATTR_TYPE_BITS
;
2541 switch (cols
[MONO_CUSTOM_ATTR_TYPE
] & MONO_CUSTOM_ATTR_TYPE_MASK
) {
2542 case MONO_CUSTOM_ATTR_TYPE_METHODDEF
:
2543 mtoken
|= MONO_TOKEN_METHOD_DEF
;
2545 case MONO_CUSTOM_ATTR_TYPE_MEMBERREF
:
2546 mtoken
|= MONO_TOKEN_MEMBER_REF
;
2549 g_error ("Unknown table for custom attr type %08x", cols
[MONO_CUSTOM_ATTR_TYPE
]);
2552 method
= get_method (m
, mtoken
, NULL
);
2553 val
= mono_metadata_blob_heap (m
, cols
[MONO_CUSTOM_ATTR_VALUE
]);
2554 len
= mono_metadata_decode_value (val
, &val
);
2555 attr
= g_string_new (".custom ");
2556 dump
= data_dump (val
, len
, "\t\t");
2557 g_string_append_printf (attr
, "%s = %s", method
, dump
);
2559 list
= g_list_append (list
, attr
->str
);
2560 g_string_free (attr
, FALSE
);
2567 get_marshal_info (MonoImage
*m
, const char *blob
) {
2570 /* len = */ mono_metadata_decode_blob_size (blob
, &blob
);
2573 case MONO_NATIVE_BOOLEAN
:
2574 return g_strdup ("bool");
2575 case MONO_NATIVE_I1
:
2576 return g_strdup ("int8");
2577 case MONO_NATIVE_U1
:
2578 return g_strdup ("unsigned int8");
2579 case MONO_NATIVE_I2
:
2580 return g_strdup ("int16");
2581 case MONO_NATIVE_U2
:
2582 return g_strdup ("unsigned int16");
2583 case MONO_NATIVE_I4
:
2584 return g_strdup ("int32");
2585 case MONO_NATIVE_U4
:
2586 return g_strdup ("unsigned int32");
2587 case MONO_NATIVE_I8
:
2588 return g_strdup ("int64");
2589 case MONO_NATIVE_U8
:
2590 return g_strdup ("unsigned int64");
2591 case MONO_NATIVE_R4
:
2592 return g_strdup ("float32");
2593 case MONO_NATIVE_R8
:
2594 return g_strdup ("float64");
2595 case MONO_NATIVE_CURRENCY
:
2596 return g_strdup ("currency");
2597 case MONO_NATIVE_BSTR
:
2598 return g_strdup ("bstr");
2599 case MONO_NATIVE_LPSTR
:
2600 return g_strdup ("lpstr");
2601 case MONO_NATIVE_LPWSTR
:
2602 return g_strdup ("lpwstr");
2603 case MONO_NATIVE_LPTSTR
:
2604 return g_strdup ("lptstr");
2605 case MONO_NATIVE_BYVALTSTR
:
2606 size
= mono_metadata_decode_value (blob
+ 1, &blob
);
2607 return g_strdup_printf ("fixed sysstring [%d]", size
);
2608 case MONO_NATIVE_IUNKNOWN
:
2609 return g_strdup ("iunknown");
2610 case MONO_NATIVE_IDISPATCH
:
2611 return g_strdup ("idispatch");
2612 case MONO_NATIVE_STRUCT
:
2613 return g_strdup ("struct");
2614 case MONO_NATIVE_INTERFACE
:
2615 return g_strdup ("interface");
2616 case MONO_NATIVE_SAFEARRAY
:
2617 return g_strdup ("safearray");
2618 case MONO_NATIVE_BYVALARRAY
:
2619 size
= mono_metadata_decode_value (blob
+ 1, &blob
);
2620 return g_strdup_printf ("fixed array [%d]", size
);
2621 case MONO_NATIVE_INT
:
2622 return g_strdup ("int");
2623 case MONO_NATIVE_UINT
:
2624 return g_strdup ("unsigned int");
2625 case MONO_NATIVE_VBBYREFSTR
:
2626 return g_strdup ("vbbyrefstr");
2627 case MONO_NATIVE_ANSIBSTR
:
2628 return g_strdup ("ansi bstr");
2629 case MONO_NATIVE_TBSTR
:
2630 return g_strdup ("tbstr");
2631 case MONO_NATIVE_VARIANTBOOL
:
2632 return g_strdup ("variant bool");
2633 case MONO_NATIVE_FUNC
:
2634 return g_strdup ("method");
2635 case MONO_NATIVE_ASANY
:
2636 return g_strdup ("as any");
2637 case MONO_NATIVE_LPARRAY
:
2638 return g_strdup ("[]");
2639 case MONO_NATIVE_LPSTRUCT
:
2640 return g_strdup ("lpstruct");
2641 case MONO_NATIVE_CUSTOM
:
2642 return g_strdup ("custom");
2643 case MONO_NATIVE_ERROR
:
2644 return g_strdup ("error");
2646 return g_strdup ("unknown");
2651 init_key_table (void)
2653 key_table
= g_hash_table_new (g_str_hash
, g_str_equal
);
2655 g_hash_table_insert (key_table
, (char *) "9", GINT_TO_POINTER (TRUE
));
2656 g_hash_table_insert (key_table
, (char *) "abstract", GINT_TO_POINTER (TRUE
));
2657 g_hash_table_insert (key_table
, (char *) "add", GINT_TO_POINTER (TRUE
));
2658 g_hash_table_insert (key_table
, (char *) "add.ovf", GINT_TO_POINTER (TRUE
));
2659 g_hash_table_insert (key_table
, (char *) "add.ovf.un", GINT_TO_POINTER (TRUE
));
2660 g_hash_table_insert (key_table
, (char *) "algorithm", GINT_TO_POINTER (TRUE
));
2661 g_hash_table_insert (key_table
, (char *) "alignment", GINT_TO_POINTER (TRUE
));
2662 g_hash_table_insert (key_table
, (char *) "and", GINT_TO_POINTER (TRUE
));
2663 g_hash_table_insert (key_table
, (char *) "ansi", GINT_TO_POINTER (TRUE
));
2664 g_hash_table_insert (key_table
, (char *) "any", GINT_TO_POINTER (TRUE
));
2665 g_hash_table_insert (key_table
, (char *) "arglist", GINT_TO_POINTER (TRUE
));
2666 g_hash_table_insert (key_table
, (char *) "array", GINT_TO_POINTER (TRUE
));
2667 g_hash_table_insert (key_table
, (char *) "as", GINT_TO_POINTER (TRUE
));
2668 g_hash_table_insert (key_table
, (char *) "assembly", GINT_TO_POINTER (TRUE
));
2669 g_hash_table_insert (key_table
, (char *) "assert", GINT_TO_POINTER (TRUE
));
2670 g_hash_table_insert (key_table
, (char *) "at", GINT_TO_POINTER (TRUE
));
2671 g_hash_table_insert (key_table
, (char *) "autochar", GINT_TO_POINTER (TRUE
));
2672 g_hash_table_insert (key_table
, (char *) "auto", GINT_TO_POINTER (TRUE
));
2673 g_hash_table_insert (key_table
, (char *) "beforefieldinit", GINT_TO_POINTER (TRUE
));
2674 g_hash_table_insert (key_table
, (char *) "bestfit", GINT_TO_POINTER (TRUE
));
2675 g_hash_table_insert (key_table
, (char *) "beq", GINT_TO_POINTER (TRUE
));
2676 g_hash_table_insert (key_table
, (char *) "beq.s", GINT_TO_POINTER (TRUE
));
2677 g_hash_table_insert (key_table
, (char *) "bge", GINT_TO_POINTER (TRUE
));
2678 g_hash_table_insert (key_table
, (char *) "bge.s", GINT_TO_POINTER (TRUE
));
2679 g_hash_table_insert (key_table
, (char *) "bge.un", GINT_TO_POINTER (TRUE
));
2680 g_hash_table_insert (key_table
, (char *) "bge.un.s", GINT_TO_POINTER (TRUE
));
2681 g_hash_table_insert (key_table
, (char *) "bgt", GINT_TO_POINTER (TRUE
));
2682 g_hash_table_insert (key_table
, (char *) "bgt.s", GINT_TO_POINTER (TRUE
));
2683 g_hash_table_insert (key_table
, (char *) "bgt.un", GINT_TO_POINTER (TRUE
));
2684 g_hash_table_insert (key_table
, (char *) "bgt.un.s", GINT_TO_POINTER (TRUE
));
2685 g_hash_table_insert (key_table
, (char *) "ble", GINT_TO_POINTER (TRUE
));
2686 g_hash_table_insert (key_table
, (char *) "ble.s", GINT_TO_POINTER (TRUE
));
2687 g_hash_table_insert (key_table
, (char *) "ble.un", GINT_TO_POINTER (TRUE
));
2688 g_hash_table_insert (key_table
, (char *) "ble.un.s", GINT_TO_POINTER (TRUE
));
2689 g_hash_table_insert (key_table
, (char *) "blob", GINT_TO_POINTER (TRUE
));
2690 g_hash_table_insert (key_table
, (char *) "blob_object", GINT_TO_POINTER (TRUE
));
2691 g_hash_table_insert (key_table
, (char *) "blt", GINT_TO_POINTER (TRUE
));
2692 g_hash_table_insert (key_table
, (char *) "blt.s", GINT_TO_POINTER (TRUE
));
2693 g_hash_table_insert (key_table
, (char *) "blt.un", GINT_TO_POINTER (TRUE
));
2694 g_hash_table_insert (key_table
, (char *) "blt.un.s", GINT_TO_POINTER (TRUE
));
2695 g_hash_table_insert (key_table
, (char *) "bne.un", GINT_TO_POINTER (TRUE
));
2696 g_hash_table_insert (key_table
, (char *) "bne.un.s", GINT_TO_POINTER (TRUE
));
2697 g_hash_table_insert (key_table
, (char *) "bool", GINT_TO_POINTER (TRUE
));
2698 g_hash_table_insert (key_table
, (char *) "box", GINT_TO_POINTER (TRUE
));
2699 g_hash_table_insert (key_table
, (char *) "break", GINT_TO_POINTER (TRUE
));
2700 g_hash_table_insert (key_table
, (char *) "brfalse", GINT_TO_POINTER (TRUE
));
2701 g_hash_table_insert (key_table
, (char *) "brfalse.s", GINT_TO_POINTER (TRUE
));
2702 g_hash_table_insert (key_table
, (char *) "br", GINT_TO_POINTER (TRUE
));
2703 g_hash_table_insert (key_table
, (char *) "brinst", GINT_TO_POINTER (TRUE
));
2704 g_hash_table_insert (key_table
, (char *) "brinst.s", GINT_TO_POINTER (TRUE
));
2705 g_hash_table_insert (key_table
, (char *) "brnull", GINT_TO_POINTER (TRUE
));
2706 g_hash_table_insert (key_table
, (char *) "brnull.s", GINT_TO_POINTER (TRUE
));
2707 g_hash_table_insert (key_table
, (char *) "br.s", GINT_TO_POINTER (TRUE
));
2708 g_hash_table_insert (key_table
, (char *) "brtrue", GINT_TO_POINTER (TRUE
));
2709 g_hash_table_insert (key_table
, (char *) "brtrue.s", GINT_TO_POINTER (TRUE
));
2710 g_hash_table_insert (key_table
, (char *) "brzero", GINT_TO_POINTER (TRUE
));
2711 g_hash_table_insert (key_table
, (char *) "brzero.s", GINT_TO_POINTER (TRUE
));
2712 g_hash_table_insert (key_table
, (char *) "bstr", GINT_TO_POINTER (TRUE
));
2713 g_hash_table_insert (key_table
, (char *) "bytearray", GINT_TO_POINTER (TRUE
));
2714 g_hash_table_insert (key_table
, (char *) "byvalstr", GINT_TO_POINTER (TRUE
));
2715 g_hash_table_insert (key_table
, (char *) "call", GINT_TO_POINTER (TRUE
));
2716 g_hash_table_insert (key_table
, (char *) "callconv", GINT_TO_POINTER (TRUE
));
2717 g_hash_table_insert (key_table
, (char *) "calli", GINT_TO_POINTER (TRUE
));
2718 g_hash_table_insert (key_table
, (char *) "callmostderived", GINT_TO_POINTER (TRUE
));
2719 g_hash_table_insert (key_table
, (char *) "callvirt", GINT_TO_POINTER (TRUE
));
2720 g_hash_table_insert (key_table
, (char *) "carray", GINT_TO_POINTER (TRUE
));
2721 g_hash_table_insert (key_table
, (char *) "castclass", GINT_TO_POINTER (TRUE
));
2722 g_hash_table_insert (key_table
, (char *) "catch", GINT_TO_POINTER (TRUE
));
2723 g_hash_table_insert (key_table
, (char *) "cdecl", GINT_TO_POINTER (TRUE
));
2724 g_hash_table_insert (key_table
, (char *) "ceq", GINT_TO_POINTER (TRUE
));
2725 g_hash_table_insert (key_table
, (char *) "cf", GINT_TO_POINTER (TRUE
));
2726 g_hash_table_insert (key_table
, (char *) "cgt", GINT_TO_POINTER (TRUE
));
2727 g_hash_table_insert (key_table
, (char *) "cgt.un", GINT_TO_POINTER (TRUE
));
2728 g_hash_table_insert (key_table
, (char *) "char", GINT_TO_POINTER (TRUE
));
2729 g_hash_table_insert (key_table
, (char *) "charmaperror", GINT_TO_POINTER (TRUE
));
2730 g_hash_table_insert (key_table
, (char *) "cil", GINT_TO_POINTER (TRUE
));
2731 g_hash_table_insert (key_table
, (char *) "ckfinite", GINT_TO_POINTER (TRUE
));
2732 g_hash_table_insert (key_table
, (char *) "class", GINT_TO_POINTER (TRUE
));
2733 g_hash_table_insert (key_table
, (char *) "clsid", GINT_TO_POINTER (TRUE
));
2734 g_hash_table_insert (key_table
, (char *) "clt", GINT_TO_POINTER (TRUE
));
2735 g_hash_table_insert (key_table
, (char *) "clt.un", GINT_TO_POINTER (TRUE
));
2736 g_hash_table_insert (key_table
, (char *) "Compilercontrolled", GINT_TO_POINTER (TRUE
));
2737 g_hash_table_insert (key_table
, (char *) "const", GINT_TO_POINTER (TRUE
));
2738 g_hash_table_insert (key_table
, (char *) "conv.i1", GINT_TO_POINTER (TRUE
));
2739 g_hash_table_insert (key_table
, (char *) "conv.i2", GINT_TO_POINTER (TRUE
));
2740 g_hash_table_insert (key_table
, (char *) "conv.i4", GINT_TO_POINTER (TRUE
));
2741 g_hash_table_insert (key_table
, (char *) "conv.i8", GINT_TO_POINTER (TRUE
));
2742 g_hash_table_insert (key_table
, (char *) "conv.i", GINT_TO_POINTER (TRUE
));
2743 g_hash_table_insert (key_table
, (char *) "conv.ovf.i1", GINT_TO_POINTER (TRUE
));
2744 g_hash_table_insert (key_table
, (char *) "conv.ovf.i1.un", GINT_TO_POINTER (TRUE
));
2745 g_hash_table_insert (key_table
, (char *) "conv.ovf.i2", GINT_TO_POINTER (TRUE
));
2746 g_hash_table_insert (key_table
, (char *) "conv.ovf.i2.un", GINT_TO_POINTER (TRUE
));
2747 g_hash_table_insert (key_table
, (char *) "conv.ovf.i4", GINT_TO_POINTER (TRUE
));
2748 g_hash_table_insert (key_table
, (char *) "conv.ovf.i4.un", GINT_TO_POINTER (TRUE
));
2749 g_hash_table_insert (key_table
, (char *) "conv.ovf.i8", GINT_TO_POINTER (TRUE
));
2750 g_hash_table_insert (key_table
, (char *) "conv.ovf.i8.un", GINT_TO_POINTER (TRUE
));
2751 g_hash_table_insert (key_table
, (char *) "conv.ovf.i", GINT_TO_POINTER (TRUE
));
2752 g_hash_table_insert (key_table
, (char *) "conv.ovf.i.un", GINT_TO_POINTER (TRUE
));
2753 g_hash_table_insert (key_table
, (char *) "conv.ovf.u1", GINT_TO_POINTER (TRUE
));
2754 g_hash_table_insert (key_table
, (char *) "conv.ovf.u1.un", GINT_TO_POINTER (TRUE
));
2755 g_hash_table_insert (key_table
, (char *) "conv.ovf.u2", GINT_TO_POINTER (TRUE
));
2756 g_hash_table_insert (key_table
, (char *) "conv.ovf.u2.un", GINT_TO_POINTER (TRUE
));
2757 g_hash_table_insert (key_table
, (char *) "conv.ovf.u4", GINT_TO_POINTER (TRUE
));
2758 g_hash_table_insert (key_table
, (char *) "conv.ovf.u4.un", GINT_TO_POINTER (TRUE
));
2759 g_hash_table_insert (key_table
, (char *) "conv.ovf.u8", GINT_TO_POINTER (TRUE
));
2760 g_hash_table_insert (key_table
, (char *) "conv.ovf.u8.un", GINT_TO_POINTER (TRUE
));
2761 g_hash_table_insert (key_table
, (char *) "conv.ovf.u", GINT_TO_POINTER (TRUE
));
2762 g_hash_table_insert (key_table
, (char *) "conv.ovf.u.un", GINT_TO_POINTER (TRUE
));
2763 g_hash_table_insert (key_table
, (char *) "conv.r4", GINT_TO_POINTER (TRUE
));
2764 g_hash_table_insert (key_table
, (char *) "conv.r8", GINT_TO_POINTER (TRUE
));
2765 g_hash_table_insert (key_table
, (char *) "conv.r.un", GINT_TO_POINTER (TRUE
));
2766 g_hash_table_insert (key_table
, (char *) "conv.u1", GINT_TO_POINTER (TRUE
));
2767 g_hash_table_insert (key_table
, (char *) "conv.u2", GINT_TO_POINTER (TRUE
));
2768 g_hash_table_insert (key_table
, (char *) "conv.u4", GINT_TO_POINTER (TRUE
));
2769 g_hash_table_insert (key_table
, (char *) "conv.u8", GINT_TO_POINTER (TRUE
));
2770 g_hash_table_insert (key_table
, (char *) "conv.u", GINT_TO_POINTER (TRUE
));
2771 g_hash_table_insert (key_table
, (char *) "cpblk", GINT_TO_POINTER (TRUE
));
2772 g_hash_table_insert (key_table
, (char *) "cpobj", GINT_TO_POINTER (TRUE
));
2773 g_hash_table_insert (key_table
, (char *) "currency", GINT_TO_POINTER (TRUE
));
2774 g_hash_table_insert (key_table
, (char *) "custom", GINT_TO_POINTER (TRUE
));
2775 g_hash_table_insert (key_table
, (char *) "date", GINT_TO_POINTER (TRUE
));
2776 g_hash_table_insert (key_table
, (char *) "decimal", GINT_TO_POINTER (TRUE
));
2777 g_hash_table_insert (key_table
, (char *) "default", GINT_TO_POINTER (TRUE
));
2778 g_hash_table_insert (key_table
, (char *) "demand", GINT_TO_POINTER (TRUE
));
2779 g_hash_table_insert (key_table
, (char *) "deny", GINT_TO_POINTER (TRUE
));
2780 g_hash_table_insert (key_table
, (char *) "div", GINT_TO_POINTER (TRUE
));
2781 g_hash_table_insert (key_table
, (char *) "div.un", GINT_TO_POINTER (TRUE
));
2782 g_hash_table_insert (key_table
, (char *) "dup", GINT_TO_POINTER (TRUE
));
2783 g_hash_table_insert (key_table
, (char *) "endfault", GINT_TO_POINTER (TRUE
));
2784 g_hash_table_insert (key_table
, (char *) "endfilter", GINT_TO_POINTER (TRUE
));
2785 g_hash_table_insert (key_table
, (char *) "endfinally", GINT_TO_POINTER (TRUE
));
2786 g_hash_table_insert (key_table
, (char *) "endmac", GINT_TO_POINTER (TRUE
));
2787 g_hash_table_insert (key_table
, (char *) "enum", GINT_TO_POINTER (TRUE
));
2788 g_hash_table_insert (key_table
, (char *) "error", GINT_TO_POINTER (TRUE
));
2789 g_hash_table_insert (key_table
, (char *) "explicit", GINT_TO_POINTER (TRUE
));
2790 g_hash_table_insert (key_table
, (char *) "extends", GINT_TO_POINTER (TRUE
));
2791 g_hash_table_insert (key_table
, (char *) "extern", GINT_TO_POINTER (TRUE
));
2792 g_hash_table_insert (key_table
, (char *) "false", GINT_TO_POINTER (TRUE
));
2793 g_hash_table_insert (key_table
, (char *) "famandassem", GINT_TO_POINTER (TRUE
));
2794 g_hash_table_insert (key_table
, (char *) "family", GINT_TO_POINTER (TRUE
));
2795 g_hash_table_insert (key_table
, (char *) "famorassem", GINT_TO_POINTER (TRUE
));
2796 g_hash_table_insert (key_table
, (char *) "fastcall", GINT_TO_POINTER (TRUE
));
2797 g_hash_table_insert (key_table
, (char *) "fault", GINT_TO_POINTER (TRUE
));
2798 g_hash_table_insert (key_table
, (char *) "field", GINT_TO_POINTER (TRUE
));
2799 g_hash_table_insert (key_table
, (char *) "filetime", GINT_TO_POINTER (TRUE
));
2800 g_hash_table_insert (key_table
, (char *) "filter", GINT_TO_POINTER (TRUE
));
2801 g_hash_table_insert (key_table
, (char *) "final", GINT_TO_POINTER (TRUE
));
2802 g_hash_table_insert (key_table
, (char *) "finally", GINT_TO_POINTER (TRUE
));
2803 g_hash_table_insert (key_table
, (char *) "fixed", GINT_TO_POINTER (TRUE
));
2804 g_hash_table_insert (key_table
, (char *) "flags", GINT_TO_POINTER (TRUE
));
2805 g_hash_table_insert (key_table
, (char *) "float32", GINT_TO_POINTER (TRUE
));
2806 g_hash_table_insert (key_table
, (char *) "float64", GINT_TO_POINTER (TRUE
));
2807 g_hash_table_insert (key_table
, (char *) "float", GINT_TO_POINTER (TRUE
));
2808 g_hash_table_insert (key_table
, (char *) "forwardref", GINT_TO_POINTER (TRUE
));
2809 g_hash_table_insert (key_table
, (char *) "fromunmanaged", GINT_TO_POINTER (TRUE
));
2810 g_hash_table_insert (key_table
, (char *) "handler", GINT_TO_POINTER (TRUE
));
2811 g_hash_table_insert (key_table
, (char *) "hidebysig", GINT_TO_POINTER (TRUE
));
2812 g_hash_table_insert (key_table
, (char *) "hresult", GINT_TO_POINTER (TRUE
));
2813 g_hash_table_insert (key_table
, (char *) "idispatch", GINT_TO_POINTER (TRUE
));
2814 g_hash_table_insert (key_table
, (char *) "il", GINT_TO_POINTER (TRUE
));
2815 g_hash_table_insert (key_table
, (char *) "illegal", GINT_TO_POINTER (TRUE
));
2816 g_hash_table_insert (key_table
, (char *) "implements", GINT_TO_POINTER (TRUE
));
2817 g_hash_table_insert (key_table
, (char *) "implicitcom", GINT_TO_POINTER (TRUE
));
2818 g_hash_table_insert (key_table
, (char *) "implicitres", GINT_TO_POINTER (TRUE
));
2819 g_hash_table_insert (key_table
, (char *) "import", GINT_TO_POINTER (TRUE
));
2820 g_hash_table_insert (key_table
, (char *) "in", GINT_TO_POINTER (TRUE
));
2821 g_hash_table_insert (key_table
, (char *) "inheritcheck", GINT_TO_POINTER (TRUE
));
2822 g_hash_table_insert (key_table
, (char *) "initblk", GINT_TO_POINTER (TRUE
));
2823 g_hash_table_insert (key_table
, (char *) "init", GINT_TO_POINTER (TRUE
));
2824 g_hash_table_insert (key_table
, (char *) "initobj", GINT_TO_POINTER (TRUE
));
2825 g_hash_table_insert (key_table
, (char *) "initonly", GINT_TO_POINTER (TRUE
));
2826 g_hash_table_insert (key_table
, (char *) "instance", GINT_TO_POINTER (TRUE
));
2827 g_hash_table_insert (key_table
, (char *) "int16", GINT_TO_POINTER (TRUE
));
2828 g_hash_table_insert (key_table
, (char *) "int32", GINT_TO_POINTER (TRUE
));
2829 g_hash_table_insert (key_table
, (char *) "int64", GINT_TO_POINTER (TRUE
));
2830 g_hash_table_insert (key_table
, (char *) "int8", GINT_TO_POINTER (TRUE
));
2831 g_hash_table_insert (key_table
, (char *) "interface", GINT_TO_POINTER (TRUE
));
2832 g_hash_table_insert (key_table
, (char *) "internalcall", GINT_TO_POINTER (TRUE
));
2833 g_hash_table_insert (key_table
, (char *) "int", GINT_TO_POINTER (TRUE
));
2834 g_hash_table_insert (key_table
, (char *) "isinst", GINT_TO_POINTER (TRUE
));
2835 g_hash_table_insert (key_table
, (char *) "iunknown", GINT_TO_POINTER (TRUE
));
2836 g_hash_table_insert (key_table
, (char *) "jmp", GINT_TO_POINTER (TRUE
));
2837 g_hash_table_insert (key_table
, (char *) "lasterr", GINT_TO_POINTER (TRUE
));
2838 g_hash_table_insert (key_table
, (char *) "lcid", GINT_TO_POINTER (TRUE
));
2839 g_hash_table_insert (key_table
, (char *) "ldarg.0", GINT_TO_POINTER (TRUE
));
2840 g_hash_table_insert (key_table
, (char *) "ldarg.1", GINT_TO_POINTER (TRUE
));
2841 g_hash_table_insert (key_table
, (char *) "ldarg.2", GINT_TO_POINTER (TRUE
));
2842 g_hash_table_insert (key_table
, (char *) "ldarg.3", GINT_TO_POINTER (TRUE
));
2843 g_hash_table_insert (key_table
, (char *) "ldarga", GINT_TO_POINTER (TRUE
));
2844 g_hash_table_insert (key_table
, (char *) "ldarga.s", GINT_TO_POINTER (TRUE
));
2845 g_hash_table_insert (key_table
, (char *) "ldarg", GINT_TO_POINTER (TRUE
));
2846 g_hash_table_insert (key_table
, (char *) "ldarg.s", GINT_TO_POINTER (TRUE
));
2847 g_hash_table_insert (key_table
, (char *) "ldc.i4.0", GINT_TO_POINTER (TRUE
));
2848 g_hash_table_insert (key_table
, (char *) "ldc.i4.1", GINT_TO_POINTER (TRUE
));
2849 g_hash_table_insert (key_table
, (char *) "ldc.i4.2", GINT_TO_POINTER (TRUE
));
2850 g_hash_table_insert (key_table
, (char *) "ldc.i4.3", GINT_TO_POINTER (TRUE
));
2851 g_hash_table_insert (key_table
, (char *) "ldc.i4.4", GINT_TO_POINTER (TRUE
));
2852 g_hash_table_insert (key_table
, (char *) "ldc.i4.5", GINT_TO_POINTER (TRUE
));
2853 g_hash_table_insert (key_table
, (char *) "ldc.i4.6", GINT_TO_POINTER (TRUE
));
2854 g_hash_table_insert (key_table
, (char *) "ldc.i4.7", GINT_TO_POINTER (TRUE
));
2855 g_hash_table_insert (key_table
, (char *) "ldc.i4.8", GINT_TO_POINTER (TRUE
));
2856 g_hash_table_insert (key_table
, (char *) "ldc.i4", GINT_TO_POINTER (TRUE
));
2857 g_hash_table_insert (key_table
, (char *) "ldc.i4.m1", GINT_TO_POINTER (TRUE
));
2858 g_hash_table_insert (key_table
, (char *) "ldc.i4.M1", GINT_TO_POINTER (TRUE
));
2859 g_hash_table_insert (key_table
, (char *) "ldc.i4.s", GINT_TO_POINTER (TRUE
));
2860 g_hash_table_insert (key_table
, (char *) "ldc.i8", GINT_TO_POINTER (TRUE
));
2861 g_hash_table_insert (key_table
, (char *) "ldc.r4", GINT_TO_POINTER (TRUE
));
2862 g_hash_table_insert (key_table
, (char *) "ldc.r8", GINT_TO_POINTER (TRUE
));
2863 g_hash_table_insert (key_table
, (char *) "ldelem", GINT_TO_POINTER (TRUE
));
2864 g_hash_table_insert (key_table
, (char *) "ldelema", GINT_TO_POINTER (TRUE
));
2865 g_hash_table_insert (key_table
, (char *) "ldelem.i1", GINT_TO_POINTER (TRUE
));
2866 g_hash_table_insert (key_table
, (char *) "ldelem.i2", GINT_TO_POINTER (TRUE
));
2867 g_hash_table_insert (key_table
, (char *) "ldelem.i4", GINT_TO_POINTER (TRUE
));
2868 g_hash_table_insert (key_table
, (char *) "ldelem.i8", GINT_TO_POINTER (TRUE
));
2869 g_hash_table_insert (key_table
, (char *) "ldelem.i", GINT_TO_POINTER (TRUE
));
2870 g_hash_table_insert (key_table
, (char *) "ldelem.r4", GINT_TO_POINTER (TRUE
));
2871 g_hash_table_insert (key_table
, (char *) "ldelem.r8", GINT_TO_POINTER (TRUE
));
2872 g_hash_table_insert (key_table
, (char *) "ldelem.ref", GINT_TO_POINTER (TRUE
));
2873 g_hash_table_insert (key_table
, (char *) "ldelem.u1", GINT_TO_POINTER (TRUE
));
2874 g_hash_table_insert (key_table
, (char *) "ldelem.u2", GINT_TO_POINTER (TRUE
));
2875 g_hash_table_insert (key_table
, (char *) "ldelem.u4", GINT_TO_POINTER (TRUE
));
2876 g_hash_table_insert (key_table
, (char *) "ldelem.u8", GINT_TO_POINTER (TRUE
));
2877 g_hash_table_insert (key_table
, (char *) "ldflda", GINT_TO_POINTER (TRUE
));
2878 g_hash_table_insert (key_table
, (char *) "ldfld", GINT_TO_POINTER (TRUE
));
2879 g_hash_table_insert (key_table
, (char *) "ldftn", GINT_TO_POINTER (TRUE
));
2880 g_hash_table_insert (key_table
, (char *) "ldind.i1", GINT_TO_POINTER (TRUE
));
2881 g_hash_table_insert (key_table
, (char *) "ldind.i2", GINT_TO_POINTER (TRUE
));
2882 g_hash_table_insert (key_table
, (char *) "ldind.i4", GINT_TO_POINTER (TRUE
));
2883 g_hash_table_insert (key_table
, (char *) "ldind.i8", GINT_TO_POINTER (TRUE
));
2884 g_hash_table_insert (key_table
, (char *) "ldind.i", GINT_TO_POINTER (TRUE
));
2885 g_hash_table_insert (key_table
, (char *) "ldind.r4", GINT_TO_POINTER (TRUE
));
2886 g_hash_table_insert (key_table
, (char *) "ldind.r8", GINT_TO_POINTER (TRUE
));
2887 g_hash_table_insert (key_table
, (char *) "ldind.ref", GINT_TO_POINTER (TRUE
));
2888 g_hash_table_insert (key_table
, (char *) "ldind.u1", GINT_TO_POINTER (TRUE
));
2889 g_hash_table_insert (key_table
, (char *) "ldind.u2", GINT_TO_POINTER (TRUE
));
2890 g_hash_table_insert (key_table
, (char *) "ldind.u4", GINT_TO_POINTER (TRUE
));
2891 g_hash_table_insert (key_table
, (char *) "ldind.u8", GINT_TO_POINTER (TRUE
));
2892 g_hash_table_insert (key_table
, (char *) "ldlen", GINT_TO_POINTER (TRUE
));
2893 g_hash_table_insert (key_table
, (char *) "ldloc.0", GINT_TO_POINTER (TRUE
));
2894 g_hash_table_insert (key_table
, (char *) "ldloc.1", GINT_TO_POINTER (TRUE
));
2895 g_hash_table_insert (key_table
, (char *) "ldloc.2", GINT_TO_POINTER (TRUE
));
2896 g_hash_table_insert (key_table
, (char *) "ldloc.3", GINT_TO_POINTER (TRUE
));
2897 g_hash_table_insert (key_table
, (char *) "ldloca", GINT_TO_POINTER (TRUE
));
2898 g_hash_table_insert (key_table
, (char *) "ldloca.s", GINT_TO_POINTER (TRUE
));
2899 g_hash_table_insert (key_table
, (char *) "ldloc", GINT_TO_POINTER (TRUE
));
2900 g_hash_table_insert (key_table
, (char *) "ldloc.s", GINT_TO_POINTER (TRUE
));
2901 g_hash_table_insert (key_table
, (char *) "ldnull", GINT_TO_POINTER (TRUE
));
2902 g_hash_table_insert (key_table
, (char *) "ldobj", GINT_TO_POINTER (TRUE
));
2903 g_hash_table_insert (key_table
, (char *) "ldsflda", GINT_TO_POINTER (TRUE
));
2904 g_hash_table_insert (key_table
, (char *) "ldsfld", GINT_TO_POINTER (TRUE
));
2905 g_hash_table_insert (key_table
, (char *) "ldstr", GINT_TO_POINTER (TRUE
));
2906 g_hash_table_insert (key_table
, (char *) "ldtoken", GINT_TO_POINTER (TRUE
));
2907 g_hash_table_insert (key_table
, (char *) "ldvirtftn", GINT_TO_POINTER (TRUE
));
2908 g_hash_table_insert (key_table
, (char *) "leave", GINT_TO_POINTER (TRUE
));
2909 g_hash_table_insert (key_table
, (char *) "leave.s", GINT_TO_POINTER (TRUE
));
2910 g_hash_table_insert (key_table
, (char *) "legacy", GINT_TO_POINTER (TRUE
));
2911 g_hash_table_insert (key_table
, (char *) "linkcheck", GINT_TO_POINTER (TRUE
));
2912 g_hash_table_insert (key_table
, (char *) "literal", GINT_TO_POINTER (TRUE
));
2913 g_hash_table_insert (key_table
, (char *) "localloc", GINT_TO_POINTER (TRUE
));
2914 g_hash_table_insert (key_table
, (char *) "lpstr", GINT_TO_POINTER (TRUE
));
2915 g_hash_table_insert (key_table
, (char *) "lpstruct", GINT_TO_POINTER (TRUE
));
2916 g_hash_table_insert (key_table
, (char *) "lptstr", GINT_TO_POINTER (TRUE
));
2917 g_hash_table_insert (key_table
, (char *) "lpvoid", GINT_TO_POINTER (TRUE
));
2918 g_hash_table_insert (key_table
, (char *) "lpwstr", GINT_TO_POINTER (TRUE
));
2919 g_hash_table_insert (key_table
, (char *) "managed", GINT_TO_POINTER (TRUE
));
2920 g_hash_table_insert (key_table
, (char *) "marshal", GINT_TO_POINTER (TRUE
));
2921 g_hash_table_insert (key_table
, (char *) "method", GINT_TO_POINTER (TRUE
));
2922 g_hash_table_insert (key_table
, (char *) "mkrefany", GINT_TO_POINTER (TRUE
));
2923 g_hash_table_insert (key_table
, (char *) "modopt", GINT_TO_POINTER (TRUE
));
2924 g_hash_table_insert (key_table
, (char *) "modreq", GINT_TO_POINTER (TRUE
));
2925 g_hash_table_insert (key_table
, (char *) "mul", GINT_TO_POINTER (TRUE
));
2926 g_hash_table_insert (key_table
, (char *) "mul.ovf", GINT_TO_POINTER (TRUE
));
2927 g_hash_table_insert (key_table
, (char *) "mul.ovf.un", GINT_TO_POINTER (TRUE
));
2928 g_hash_table_insert (key_table
, (char *) "native", GINT_TO_POINTER (TRUE
));
2929 g_hash_table_insert (key_table
, (char *) "neg", GINT_TO_POINTER (TRUE
));
2930 g_hash_table_insert (key_table
, (char *) "nested", GINT_TO_POINTER (TRUE
));
2931 g_hash_table_insert (key_table
, (char *) "newarr", GINT_TO_POINTER (TRUE
));
2932 g_hash_table_insert (key_table
, (char *) "newobj", GINT_TO_POINTER (TRUE
));
2933 g_hash_table_insert (key_table
, (char *) "newslot", GINT_TO_POINTER (TRUE
));
2934 g_hash_table_insert (key_table
, (char *) "noappdomain", GINT_TO_POINTER (TRUE
));
2935 g_hash_table_insert (key_table
, (char *) "noinlining", GINT_TO_POINTER (TRUE
));
2936 g_hash_table_insert (key_table
, (char *) "nomachine", GINT_TO_POINTER (TRUE
));
2937 g_hash_table_insert (key_table
, (char *) "nomangle", GINT_TO_POINTER (TRUE
));
2938 g_hash_table_insert (key_table
, (char *) "nometadata", GINT_TO_POINTER (TRUE
));
2939 g_hash_table_insert (key_table
, (char *) "noncasdemand", GINT_TO_POINTER (TRUE
));
2940 g_hash_table_insert (key_table
, (char *) "noncasinheritance", GINT_TO_POINTER (TRUE
));
2941 g_hash_table_insert (key_table
, (char *) "noncaslinkdemand", GINT_TO_POINTER (TRUE
));
2942 g_hash_table_insert (key_table
, (char *) "nop", GINT_TO_POINTER (TRUE
));
2943 g_hash_table_insert (key_table
, (char *) "noprocess", GINT_TO_POINTER (TRUE
));
2944 g_hash_table_insert (key_table
, (char *) "not", GINT_TO_POINTER (TRUE
));
2945 g_hash_table_insert (key_table
, (char *) "not_in_gc_heap", GINT_TO_POINTER (TRUE
));
2946 g_hash_table_insert (key_table
, (char *) "notremotable", GINT_TO_POINTER (TRUE
));
2947 g_hash_table_insert (key_table
, (char *) "notserialized", GINT_TO_POINTER (TRUE
));
2948 g_hash_table_insert (key_table
, (char *) "null", GINT_TO_POINTER (TRUE
));
2949 g_hash_table_insert (key_table
, (char *) "nullref", GINT_TO_POINTER (TRUE
));
2950 g_hash_table_insert (key_table
, (char *) "object", GINT_TO_POINTER (TRUE
));
2951 g_hash_table_insert (key_table
, (char *) "objectref", GINT_TO_POINTER (TRUE
));
2952 g_hash_table_insert (key_table
, (char *) "off", GINT_TO_POINTER (TRUE
));
2953 g_hash_table_insert (key_table
, (char *) "on", GINT_TO_POINTER (TRUE
));
2954 g_hash_table_insert (key_table
, (char *) "opt", GINT_TO_POINTER (TRUE
));
2955 g_hash_table_insert (key_table
, (char *) "optil", GINT_TO_POINTER (TRUE
));
2956 g_hash_table_insert (key_table
, (char *) "or", GINT_TO_POINTER (TRUE
));
2957 g_hash_table_insert (key_table
, (char *) "out", GINT_TO_POINTER (TRUE
));
2958 g_hash_table_insert (key_table
, (char *) "permitonly", GINT_TO_POINTER (TRUE
));
2959 g_hash_table_insert (key_table
, (char *) "pinned", GINT_TO_POINTER (TRUE
));
2960 g_hash_table_insert (key_table
, (char *) "pinvokeimpl", GINT_TO_POINTER (TRUE
));
2961 g_hash_table_insert (key_table
, (char *) "pop", GINT_TO_POINTER (TRUE
));
2962 g_hash_table_insert (key_table
, (char *) "prefix1", GINT_TO_POINTER (TRUE
));
2963 g_hash_table_insert (key_table
, (char *) "prefix2", GINT_TO_POINTER (TRUE
));
2964 g_hash_table_insert (key_table
, (char *) "prefix3", GINT_TO_POINTER (TRUE
));
2965 g_hash_table_insert (key_table
, (char *) "prefix4", GINT_TO_POINTER (TRUE
));
2966 g_hash_table_insert (key_table
, (char *) "prefix5", GINT_TO_POINTER (TRUE
));
2967 g_hash_table_insert (key_table
, (char *) "prefix6", GINT_TO_POINTER (TRUE
));
2968 g_hash_table_insert (key_table
, (char *) "prefix7", GINT_TO_POINTER (TRUE
));
2969 g_hash_table_insert (key_table
, (char *) "prefixref", GINT_TO_POINTER (TRUE
));
2970 g_hash_table_insert (key_table
, (char *) "prejitdeny", GINT_TO_POINTER (TRUE
));
2971 g_hash_table_insert (key_table
, (char *) "prejitgrant", GINT_TO_POINTER (TRUE
));
2972 g_hash_table_insert (key_table
, (char *) "preservesig", GINT_TO_POINTER (TRUE
));
2973 g_hash_table_insert (key_table
, (char *) "private", GINT_TO_POINTER (TRUE
));
2974 g_hash_table_insert (key_table
, (char *) "privatescope", GINT_TO_POINTER (TRUE
));
2975 g_hash_table_insert (key_table
, (char *) "property", GINT_TO_POINTER (TRUE
));
2976 g_hash_table_insert (key_table
, (char *) "protected", GINT_TO_POINTER (TRUE
));
2977 g_hash_table_insert (key_table
, (char *) "public", GINT_TO_POINTER (TRUE
));
2978 g_hash_table_insert (key_table
, (char *) "readonly", GINT_TO_POINTER (TRUE
));
2979 g_hash_table_insert (key_table
, (char *) "record", GINT_TO_POINTER (TRUE
));
2980 g_hash_table_insert (key_table
, (char *) "refany", GINT_TO_POINTER (TRUE
));
2981 g_hash_table_insert (key_table
, (char *) "refanytype", GINT_TO_POINTER (TRUE
));
2982 g_hash_table_insert (key_table
, (char *) "refanyval", GINT_TO_POINTER (TRUE
));
2983 g_hash_table_insert (key_table
, (char *) "rem", GINT_TO_POINTER (TRUE
));
2984 g_hash_table_insert (key_table
, (char *) "rem.un", GINT_TO_POINTER (TRUE
));
2985 g_hash_table_insert (key_table
, (char *) "reqmin", GINT_TO_POINTER (TRUE
));
2986 g_hash_table_insert (key_table
, (char *) "reqopt", GINT_TO_POINTER (TRUE
));
2987 g_hash_table_insert (key_table
, (char *) "reqrefuse", GINT_TO_POINTER (TRUE
));
2988 g_hash_table_insert (key_table
, (char *) "reqsecobj", GINT_TO_POINTER (TRUE
));
2989 g_hash_table_insert (key_table
, (char *) "request", GINT_TO_POINTER (TRUE
));
2990 g_hash_table_insert (key_table
, (char *) "ret", GINT_TO_POINTER (TRUE
));
2991 g_hash_table_insert (key_table
, (char *) "rethrow", GINT_TO_POINTER (TRUE
));
2992 g_hash_table_insert (key_table
, (char *) "retval", GINT_TO_POINTER (TRUE
));
2993 g_hash_table_insert (key_table
, (char *) "rtspecialname", GINT_TO_POINTER (TRUE
));
2994 g_hash_table_insert (key_table
, (char *) "runtime", GINT_TO_POINTER (TRUE
));
2995 g_hash_table_insert (key_table
, (char *) "safearray", GINT_TO_POINTER (TRUE
));
2996 g_hash_table_insert (key_table
, (char *) "sealed", GINT_TO_POINTER (TRUE
));
2997 g_hash_table_insert (key_table
, (char *) "sequential", GINT_TO_POINTER (TRUE
));
2998 g_hash_table_insert (key_table
, (char *) "serializable", GINT_TO_POINTER (TRUE
));
2999 g_hash_table_insert (key_table
, (char *) "shl", GINT_TO_POINTER (TRUE
));
3000 g_hash_table_insert (key_table
, (char *) "shr", GINT_TO_POINTER (TRUE
));
3001 g_hash_table_insert (key_table
, (char *) "shr.un", GINT_TO_POINTER (TRUE
));
3002 g_hash_table_insert (key_table
, (char *) "sizeof", GINT_TO_POINTER (TRUE
));
3003 g_hash_table_insert (key_table
, (char *) "special", GINT_TO_POINTER (TRUE
));
3004 g_hash_table_insert (key_table
, (char *) "specialname", GINT_TO_POINTER (TRUE
));
3005 g_hash_table_insert (key_table
, (char *) "starg", GINT_TO_POINTER (TRUE
));
3006 g_hash_table_insert (key_table
, (char *) "starg.s", GINT_TO_POINTER (TRUE
));
3007 g_hash_table_insert (key_table
, (char *) "static", GINT_TO_POINTER (TRUE
));
3008 g_hash_table_insert (key_table
, (char *) "stdcall", GINT_TO_POINTER (TRUE
));
3009 g_hash_table_insert (key_table
, (char *) "stelem", GINT_TO_POINTER (TRUE
));
3010 g_hash_table_insert (key_table
, (char *) "stelem.i1", GINT_TO_POINTER (TRUE
));
3011 g_hash_table_insert (key_table
, (char *) "stelem.i2", GINT_TO_POINTER (TRUE
));
3012 g_hash_table_insert (key_table
, (char *) "stelem.i4", GINT_TO_POINTER (TRUE
));
3013 g_hash_table_insert (key_table
, (char *) "stelem.i8", GINT_TO_POINTER (TRUE
));
3014 g_hash_table_insert (key_table
, (char *) "stelem.i", GINT_TO_POINTER (TRUE
));
3015 g_hash_table_insert (key_table
, (char *) "stelem.r4", GINT_TO_POINTER (TRUE
));
3016 g_hash_table_insert (key_table
, (char *) "stelem.r8", GINT_TO_POINTER (TRUE
));
3017 g_hash_table_insert (key_table
, (char *) "stelem.ref", GINT_TO_POINTER (TRUE
));
3018 g_hash_table_insert (key_table
, (char *) "stfld", GINT_TO_POINTER (TRUE
));
3019 g_hash_table_insert (key_table
, (char *) "stind.i1", GINT_TO_POINTER (TRUE
));
3020 g_hash_table_insert (key_table
, (char *) "stind.i2", GINT_TO_POINTER (TRUE
));
3021 g_hash_table_insert (key_table
, (char *) "stind.i4", GINT_TO_POINTER (TRUE
));
3022 g_hash_table_insert (key_table
, (char *) "stind.i8", GINT_TO_POINTER (TRUE
));
3023 g_hash_table_insert (key_table
, (char *) "stind.i", GINT_TO_POINTER (TRUE
));
3024 g_hash_table_insert (key_table
, (char *) "stind.r4", GINT_TO_POINTER (TRUE
));
3025 g_hash_table_insert (key_table
, (char *) "stind.r8", GINT_TO_POINTER (TRUE
));
3026 g_hash_table_insert (key_table
, (char *) "stloc", GINT_TO_POINTER (TRUE
));
3027 g_hash_table_insert (key_table
, (char *) "stobj", GINT_TO_POINTER (TRUE
));
3028 g_hash_table_insert (key_table
, (char *) "storage", GINT_TO_POINTER (TRUE
));
3029 g_hash_table_insert (key_table
, (char *) "stored_object", GINT_TO_POINTER (TRUE
));
3030 g_hash_table_insert (key_table
, (char *) "streamed_object", GINT_TO_POINTER (TRUE
));
3031 g_hash_table_insert (key_table
, (char *) "stream", GINT_TO_POINTER (TRUE
));
3032 g_hash_table_insert (key_table
, (char *) "strict", GINT_TO_POINTER (TRUE
));
3033 g_hash_table_insert (key_table
, (char *) "string", GINT_TO_POINTER (TRUE
));
3034 g_hash_table_insert (key_table
, (char *) "struct", GINT_TO_POINTER (TRUE
));
3035 g_hash_table_insert (key_table
, (char *) "stsfld", GINT_TO_POINTER (TRUE
));
3036 g_hash_table_insert (key_table
, (char *) "sub", GINT_TO_POINTER (TRUE
));
3037 g_hash_table_insert (key_table
, (char *) "sub.ovf", GINT_TO_POINTER (TRUE
));
3038 g_hash_table_insert (key_table
, (char *) "sub.ovf.un", GINT_TO_POINTER (TRUE
));
3039 g_hash_table_insert (key_table
, (char *) "switch", GINT_TO_POINTER (TRUE
));
3040 g_hash_table_insert (key_table
, (char *) "synchronized", GINT_TO_POINTER (TRUE
));
3041 g_hash_table_insert (key_table
, (char *) "syschar", GINT_TO_POINTER (TRUE
));
3042 g_hash_table_insert (key_table
, (char *) "sysstring", GINT_TO_POINTER (TRUE
));
3043 g_hash_table_insert (key_table
, (char *) "tbstr", GINT_TO_POINTER (TRUE
));
3044 g_hash_table_insert (key_table
, (char *) "thiscall", GINT_TO_POINTER (TRUE
));
3045 g_hash_table_insert (key_table
, (char *) "tls", GINT_TO_POINTER (TRUE
));
3046 g_hash_table_insert (key_table
, (char *) "to", GINT_TO_POINTER (TRUE
));
3047 g_hash_table_insert (key_table
, (char *) "true", GINT_TO_POINTER (TRUE
));
3048 g_hash_table_insert (key_table
, (char *) "type", GINT_TO_POINTER (TRUE
));
3049 g_hash_table_insert (key_table
, (char *) "typedref", GINT_TO_POINTER (TRUE
));
3050 g_hash_table_insert (key_table
, (char *) "uint", GINT_TO_POINTER (TRUE
));
3051 g_hash_table_insert (key_table
, (char *) "uint8", GINT_TO_POINTER (TRUE
));
3052 g_hash_table_insert (key_table
, (char *) "uint16", GINT_TO_POINTER (TRUE
));
3053 g_hash_table_insert (key_table
, (char *) "uint32", GINT_TO_POINTER (TRUE
));
3054 g_hash_table_insert (key_table
, (char *) "uint64", GINT_TO_POINTER (TRUE
));
3055 g_hash_table_insert (key_table
, (char *) "unbox", GINT_TO_POINTER (TRUE
));
3056 g_hash_table_insert (key_table
, (char *) "unicode", GINT_TO_POINTER (TRUE
));
3057 g_hash_table_insert (key_table
, (char *) "unmanagedexp", GINT_TO_POINTER (TRUE
));
3058 g_hash_table_insert (key_table
, (char *) "unmanaged", GINT_TO_POINTER (TRUE
));
3059 g_hash_table_insert (key_table
, (char *) "unsigned", GINT_TO_POINTER (TRUE
));
3060 g_hash_table_insert (key_table
, (char *) "userdefined", GINT_TO_POINTER (TRUE
));
3061 g_hash_table_insert (key_table
, (char *) "value", GINT_TO_POINTER (TRUE
));
3062 g_hash_table_insert (key_table
, (char *) "valuetype", GINT_TO_POINTER (TRUE
));
3063 g_hash_table_insert (key_table
, (char *) "vararg", GINT_TO_POINTER (TRUE
));
3064 g_hash_table_insert (key_table
, (char *) "variant", GINT_TO_POINTER (TRUE
));
3065 g_hash_table_insert (key_table
, (char *) "vector", GINT_TO_POINTER (TRUE
));
3066 g_hash_table_insert (key_table
, (char *) "virtual", GINT_TO_POINTER (TRUE
));
3067 g_hash_table_insert (key_table
, (char *) "void", GINT_TO_POINTER (TRUE
));
3068 g_hash_table_insert (key_table
, (char *) "wchar", GINT_TO_POINTER (TRUE
));
3069 g_hash_table_insert (key_table
, (char *) "winapi", GINT_TO_POINTER (TRUE
));
3070 g_hash_table_insert (key_table
, (char *) "with", GINT_TO_POINTER (TRUE
));
3071 g_hash_table_insert (key_table
, (char *) "xor", GINT_TO_POINTER (TRUE
));
3075 method_dor_to_token (guint32 idx
) {
3076 switch (idx
& MONO_METHODDEFORREF_MASK
) {
3077 case MONO_METHODDEFORREF_METHODDEF
:
3078 return MONO_TOKEN_METHOD_DEF
| (idx
>> MONO_METHODDEFORREF_BITS
);
3079 case MONO_METHODDEFORREF_METHODREF
:
3080 return MONO_TOKEN_MEMBER_REF
| (idx
>> MONO_METHODDEFORREF_BITS
);
3086 get_method_override (MonoImage
*m
, guint32 token
, MonoGenericContainer
*container
)
3088 MonoTableInfo
*t
= &m
->tables
[MONO_TABLE_METHODIMPL
];
3091 for (i
= 1; i
<= t
->rows
; i
++){
3092 guint32 cols
[MONO_METHODIMPL_SIZE
];
3095 mono_metadata_decode_row (t
, i
- 1, cols
, MONO_METHODIMPL_SIZE
);
3097 impl
= method_dor_to_token (cols
[MONO_METHODIMPL_BODY
]);
3098 decl
= method_dor_to_token (cols
[MONO_METHODIMPL_DECLARATION
]);
3100 if (token
== impl
) {
3101 MonoMethod
*mh
= NULL
;
3102 mh
= mono_get_method_full (m
, decl
, NULL
, (MonoGenericContext
*) container
);
3104 if (mh
&& (mh
->klass
&& (mh
->klass
->generic_class
|| mh
->klass
->generic_container
))) {
3108 meth_str
= get_method_core (m
, decl
, TRUE
, container
);
3109 ret
= g_strdup_printf ("method %s", meth_str
);
3113 return get_method_core (m
, decl
, FALSE
, container
);
3122 check_ambiguous_genparams (MonoGenericContainer
*container
)
3124 GSList
*dup_list
= NULL
, *l
;
3125 GHashTable
*table
= NULL
;
3132 if (generic_containers
&& g_hash_table_lookup (generic_containers
, container
))
3133 /* Already been checked for ambiguous gen params */
3136 table
= g_hash_table_new (g_str_hash
, g_str_equal
);
3137 for (i
= 0; i
< container
->type_argc
; i
++) {
3138 MonoGenericParam
*param
= mono_generic_container_get_param (container
, i
);
3140 if ((p
= g_hash_table_lookup (table
, mono_generic_param_info (param
)->name
)))
3141 dup_list
= g_slist_prepend (g_slist_prepend (dup_list
, GUINT_TO_POINTER (i
+ 1)), p
);
3143 g_hash_table_insert (table
, (char*)mono_generic_param_info (param
)->name
, GUINT_TO_POINTER (i
+ 1));
3147 if (!mono_generic_params_with_ambiguous_names
)
3148 mono_generic_params_with_ambiguous_names
= g_hash_table_new (NULL
, NULL
);
3149 for (l
= dup_list
; l
; l
= l
->next
) {
3150 int param
= GPOINTER_TO_UINT (l
->data
);
3151 g_hash_table_insert (mono_generic_params_with_ambiguous_names
,
3152 mono_generic_container_get_param (container
, param
-1),
3153 mono_generic_container_get_param (container
, param
-1));
3155 g_slist_free (dup_list
);
3158 if (!generic_containers
)
3159 generic_containers
= g_hash_table_new (NULL
, NULL
);
3161 g_hash_table_insert (generic_containers
, container
, container
);
3162 g_hash_table_destroy (table
);
3166 cant_print_generic_param_name (MonoGenericParam
*gparam
)
3168 MonoGenericContainer
*container
;
3171 container
= mono_generic_param_owner (gparam
);
3172 check_ambiguous_genparams (container
);
3173 return (!container
|| (mono_generic_params_with_ambiguous_names
&&
3174 g_hash_table_lookup (mono_generic_params_with_ambiguous_names
, gparam
)));
3178 static dis_map_t method_impl_map
[] = {
3179 { METHOD_IMPL_ATTRIBUTE_IL
, "cil " },
3180 { METHOD_IMPL_ATTRIBUTE_NATIVE
, "native " },
3181 { METHOD_IMPL_ATTRIBUTE_OPTIL
, "optil " },
3182 { METHOD_IMPL_ATTRIBUTE_RUNTIME
, "runtime " },
3186 static dis_map_t managed_type_map
[] = {
3187 { METHOD_IMPL_ATTRIBUTE_UNMANAGED
, "unmanaged " },
3188 { METHOD_IMPL_ATTRIBUTE_MANAGED
, "managed " },
3192 static dis_map_t managed_impl_flags
[] = {
3193 { METHOD_IMPL_ATTRIBUTE_FORWARD_REF
, "fwdref " },
3194 { METHOD_IMPL_ATTRIBUTE_PRESERVE_SIG
, "preservesig " },
3195 { METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL
, "internalcall " },
3196 { METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED
, "synchronized " },
3197 { METHOD_IMPL_ATTRIBUTE_NOINLINING
, "noinlining " },
3198 { METHOD_IMPL_ATTRIBUTE_NOOPTIMIZATION
, "nooptimization " },
3199 { METHOD_IMPL_ATTRIBUTE_AGGRESSIVE_INLINING
, "agressive-inlining" },
3204 get_method_impl_flags (guint32 f
)
3206 GString
*str
= g_string_new ("");
3208 int code_type
= f
& METHOD_IMPL_ATTRIBUTE_CODE_TYPE_MASK
;
3209 int managed_type
= f
& METHOD_IMPL_ATTRIBUTE_MANAGED_MASK
;
3210 int rest
= f
& ~(code_type
| managed_type
);
3212 g_string_append (str
, map (code_type
, method_impl_map
));
3213 g_string_append (str
, map (managed_type
, managed_type_map
));
3214 g_string_append (str
, flags (rest
, managed_impl_flags
));
3217 g_string_free (str
, FALSE
);