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
9 * Licensed under the MIT license. See LICENSE file in the project root for full license information.
21 #include <mono/utils/mono-compiler.h>
22 #include <mono/metadata/class.h>
23 #include <mono/metadata/marshal.h>
24 #include <mono/metadata/metadata-internals.h>
25 #include <mono/utils/mono-math.h>
27 extern gboolean substitute_with_mscorlib_p
;
30 get_token_comment (const char *prefix
, guint32 token
);
32 static MonoGenericContainer
*
33 get_memberref_container (MonoImage
*m
, guint32 mrp_token
, MonoGenericContainer
*container
, MonoError
*error
);
36 get_memberref_parent (MonoImage
*m
, guint32 mrp_token
, MonoGenericContainer
*container
);
39 cant_print_generic_param_name (MonoGenericParam
*gparam
);
41 GHashTable
*key_table
= NULL
;
42 GHashTable
*mono_generic_params_with_ambiguous_names
= NULL
;
43 GHashTable
*generic_containers
= NULL
;
44 gboolean show_method_tokens
= FALSE
;
45 gboolean show_tokens
= FALSE
;
48 get_typedef (MonoImage
*m
, int idx
)
50 guint32 cols
[MONO_TYPEDEF_SIZE
];
52 char *tstring
, *result
;
59 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_TYPEDEF
], idx
- 1, cols
, MONO_TYPEDEF_SIZE
);
61 ns
= mono_metadata_string_heap (m
, cols
[MONO_TYPEDEF_NAMESPACE
]);
63 /* Check if this is a nested type */
64 token
= MONO_TOKEN_TYPE_DEF
| (idx
);
65 token
= mono_metadata_nested_in_typedef (m
, token
);
66 tstring
= get_token_comment (NULL
, token
);
70 outer
= get_typedef (m
, mono_metadata_token_index (token
));
71 result
= g_strdup_printf (
73 mono_metadata_string_heap (m
, cols
[MONO_TYPEDEF_NAME
]),
74 tstring
? tstring
: "");
81 result
= g_strdup_printf (
82 "%s%s%s%s", ns
, *ns
?".":"",
83 mono_metadata_string_heap (m
, cols
[MONO_TYPEDEF_NAME
]),
84 tstring
? tstring
: "");
91 get_module (MonoImage
*m
, int idx
)
93 guint32 cols
[MONO_MODULE_SIZE
];
96 * There MUST BE only one module in the Module table
100 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MODULE
], idx
- 1, cols
, MONO_MODULE_SIZE
);
102 return get_escaped_name (mono_metadata_string_heap (m
, cols
[MONO_MODULE_NAME
]));
106 get_moduleref (MonoImage
*m
, int idx
)
108 guint32 cols
[MONO_MODULEREF_SIZE
];
110 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MODULEREF
], idx
- 1, cols
, MONO_MODULEREF_SIZE
);
112 return get_escaped_name (mono_metadata_string_heap (m
, cols
[MONO_MODULEREF_NAME
]));
116 get_assemblyref (MonoImage
*m
, int idx
)
118 guint32 cols
[MONO_ASSEMBLYREF_SIZE
];
120 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_ASSEMBLYREF
], idx
- 1, cols
, MONO_ASSEMBLYREF_SIZE
);
122 return get_escaped_name (mono_metadata_string_heap (m
, cols
[MONO_ASSEMBLYREF_NAME
]));
126 stringify_array (guint32 rank
, guint32 num_sizes
, guint32 num_lo_bounds
, gint32
*sizes
, gint32
*lo_bounds
)
128 GString
*res
= g_string_new ("[");
131 for (i
= 0; i
< rank
; i
++) {
133 g_string_append_c (res
, ',');
134 if (i
< num_lo_bounds
)
135 g_string_append_printf (res
, "%d...", lo_bounds
[i
]);
137 if (i
< num_lo_bounds
)
138 g_string_append_printf (res
, "%d", lo_bounds
[i
] + sizes
[i
] - 1);
140 g_string_append_printf (res
, "%d", sizes
[i
]);
144 g_string_append (res
, "]");
146 return g_string_free (res
, FALSE
);
151 * Returns a string representing the ArrayShape (22.2.16).
154 get_array_shape (MonoImage
*m
, const char *ptr
, char **result
)
156 guint32 rank
, num_sizes
, num_lo_bounds
;
157 gint32
*sizes
= NULL
, *lo_bounds
= NULL
;
160 rank
= mono_metadata_decode_value (ptr
, &ptr
);
161 num_sizes
= mono_metadata_decode_value (ptr
, &ptr
);
164 sizes
= g_new (gint32
, num_sizes
);
166 for (i
= 0; i
< num_sizes
; i
++)
167 sizes
[i
] = mono_metadata_decode_value (ptr
, &ptr
);
169 num_lo_bounds
= mono_metadata_decode_value (ptr
, &ptr
);
170 if (num_lo_bounds
> 0)
171 lo_bounds
= g_new (gint32
, num_lo_bounds
);
173 for (i
= 0; i
< num_lo_bounds
; i
++)
174 lo_bounds
[i
] = mono_metadata_decode_signed_value (ptr
, &ptr
);
176 *result
= stringify_array (rank
, num_sizes
, num_lo_bounds
, sizes
, lo_bounds
);
186 * @m: metadata context
187 * @blob_idx: index into the blob heap
189 * Returns the stringified representation of a TypeSpec signature (22.2.17)
192 get_typespec (MonoImage
*m
, guint32 idx
, gboolean is_def
, MonoGenericContainer
*container
)
194 guint32 cols
[MONO_TYPESPEC_SIZE
];
197 GString
*res
= g_string_new ("");
198 MonoMethodSignature
*sig
;
200 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_TYPESPEC
], idx
-1, cols
, MONO_TYPESPEC_SIZE
);
201 ptr
= mono_metadata_blob_heap (m
, cols
[MONO_TYPESPEC_SIGNATURE
]);
202 /* len = */ mono_metadata_decode_value (ptr
, &ptr
);
206 ptr
= get_custom_mod (m
, ptr
, &s
);
208 g_string_append (res
, s
);
209 g_string_append_c (res
, ' ');
213 if (*ptr
== MONO_TYPE_VOID
)
214 g_string_append (res
, "void");
216 ptr
= get_type (m
, ptr
, &s
, is_def
, container
);
218 g_string_append (res
, s
);
220 g_string_append (res
, "*");
223 case MONO_TYPE_FNPTR
: {
225 sig
= mono_metadata_parse_method_signature_full (m
, container
, 0, ptr
, &ptr
, error
);
226 g_assert (mono_error_ok (error
)); /*FIXME don't swallow the error message*/
227 s
= dis_stringify_function_ptr (m
, sig
);
228 g_string_append (res
, "method ");
229 g_string_append (res
, s
);
233 case MONO_TYPE_ARRAY
:
234 ptr
= get_type (m
, ptr
, &s
, is_def
, container
);
235 g_string_append (res
, s
);
237 g_string_append_c (res
, ' ');
238 ptr
= get_array_shape (m
, ptr
, &s
);
239 g_string_append (res
, s
);
243 case MONO_TYPE_SZARRAY
:
244 ptr
= get_custom_mod (m
, ptr
, &s
);
246 g_string_append (res
, s
);
247 g_string_append_c (res
, ' ');
250 ptr
= get_type (m
, ptr
, &s
, is_def
, container
);
251 g_string_append (res
, s
);
252 g_string_append (res
, "[]");
257 ptr
= get_type (m
, ptr
- 1, &s
, is_def
, container
);
258 g_string_append (res
, s
);
264 int token
= mono_metadata_make_token (MONO_TABLE_TYPESPEC
, idx
);
265 result
= get_token_comment (res
->str
, token
);
266 g_string_free (res
, TRUE
);
269 g_string_free (res
, FALSE
);
276 get_typeref (MonoImage
*m
, int idx
)
278 guint32 cols
[MONO_TYPEREF_SIZE
];
281 guint32 rs_idx
, table
;
283 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_TYPEREF
], idx
- 1, cols
, MONO_TYPEREF_SIZE
);
285 t
= mono_metadata_string_heap (m
, cols
[MONO_TYPEREF_NAME
]);
286 s
= mono_metadata_string_heap (m
, cols
[MONO_TYPEREF_NAMESPACE
]);
288 rs_idx
= cols
[MONO_TYPEREF_SCOPE
] >> MONO_RESOLTION_SCOPE_BITS
;
289 table
= cols
[MONO_TYPEREF_SCOPE
] & MONO_RESOLTION_SCOPE_MASK
;
292 case MONO_RESOLTION_SCOPE_MODULE
: /* Module */
293 x
= get_module (m
, rs_idx
);
294 ret
= g_strdup_printf ("[%s] %s%s%s", x
, s
, *s
?".":"", t
);
298 case MONO_RESOLTION_SCOPE_MODULEREF
: /* ModuleRef */
299 x
= get_moduleref (m
, rs_idx
);
300 ret
= g_strdup_printf ("[.module %s]%s%s%s", x
, s
, *s
? "." : "", t
);
303 case MONO_RESOLTION_SCOPE_ASSEMBLYREF
: /*
304 * AssemblyRef (ECMA docs claim it is 3, but it looks to
305 * me like it is 2 (tokens are prefixed with 0x23)
307 x
= get_assemblyref (m
, rs_idx
);
308 ret
= g_strdup_printf ("[%s]%s%s%s", x
, s
, *s
?".":"", t
);
312 case MONO_RESOLTION_SCOPE_TYPEREF
: /* TypeRef */
313 x
= get_typeref (m
, rs_idx
);
314 ret
= g_strdup_printf ("%s/%s", x
, t
);
319 ret
= g_strdup_printf ("Unknown table in TypeRef %d", table
);
323 int token
= mono_metadata_make_token (MONO_TABLE_TYPEREF
, idx
);
324 char *temp
= get_token_comment (ret
, token
);
333 * get_typedef_or_ref:
334 * @m: metadata context
335 * @dor_token: def or ref encoded index
337 * Low two bits contain table to lookup from
338 * high bits contain the index into the def or ref table
340 * Returns: a stringified version of the MethodDef or MethodRef
341 * at (dor_token >> 2)
344 get_typedef_or_ref (MonoImage
*m
, guint32 dor_token
, MonoGenericContainer
*container
)
346 char *temp
= NULL
, *s
= NULL
;
350 * low 2 bits contain encoding
352 table
= dor_token
& MONO_TYPEDEFORREF_MASK
;
353 idx
= dor_token
>> MONO_TYPEDEFORREF_BITS
;
356 case 0: /* TypeDef */
357 temp
= get_typedef (m
, idx
);
358 s
= g_strdup_printf ("%s", temp
);
361 case 1: /* TypeRef */
362 temp
= get_typeref (m
, idx
);
363 s
= g_strdup_printf ("%s", temp
);
366 case 2: /* TypeSpec */
367 s
= get_typespec (m
, idx
, FALSE
, container
);
371 g_error ("Unhandled encoding for typedef-or-ref coded index 0x%08x", dor_token
);
381 * get_type_or_methdef
382 * @m: metadata context
383 * @dor_token: type or method def encoded index
385 * Low bit contains the table to lookup from
386 * high bits contain the index into the type def or method def table
388 * Returns: a stringified version of the TypeOrMethodDef token
391 get_type_or_methdef (MonoImage
*m
, guint32 dor_token
)
393 if (dor_token
& MONO_TYPEORMETHOD_METHOD
) /* MethodDef */
394 return get_methoddef (m
, dor_token
>> MONO_TYPEORMETHOD_BITS
);
396 return get_typedef (m
, dor_token
>> MONO_TYPEORMETHOD_BITS
);
400 * get_encoded_typedef_or_ref:
401 * @m: metadata context
402 * @ptr: location to decode from.
403 * @result: pointer to string where resulting decoded string is stored
405 * result will point to a g_malloc()ed string.
407 * Returns: the new ptr to continue decoding
410 get_encoded_typedef_or_ref (MonoImage
*m
, const char *ptr
, char **result
)
414 token
= mono_metadata_decode_value (ptr
, &ptr
);
416 *result
= get_typedef_or_ref (m
, token
, NULL
);
424 * Decodes a CustomMod (22.2.7)
426 * Returns: updated pointer location
429 get_custom_mod (MonoImage
*m
, const char *ptr
, char **return_value
)
434 *return_value
= NULL
;
435 while ((*ptr
== MONO_TYPE_CMOD_OPT
) ||
436 (*ptr
== MONO_TYPE_CMOD_REQD
)) {
437 mod
= (*ptr
== MONO_TYPE_CMOD_REQD
) ? "modreq" : "modopt";
439 ptr
= get_encoded_typedef_or_ref (m
, ptr
, &s
);
441 /* cmods are encoded in reverse order from how we want to print them.
442 * "int32 modopt (Foo) modopt (Bar)" is encoded as "cmod_opt [typedef_or_ref "Bar"] cmod_opt [typedef_or_ref "Foo"] I4"
444 if (*return_value
== NULL
)
445 *return_value
= g_strconcat (" ", mod
, " (", s
, ")", NULL
);
447 *return_value
= g_strconcat (mod
, " (", s
, ") ", *return_value
, NULL
);
454 static dis_map_t element_type_map
[] = {
455 { MONO_TYPE_END
, "end" },
456 { MONO_TYPE_VOID
, "void" },
457 { MONO_TYPE_BOOLEAN
, "bool" },
458 { MONO_TYPE_CHAR
, "char" },
459 { MONO_TYPE_I1
, "int8" },
460 { MONO_TYPE_U1
, "unsigned int8" },
461 { MONO_TYPE_I2
, "int16" },
462 { MONO_TYPE_U2
, "unsigned int16" },
463 { MONO_TYPE_I4
, "int32" },
464 { MONO_TYPE_U4
, "unsigned int32" },
465 { MONO_TYPE_I8
, "int64" },
466 { MONO_TYPE_U8
, "unsigned int64" },
467 { MONO_TYPE_R4
, "float32" },
468 { MONO_TYPE_R8
, "float64" },
469 { MONO_TYPE_STRING
, "string" },
470 { MONO_TYPE_TYPEDBYREF
, "typedref" },
471 { MONO_TYPE_I
, "native int" },
472 { MONO_TYPE_U
, "native unsigned int" },
473 { MONO_TYPE_OBJECT
, "object" },
477 static dis_map_t call_conv_type_map
[] = {
478 { MONO_CALL_DEFAULT
, "default" },
479 { MONO_CALL_C
, "unmanaged cdecl" },
480 { MONO_CALL_STDCALL
, "unmanaged stdcall" },
481 { MONO_CALL_THISCALL
, "unmanaged thiscall" },
482 { MONO_CALL_FASTCALL
, "unmanaged fastcall" },
483 { MONO_CALL_VARARG
, "vararg" },
488 dis_stringify_token (MonoImage
*m
, guint32 token
)
490 guint idx
= token
& 0xffffff;
491 switch (token
>> 24) {
492 case MONO_TABLE_TYPEDEF
: return get_typedef (m
, idx
);
493 case MONO_TABLE_TYPEREF
: return get_typeref (m
, idx
);
494 case MONO_TABLE_TYPESPEC
: return get_typespec (m
, idx
, FALSE
, NULL
);
498 return g_strdup_printf("0x%08x", token
);
502 dis_stringify_array (MonoImage
*m
, MonoArrayType
*array
, gboolean is_def
)
504 char *type
, *arr_str
, *ret
;
506 type
= dis_stringify_type (m
, m_class_get_byval_arg (array
->eklass
), is_def
);
507 arr_str
= stringify_array (array
->rank
, array
->numsizes
, array
->numlobounds
, array
->sizes
, array
->lobounds
);
509 ret
= g_strconcat (type
, arr_str
, NULL
);
517 dis_stringify_modifiers (MonoImage
*m
, int n
, MonoCustomMod
*mod
)
519 GString
*s
= g_string_new("");
522 for (i
= 0; i
< n
; ++i
) {
523 char *tok
= dis_stringify_token (m
, mod
[i
].token
);
525 g_string_append_printf (s
, " ");
526 g_string_append_printf (s
, " %s (%s)", mod
[i
].required
? "modreq": "modopt", tok
);
529 g_string_append_c (s
, ' ');
531 g_string_free (s
, FALSE
);
536 dis_stringify_param (MonoImage
*m
, MonoType
*param
)
541 const char *in
= param
->attrs
& PARAM_ATTRIBUTE_IN
? "[in]" : "";
542 const char *out
= param
->attrs
& PARAM_ATTRIBUTE_OUT
? "[out]": "";
543 const char *opt
= param
->attrs
& PARAM_ATTRIBUTE_OPTIONAL
? "[opt]": "";
544 attribs
= g_strconcat(in
, out
, opt
, NULL
);
545 t
= dis_stringify_type (m
, param
, TRUE
);
546 result
= g_strjoin(attribs
[0] ? " ":"", attribs
, t
, NULL
);
553 dis_stringify_variant_type (MonoMarshalVariant variant
)
556 case MONO_VARIANT_EMPTY
:
557 return g_strdup ("");
558 case MONO_VARIANT_NULL
:
559 return g_strdup ("null");
560 case MONO_VARIANT_I2
:
561 return g_strdup ("int16");
562 case MONO_VARIANT_I4
:
563 return g_strdup ("int32");
564 case MONO_VARIANT_R4
:
565 return g_strdup ("float32");
566 case MONO_VARIANT_R8
:
567 return g_strdup ("float64");
568 case MONO_VARIANT_CY
:
569 return g_strdup ("currency");
570 case MONO_VARIANT_DATE
:
571 return g_strdup ("date");
572 case MONO_VARIANT_BSTR
:
573 return g_strdup ("bstr");
574 case MONO_VARIANT_DISPATCH
:
575 return g_strdup ("idispatch");
576 case MONO_VARIANT_ERROR
:
577 return g_strdup ("error");
578 case MONO_VARIANT_BOOL
:
579 return g_strdup ("bool");
580 case MONO_VARIANT_VARIANT
:
581 return g_strdup ("variant");
582 case MONO_VARIANT_UNKNOWN
:
583 return g_strdup ("iunknown");
584 case MONO_VARIANT_DECIMAL
:
585 return g_strdup ("decimal");
586 case MONO_VARIANT_I1
:
587 return g_strdup ("int8");
588 case MONO_VARIANT_UI1
:
589 return g_strdup ("unsigned int8");
590 case MONO_VARIANT_UI2
:
591 return g_strdup ("unsigned int16");
592 case MONO_VARIANT_UI4
:
593 return g_strdup ("unsigned int32");
594 case MONO_VARIANT_I8
:
595 return g_strdup ("int64");
596 case MONO_VARIANT_UI8
:
597 return g_strdup ("unsigned int64");
598 case MONO_VARIANT_INT
:
599 return g_strdup ("int");
600 case MONO_VARIANT_UINT
:
601 return g_strdup ("unsigned int");
602 case MONO_VARIANT_VOID
:
603 return g_strdup ("void");
604 case MONO_VARIANT_HRESULT
:
605 return g_strdup ("hresult");
606 case MONO_VARIANT_PTR
:
607 return g_strdup ("*");
608 case MONO_VARIANT_SAFEARRAY
:
609 return g_strdup ("safearray");
610 case MONO_VARIANT_CARRAY
:
611 return g_strdup ("carray");
612 case MONO_VARIANT_USERDEFINED
:
613 return g_strdup ("userdefined");
614 case MONO_VARIANT_LPSTR
:
615 return g_strdup ("lpstr");
616 case MONO_VARIANT_LPWSTR
:
617 return g_strdup ("lpwstr");
618 case MONO_VARIANT_RECORD
:
619 return g_strdup ("record");
620 case MONO_VARIANT_FILETIME
:
621 return g_strdup ("filetime");
622 case MONO_VARIANT_BLOB
:
623 return g_strdup ("blob");
624 case MONO_VARIANT_STREAM
:
625 return g_strdup ("stream");
626 case MONO_VARIANT_STORAGE
:
627 return g_strdup ("storage");
628 case MONO_VARIANT_STREAMED_OBJECT
:
629 return g_strdup ("streamed_object");
630 case MONO_VARIANT_STORED_OBJECT
:
631 return g_strdup ("stored_object");
632 case MONO_VARIANT_BLOB_OBJECT
:
633 return g_strdup ("blob_object");
634 case MONO_VARIANT_CF
:
635 return g_strdup ("cf");
636 case MONO_VARIANT_CLSID
:
637 return g_strdup ("clsid");
638 case MONO_VARIANT_VECTOR
:
639 /* FIXME: output: <v_type> vector */
640 return g_strdup ("vector");
641 case MONO_VARIANT_ARRAY
:
642 /* FIXME: output: <v_type> [ ] */
643 return g_strdup ("[]");
644 case MONO_VARIANT_BYREF
:
645 /* FIXME: output: <v_type> & */
646 return g_strdup ("&");
648 return g_strdup ("unknown");
653 dis_stringify_native_type (MonoMarshalNative native
)
656 case MONO_NATIVE_BOOLEAN
:
657 return g_strdup ("bool");
659 return g_strdup ("int8");
661 return g_strdup ("unsigned int8");
663 return g_strdup ("int16");
665 return g_strdup ("unsigned int16");
667 return g_strdup ("int32");
669 return g_strdup ("unsigned int32");
671 return g_strdup ("int64");
673 return g_strdup ("unsigned int64");
675 return g_strdup ("float32");
677 return g_strdup ("float64");
678 case MONO_NATIVE_CURRENCY
:
679 return g_strdup ("currency");
680 case MONO_NATIVE_BSTR
:
681 return g_strdup ("bstr");
682 case MONO_NATIVE_LPSTR
:
683 return g_strdup ("lpstr");
684 case MONO_NATIVE_LPWSTR
:
685 return g_strdup ("lpwstr");
686 case MONO_NATIVE_LPTSTR
:
687 return g_strdup ("lptstr");
688 case MONO_NATIVE_IUNKNOWN
:
689 return g_strdup ("iunknown");
690 case MONO_NATIVE_IDISPATCH
:
691 return g_strdup ("idispatch");
692 case MONO_NATIVE_STRUCT
:
693 return g_strdup ("struct");
694 case MONO_NATIVE_INTERFACE
:
695 return g_strdup ("interface");
696 case MONO_NATIVE_SAFEARRAY
:
697 return g_strdup ("safearray");
698 case MONO_NATIVE_INT
:
699 return g_strdup ("int");
700 case MONO_NATIVE_UINT
:
701 return g_strdup ("unsigned int");
702 case MONO_NATIVE_VBBYREFSTR
:
703 return g_strdup ("vbbyrefstr");
704 case MONO_NATIVE_ANSIBSTR
:
705 return g_strdup ("ansi bstr");
706 case MONO_NATIVE_TBSTR
:
707 return g_strdup ("tbstr");
708 case MONO_NATIVE_VARIANTBOOL
:
709 return g_strdup ("variant bool");
710 case MONO_NATIVE_FUNC
:
711 return g_strdup ("method");
712 case MONO_NATIVE_ASANY
:
713 return g_strdup ("as any");
714 case MONO_NATIVE_LPSTRUCT
:
715 return g_strdup ("lpstruct");
716 case MONO_NATIVE_CUSTOM
:
717 return g_strdup ("custom");
718 case MONO_NATIVE_ERROR
:
719 return g_strdup ("error");
720 case MONO_NATIVE_MAX
:
721 return g_strdup ("");
723 return g_strdup ("unknown");
728 dis_stringify_marshal_spec (MonoMarshalSpec
*spec
)
730 switch (spec
->native
) {
731 case MONO_NATIVE_BYVALTSTR
:
732 return g_strdup_printf (" marshal (fixed sysstring [%d])", spec
->data
.array_data
.num_elem
);
733 case MONO_NATIVE_BYVALARRAY
:
734 return g_strdup_printf (" marshal (fixed array [%d])", spec
->data
.array_data
.num_elem
);
735 case MONO_NATIVE_LPARRAY
: {
736 char *elem_type
, *elems
, *ret
;
737 guint32 num_elem
= spec
->data
.array_data
.num_elem
;
738 guint32 param_num
= spec
->data
.array_data
.param_num
;
740 elem_type
= dis_stringify_native_type (spec
->data
.array_data
.elem_type
);
741 if (num_elem
== -1 && param_num
== -1)
742 elems
= g_strdup ("");
743 else if ((param_num
== -1) || (spec
->data
.array_data
.elem_mult
== 0))
744 elems
= g_strdup_printf ("%d", num_elem
);
745 else if ((num_elem
== -1) || (num_elem
== 0))
746 elems
= g_strdup_printf ("+ %d", param_num
);
748 elems
= g_strdup_printf ("%d + %d", num_elem
, param_num
);
750 ret
= g_strdup_printf (" marshal (%s[%s])", elem_type
, elems
);
755 case MONO_NATIVE_SAFEARRAY
: {
756 char *elem_type
= NULL
, *ret
;
758 if (spec
->data
.safearray_data
.elem_type
!= 0)
759 elem_type
= dis_stringify_variant_type (spec
->data
.safearray_data
.elem_type
);
760 ret
= g_strdup_printf (" marshal (safearray %s)", elem_type
? elem_type
: "");
765 case MONO_NATIVE_CUSTOM
:
766 return g_strdup_printf (" marshal (custom (\"%s\", \"%s\"))",
767 spec
->data
.custom_data
.custom_name
? spec
->data
.custom_data
.custom_name
: "",
768 spec
->data
.custom_data
.cookie
? spec
->data
.custom_data
.cookie
: "");
770 char *native_type
, *ret
;
771 native_type
= dis_stringify_native_type (spec
->native
);
772 ret
= g_strdup_printf (" marshal (%s)", native_type
);
773 g_free (native_type
);
781 * @m: metadata context
782 * @table_type: The type of table we are getting generics for (0 for typedef, 1 for method)
783 * @row: The row in the table
785 * Returns: Allocated stringified generic parameters
788 get_generic_param (MonoImage
*m
, MonoGenericContainer
*container
)
797 result
= g_string_new ("");
799 g_string_append_c (result
, '<');
800 for (i
= 0; i
< container
->type_argc
; i
++) {
801 MonoGenericParam
*param
= mono_generic_container_get_param (container
, i
);
802 MonoGenericParamInfo
*param_info
= mono_generic_param_info (param
);
809 g_string_append (result
, ",");
811 flags
= param_info
->flags
& GENERIC_PARAMETER_ATTRIBUTE_VARIANCE_MASK
;
812 if ((flags
& GENERIC_PARAMETER_ATTRIBUTE_COVARIANT
) == GENERIC_PARAMETER_ATTRIBUTE_COVARIANT
)
813 g_string_append (result
, "+ ");
814 if ((flags
& GENERIC_PARAMETER_ATTRIBUTE_CONTRAVARIANT
) == GENERIC_PARAMETER_ATTRIBUTE_CONTRAVARIANT
)
815 g_string_append (result
, "- ");
817 flags
= param_info
->flags
& GENERIC_PARAMETER_ATTRIBUTE_SPECIAL_CONSTRAINTS_MASK
;
818 if ((flags
& GENERIC_PARAMETER_ATTRIBUTE_REFERENCE_TYPE_CONSTRAINT
) == GENERIC_PARAMETER_ATTRIBUTE_REFERENCE_TYPE_CONSTRAINT
)
819 g_string_append (result
, "class ");
820 if ((flags
& GENERIC_PARAMETER_ATTRIBUTE_VALUE_TYPE_CONSTRAINT
) == GENERIC_PARAMETER_ATTRIBUTE_VALUE_TYPE_CONSTRAINT
)
821 g_string_append (result
, "valuetype ");
822 if ((flags
& GENERIC_PARAMETER_ATTRIBUTE_CONSTRUCTOR_CONSTRAINT
) == GENERIC_PARAMETER_ATTRIBUTE_CONSTRUCTOR_CONSTRAINT
)
823 g_string_append (result
, ".ctor ");
825 for (constr
= param_info
->constraints
; constr
&& *constr
; constr
++) {
829 g_string_append_c (result
, '(');
832 g_string_append (result
, ", ");
833 sig
= dis_stringify_type (m
, m_class_get_byval_arg (*constr
), TRUE
);
834 g_string_append (result
, sig
);
839 g_string_append (result
, ") ");
841 esname
= get_escaped_name (mono_generic_param_info (param
)->name
);
842 g_string_append (result
, esname
);
846 g_string_append_c (result
, '>');
848 retval
= result
->str
;
849 g_string_free (result
, FALSE
);
854 dis_stringify_method_signature (MonoImage
*m
, MonoMethodSignature
*method
, int methoddef_row
,
855 MonoGenericContainer
*container
, gboolean fully_qualified
)
857 return dis_stringify_method_signature_full (m
, method
, methoddef_row
, container
, fully_qualified
, TRUE
);
861 * @m: metadata context
862 * @method: MonoMethodSignature to dis-stringify
863 * @methoddef_row: row index in the Method table
864 * @context: generic context, generic method's context in case of a Generic method
865 * or a generic type's context. if !@context, treats it as a non-generic method
866 * @fully_qualified: TRUE to print type name also.
868 * Returns: Allocated stringified method signature
871 dis_stringify_method_signature_full (MonoImage
*m
, MonoMethodSignature
*method
, int methoddef_row
,
872 MonoGenericContainer
*container
, gboolean fully_qualified
, gboolean with_marshal_info
)
874 guint32 cols
[MONO_METHOD_SIZE
];
875 guint32 pcols
[MONO_PARAM_SIZE
];
876 guint32 param_index
= 0, next_param_index
= 0;
877 gboolean has_param_row
;
878 const char *method_name
= "";
880 char *retval
, *esname
;
882 char *marshal_info
= NULL
, *ret_marshal_info
= NULL
;
883 char *gen_param
= NULL
;
884 GString
*result
= g_string_new ("");
885 GString
*result_ret
= g_string_new ("");
888 g_assert (method
|| methoddef_row
);
891 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHOD
], methoddef_row
-1, cols
, MONO_METHOD_SIZE
);
892 if (fully_qualified
) {
893 guint32 type_idx
= mono_metadata_typedef_from_method (m
, methoddef_row
);
895 type
= get_typedef (m
, type_idx
);
897 type
= g_strdup ("<invalid>");
899 method_name
= mono_metadata_string_heap (m
, cols
[MONO_METHOD_NAME
]);
900 param_index
= cols
[MONO_METHOD_PARAMLIST
];
903 const char *sig
= mono_metadata_blob_heap (m
, cols
[MONO_METHOD_SIGNATURE
]);
905 container
= mono_metadata_load_generic_params (m
, MONO_TOKEN_METHOD_DEF
| methoddef_row
, container
, NULL
);
907 mono_metadata_load_generic_param_constraints_checked (m
, MONO_TOKEN_METHOD_DEF
| methoddef_row
, container
, error
);
908 g_assert (mono_error_ok (error
)); /*FIXME don't swallow the error message*/
911 mono_metadata_decode_blob_size (sig
, &sig
);
912 method
= mono_metadata_parse_method_signature_full (m
, container
, methoddef_row
, sig
, &sig
, error
);
913 g_assert (mono_error_ok (error
)); /*FIXME don't swallow the error message*/
917 if (container
&& container
->is_method
)
918 gen_param
= get_generic_param (m
, container
);
920 if (methoddef_row
< m
->tables
[MONO_TABLE_METHOD
].rows
) {
921 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHOD
], methoddef_row
, cols
, MONO_METHOD_SIZE
);
922 next_param_index
= cols
[MONO_METHOD_PARAMLIST
];
924 next_param_index
= m
->tables
[MONO_TABLE_PARAM
].rows
+ 1;
928 start
= method
->hasthis
? 0 : 1;
929 for (i
= 0; i
< method
->param_count
+ 1; ++i
) {
931 has_param_row
= param_index
&& param_index
< next_param_index
;
934 if (method
->param_count
== 0 && !has_param_row
)
935 /* method has zero parameters, and no row for return val in the PARAM table */
939 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_PARAM
], param_index
- 1, pcols
, MONO_PARAM_SIZE
);
941 if (has_param_row
&& i
== pcols
[MONO_PARAM_SEQUENCE
]) {
943 esname
= get_escaped_name (
944 mono_metadata_string_heap (m
, pcols
[MONO_PARAM_NAME
]));
946 if (with_marshal_info
&& (pcols
[MONO_PARAM_FLAGS
] & PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL
)) {
948 MonoMarshalSpec
*spec
;
949 tp
= mono_metadata_get_marshal_info (m
, param_index
- 1, FALSE
);
951 spec
= mono_metadata_parse_marshal_spec (m
, tp
);
954 marshal_info
= dis_stringify_marshal_spec (spec
);
956 ret_marshal_info
= dis_stringify_marshal_spec (spec
);
959 marshal_info
= g_strdup ("(missing)");
961 ret_marshal_info
= g_strdup ("(missing)");
967 /* A_[0-9]* does not require escaping */
968 esname
= g_strdup_printf ("A_%i", i
- start
);
975 g_string_append (result
, ", ");
977 retval
= dis_stringify_param (m
, method
->params
[i
- 1]);
979 g_string_append_printf (result
, "%s%s %s", retval
, marshal_info
? marshal_info
: "", esname
);
982 g_free (marshal_info
);
984 g_string_append (result
, ") ");
986 retval
= dis_stringify_param (m
, method
->ret
);
989 g_string_append (result_ret
, "instance ");
990 g_string_append (result_ret
, map (method
->call_convention
, call_conv_type_map
));
991 g_string_append_printf (result_ret
, " %s%s ", retval
, ret_marshal_info
? ret_marshal_info
:"");
992 g_free (ret_marshal_info
);
994 char *estype
= get_escaped_name (type
);
995 g_string_append_printf (result_ret
, "%s::", estype
);
999 esname
= get_escaped_name (method_name
);
1000 g_string_append (result_ret
, esname
);
1003 g_string_append (result_ret
, gen_param
);
1006 g_string_append (result_ret
, " (");
1009 g_string_append (result_ret
, result
->str
);
1010 g_string_free (result
, TRUE
);
1011 result
= result_ret
;
1013 if (show_method_tokens
&& methoddef_row
)
1014 g_string_append_printf (result
, " /* 0x%X */ ",
1015 (methoddef_row
>> MONO_TYPEORMETHOD_BITS
) | MONO_TOKEN_METHOD_DEF
);
1018 mono_metadata_free_method_signature (method
);
1019 retval
= result
->str
;
1020 g_string_free (result
, FALSE
);
1026 dis_stringify_function_ptr (MonoImage
*m
, MonoMethodSignature
*method
)
1029 GString
*result
= g_string_new ("");
1034 g_string_append (result
, map (method
->call_convention
, call_conv_type_map
));
1036 retval
= dis_stringify_param (m
, method
->ret
);
1037 g_string_append_printf (result
, " %s ", retval
);
1040 g_string_append (result
, " *(");
1041 for (i
= 0; i
< method
->param_count
; ++i
) {
1043 g_string_append (result
, ", ");
1044 retval
= dis_stringify_param (m
, method
->params
[i
]);
1045 g_string_append (result
, retval
);
1048 g_string_append (result
, ") ");
1050 retval
= result
->str
;
1051 g_string_free (result
, FALSE
);
1057 get_escaped_class_name (MonoClass
*c
)
1059 char *result
, *esname
;
1061 if (m_class_get_type_token (c
) == mono_metadata_make_token (MONO_TABLE_TYPEDEF
, 1))
1065 if (m_class_get_rank (c
) || m_class_get_byval_arg (c
)->type
== MONO_TYPE_PTR
)
1068 esname
= get_escaped_name (m_class_get_name (c
));
1070 if (m_class_get_nested_in (c
)){
1071 char *part_a
= get_escaped_class_name (m_class_get_nested_in (c
));
1073 result
= g_strdup_printf ("%s/%s", part_a
, esname
);
1075 } else if (*m_class_get_name_space (c
))
1076 result
= g_strdup_printf ("%s.%s", m_class_get_name_space (c
), esname
);
1078 result
= g_strdup (esname
);
1085 dis_stringify_object_with_class (MonoImage
*m
, MonoClass
*c
, gboolean prefix
, gboolean is_def
)
1087 /* FIXME: handle MONO_TYPE_OBJECT ... */
1088 MonoType
*type
= m_class_get_byval_arg (c
);
1089 const char *otype
= type
->type
== MONO_TYPE_VALUETYPE
? "valuetype " : "class " ;
1090 char *assemblyref
= NULL
, *result
, *esname
, *generic
= NULL
;
1092 if (m_class_get_type_token (c
) == mono_metadata_make_token (MONO_TABLE_TYPEDEF
, 1))
1096 if (m
!= m_class_get_image (c
)) {
1097 if (m_class_get_image (c
)->assembly_name
) {
1099 if (substitute_with_mscorlib_p
&& !strcmp ("corlib", m_class_get_image (c
)->assembly_name
))
1100 assemblyref
= g_strdup_printf ("[%s]", "mscorlib");
1102 char *esc
= get_escaped_name (m_class_get_image (c
)->assembly
->aname
.name
);
1104 assemblyref
= g_strdup_printf ("[%s]", esc
);
1108 assemblyref
= g_strdup_printf ("[.module %s]", m_class_get_image (c
)->module_name
);
1112 esname
= get_escaped_class_name (c
);
1114 if (mono_class_is_ginst (c
)) {
1115 MonoGenericClass
*gclass
= mono_class_get_generic_class (c
);
1116 MonoGenericInst
*inst
= gclass
->context
.class_inst
;
1117 GString
*str
= g_string_new ("");
1120 for (i
= 0; i
< inst
->type_argc
; i
++){
1121 char *t
= dis_stringify_type (m
, inst
->type_argv
[i
], is_def
);
1123 g_string_append (str
, t
);
1124 if (i
+1 != inst
->type_argc
)
1125 g_string_append (str
, ", ");
1128 generic
= g_strdup_printf ("<%s>", str
->str
);
1129 g_string_free (str
, TRUE
);
1133 result
= g_strdup_printf ("%s%s%s%s", prefix
? otype
: "", assemblyref
?assemblyref
:"",
1134 esname
, generic
?generic
:"");
1137 g_free (assemblyref
);
1144 dis_stringify_object (MonoImage
*m
, MonoType
*type
, gboolean is_def
)
1146 MonoClass
*c
= mono_class_from_mono_type_internal (type
);
1147 return dis_stringify_object_with_class (m
, c
, TRUE
, is_def
);
1151 dis_stringify_type (MonoImage
*m
, MonoType
*type
, gboolean is_def
)
1153 const char *pinned
= "", *byref
= "";
1154 char *bare
= NULL
, *mods
= NULL
;
1157 if (type
->has_cmods
) {
1158 MonoCustomModContainer
*cmods
= mono_type_get_cmods (type
);
1159 mods
= dis_stringify_modifiers (cmods
->image
, cmods
->count
, cmods
->modifiers
);
1162 switch (type
->type
){
1163 case MONO_TYPE_BOOLEAN
:
1164 case MONO_TYPE_CHAR
:
1177 case MONO_TYPE_STRING
:
1178 case MONO_TYPE_OBJECT
:
1179 case MONO_TYPE_TYPEDBYREF
:
1180 bare
= g_strdup (map (type
->type
, element_type_map
));
1183 case MONO_TYPE_VALUETYPE
:
1184 case MONO_TYPE_CLASS
:
1185 bare
= dis_stringify_object (m
, type
, is_def
);
1187 case MONO_TYPE_FNPTR
: {
1189 child_type
= dis_stringify_function_ptr (m
, type
->data
.method
);
1190 bare
= g_strdup_printf ("method %s", child_type
);
1191 g_free (child_type
);
1194 case MONO_TYPE_PTR
: {
1196 child_type
= dis_stringify_type (m
, type
->data
.type
, is_def
);
1198 bare
= g_strdup_printf ("%s*", child_type
);
1199 g_free (child_type
);
1202 case MONO_TYPE_SZARRAY
: {
1204 child_type
= dis_stringify_type (m
, m_class_get_byval_arg (type
->data
.klass
), is_def
);
1206 bare
= g_strdup_printf ("%s[]", child_type
);
1207 g_free (child_type
);
1210 case MONO_TYPE_ARRAY
:
1211 bare
= dis_stringify_array (m
, type
->data
.array
, is_def
);
1213 case MONO_TYPE_VOID
:
1214 bare
= g_strdup ("void");
1216 case MONO_TYPE_MVAR
:
1217 if (is_def
&& !cant_print_generic_param_name (type
->data
.generic_param
))
1218 bare
= g_strdup_printf ("!!%s", get_escaped_name (mono_generic_param_info (type
->data
.generic_param
)->name
));
1220 bare
= g_strdup_printf ("!!%d", mono_type_get_generic_param_num (type
));
1223 if (is_def
&& !cant_print_generic_param_name (type
->data
.generic_param
))
1224 bare
= g_strdup_printf ("!%s", get_escaped_name (mono_generic_param_info (type
->data
.generic_param
)->name
));
1226 bare
= g_strdup_printf ("!%d", mono_type_get_generic_param_num (type
));
1228 case MONO_TYPE_GENERICINST
: {
1229 GString
*str
= g_string_new ("");
1230 MonoGenericInst
*inst
;
1232 char *generic_type
= dis_stringify_type (
1233 m
, m_class_get_byval_arg (type
->data
.generic_class
->container_class
), is_def
);
1234 inst
= type
->data
.generic_class
->context
.class_inst
;
1235 for (i
= 0; i
< inst
->type_argc
; i
++){
1236 char *t
= dis_stringify_type (m
, inst
->type_argv
[i
], is_def
);
1238 g_string_append (str
, t
);
1239 if (i
+1 != inst
->type_argc
)
1240 g_string_append (str
, ", ");
1243 bare
= g_strdup_printf ("%s<%s>", generic_type
, str
->str
);
1244 g_string_free (str
, TRUE
);
1249 g_error ("Do not know how to stringify type 0x%x", type
->type
);
1259 /* bare is NULL, for <Module> */
1262 result
= g_strconcat (bare
, byref
, pinned
, mods
? mods
: "", NULL
);
1271 * @m: metadata context
1272 * @ptr: location to decode from.
1273 * @result: pointer to string where resulting decoded string is stored
1275 * This routine returs in @result the stringified type pointed by @ptr.
1278 * Returns: the new ptr to continue decoding
1281 get_type (MonoImage
*m
, const char *ptr
, char **result
, gboolean is_def
, MonoGenericContainer
*container
)
1284 const char *start
= ptr
;
1288 if (*ptr
== MONO_TYPE_BYREF
)
1291 type
= mono_metadata_decode_value (ptr
, &ptr
);
1294 case MONO_TYPE_VALUETYPE
:
1295 case MONO_TYPE_CLASS
: {
1296 guint32 token
= mono_metadata_parse_typedef_or_ref (m
, ptr
, &ptr
);
1297 MonoClass
*klass
= mono_class_get_checked (m
, token
, error
);
1300 temp
= dis_stringify_object_with_class (m
, klass
, TRUE
, FALSE
);
1302 temp
= g_strdup_printf ("<BROKEN CLASS token_%8x due to %s>", token
, mono_error_get_message (error
));
1303 mono_error_cleanup (error
);
1307 *result
= get_token_comment (temp
, token
);
1314 case MONO_TYPE_GENERICINST
: {
1315 GString
*str
= g_string_new ("");
1319 ptr
= get_type (m
, ptr
, &temp
, is_def
, container
);
1320 g_string_append (str
, temp
);
1323 count
= mono_metadata_decode_value (ptr
, &ptr
);
1324 g_string_append (str
, "<");
1326 for (i
= 0; i
< count
; i
++) {
1328 g_string_append (str
, ",");
1329 ptr
= get_type (m
, ptr
, &temp
, is_def
, container
);
1330 g_string_append (str
, temp
);
1333 g_string_append (str
, ">");
1335 g_string_free (str
, FALSE
);
1340 t
= mono_metadata_parse_type_checked (m
, container
, 0, FALSE
, start
, &ptr
, error
);
1342 *result
= dis_stringify_type (m
, t
, is_def
);
1344 *result
= g_strdup_printf ("Invalid type due to %s", mono_error_get_message (error
));
1345 mono_error_cleanup (error
);
1356 * Returns a stringified representation of a FieldSig (22.2.4)
1359 get_field_signature (MonoImage
*m
, guint32 blob_signature
, MonoGenericContainer
*container
)
1361 char *allocated_modifier_string
, *allocated_type_string
;
1362 const char *ptr
= mono_metadata_blob_heap (m
, blob_signature
);
1366 len
= mono_metadata_decode_value (ptr
, &ptr
);
1368 g_assert (*ptr
== 0x06);
1369 /* hex_dump (ptr, 0, len); */
1372 ptr
= get_custom_mod (m
, ptr
, &allocated_modifier_string
);
1373 ptr
= get_type (m
, ptr
, &allocated_type_string
, FALSE
, container
);
1375 res
= g_strdup_printf (
1377 allocated_type_string
,
1378 allocated_modifier_string
? allocated_modifier_string
: "");
1380 g_free (allocated_modifier_string
);
1381 g_free (allocated_type_string
);
1387 get_field_literal_type (MonoImage
*m
, guint32 blob_signature
)
1389 const char *ptr
= mono_metadata_blob_heap (m
, blob_signature
);
1391 char *allocated_modifier_string
;
1393 len
= mono_metadata_decode_value (ptr
, &ptr
);
1396 g_assert (*ptr
== 0x06);
1399 ptr
= get_custom_mod (m
, ptr
, &allocated_modifier_string
);
1400 g_free (allocated_modifier_string
);
1402 return (MonoTypeEnum
) *ptr
;
1408 * @m: metadata context
1409 * @token: token to decode
1411 * decodes the literal indexed by @token.
1414 decode_literal (MonoImage
*m
, guint32 token
)
1416 return g_strdup ("LITERAL_VALUE");
1421 * @m: metadata context
1422 * @ptr: location to decode from.
1423 * @result: pointer to string where resulting decoded string is stored
1425 * This routine returns in @result the stringified RetType (22.2.11)
1427 * Returns: the new ptr to continue decoding.
1430 get_ret_type (MonoImage
*m
, const char *ptr
, char **ret_type
, MonoGenericContainer
*container
)
1432 GString
*str
= g_string_new ("");
1434 char *allocated_type_string
;
1437 ptr
= get_custom_mod (m
, ptr
, &mod
);
1439 if (*ptr
== MONO_TYPE_TYPEDBYREF
){
1440 g_string_append (str
, "typedref");
1442 } else if (*ptr
== MONO_TYPE_VOID
){
1443 g_string_append (str
, "void");
1446 if (*ptr
== MONO_TYPE_BYREF
){
1451 ptr
= get_type (m
, ptr
, &allocated_type_string
, FALSE
, container
);
1452 g_string_append (str
, allocated_type_string
);
1454 g_string_append (str
, "& ");
1455 g_free (allocated_type_string
);
1459 g_string_append (str
, mod
);
1460 g_string_append_c (str
, ' ');
1464 *ret_type
= str
->str
;
1465 g_string_free (str
, FALSE
);
1472 * @m: metadata context
1473 * @ptr: location to decode from.
1474 * @result: pointer to string where resulting decoded string is stored
1476 * This routine returns in @result the stringified Param (22.2.10)
1478 * Returns: the new ptr to continue decoding.
1481 get_param (MonoImage
*m
, const char *ptr
, char **retval
, MonoGenericContainer
*container
)
1483 GString
*str
= g_string_new ("");
1484 char *allocated_mod_string
, *allocated_type_string
;
1486 ptr
= get_custom_mod (m
, ptr
, &allocated_mod_string
);
1488 if (*ptr
== MONO_TYPE_TYPEDBYREF
){
1489 g_string_append (str
, " typedref ");
1492 gboolean by_ref
= 0;
1493 if (*ptr
== MONO_TYPE_BYREF
){
1494 g_string_append (str
, "[out] ");
1498 ptr
= get_type (m
, ptr
, &allocated_type_string
, FALSE
, container
);
1499 g_string_append (str
, allocated_type_string
);
1501 g_string_append_c (str
, '&');
1502 g_free (allocated_type_string
);
1505 if (allocated_mod_string
){
1506 g_string_append (str
, allocated_mod_string
);
1507 g_string_append_c (str
, ' ');
1508 g_free (allocated_mod_string
);
1512 g_string_free (str
, FALSE
);
1519 * @str: string to process
1520 * @list: list of chars to escape
1522 * Returns: an allocated escaped string.
1525 str_escape (const char *str
, const char *list
)
1527 const char *p
= str
;
1530 res
= g_string_sized_new (strlen (str
));
1533 while (*p
&& !strchr (list
, *p
))
1535 g_string_append_len (res
, str
, p
- str
);
1538 g_string_append_c (res
, '\\');
1543 return g_string_free (res
, FALSE
);
1549 * Returns: An allocated escaped name. A name needs to be escaped
1550 * because it might be an ilasm keyword.
1553 get_escaped_name (const char *name
)
1561 g_assert (key_table
);
1563 if (strlen (name
) == 0)
1564 return g_strdup (name
);
1566 for (s
= name
; *s
; s
++) {
1567 char *first
, *result
;
1572 first
= g_strndup (name
, s
-name
);
1573 result
= g_strdup_printf ("%s/%s", get_escaped_name (first
), get_escaped_name (s
+1));
1579 for (s
= name
; *s
; s
++) {
1580 if (isalnum (*s
) || *s
== '_' || *s
== '$' || *s
== '@' ||
1581 *s
== '?' || (*s
== '.' && s
!= name
) || *s
== 0 || *s
== '!' || *s
== '`')
1584 esc
= str_escape (name
, "'\\");
1585 ret
= g_strdup_printf ("'%s'", esc
);
1590 if (g_hash_table_lookup (key_table
, name
))
1591 return g_strdup_printf ("'%s'", name
);
1593 return str_escape (name
, "'\\");
1596 static dis_map_t param_map
[] = {
1597 { PARAM_ATTRIBUTE_IN
, "[in] " },
1598 { PARAM_ATTRIBUTE_OUT
, "[out] " },
1599 { PARAM_ATTRIBUTE_OPTIONAL
, "optional " },
1600 { PARAM_ATTRIBUTE_HAS_DEFAULT
, "hasdefault " },
1601 { PARAM_ATTRIBUTE_HAS_FIELD_MARSHAL
, "fieldmarshal " },
1606 param_flags (guint32 f
)
1608 return g_strdup (flags (f
, param_map
));
1611 static dis_map_t field_access_map
[] = {
1612 { FIELD_ATTRIBUTE_COMPILER_CONTROLLED
, "privatescope " },
1613 { FIELD_ATTRIBUTE_PRIVATE
, "private " },
1614 { FIELD_ATTRIBUTE_FAM_AND_ASSEM
, "famandassem " },
1615 { FIELD_ATTRIBUTE_ASSEMBLY
, "assembly " },
1616 { FIELD_ATTRIBUTE_FAMILY
, "family " },
1617 { FIELD_ATTRIBUTE_FAM_OR_ASSEM
, "famorassem " },
1618 { FIELD_ATTRIBUTE_PUBLIC
, "public " },
1622 static dis_map_t field_flags_map
[] = {
1623 { FIELD_ATTRIBUTE_STATIC
, "static " },
1624 { FIELD_ATTRIBUTE_INIT_ONLY
, "initonly " },
1625 { FIELD_ATTRIBUTE_LITERAL
, "literal " },
1626 { FIELD_ATTRIBUTE_NOT_SERIALIZED
, "notserialized " },
1627 { FIELD_ATTRIBUTE_SPECIAL_NAME
, "specialname " },
1628 { FIELD_ATTRIBUTE_PINVOKE_IMPL
, "FIXME:pinvokeimpl " },
1629 { FIELD_ATTRIBUTE_RT_SPECIAL_NAME
, "rtspecialname " },
1631 /* This is set when a MarshalAs attribute is seen. FIXME: round-trip? */
1632 { FIELD_ATTRIBUTE_HAS_FIELD_MARSHAL
, "" },
1634 /* This seems to be set if LITERAL is set. FIXME: round-trip? */
1635 { FIELD_ATTRIBUTE_HAS_DEFAULT
, "" },
1637 /* This seems to be set on compiler-generated array initializer fields. FIXME: round-trip? */
1638 { FIELD_ATTRIBUTE_HAS_FIELD_RVA
, "" },
1645 * Returns a stringified version of a Field's flags
1648 field_flags (guint32 f
)
1651 int access
= f
& FIELD_ATTRIBUTE_FIELD_ACCESS_MASK
;
1652 int rest
= f
& ~access
;
1656 strcat (buffer
, map (access
, field_access_map
));
1657 strcat (buffer
, flags (rest
, field_flags_map
));
1658 return g_strdup (buffer
);
1662 * Returns a stringifed representation of a MethodRefSig (22.2.2)
1665 get_methodref_signature (MonoImage
*m
, guint32 blob_signature
, const char *fancy_name
)
1667 GString
*res
= g_string_new ("");
1668 const char *ptr
= mono_metadata_blob_heap (m
, blob_signature
);
1669 char *allocated_ret_type
, *s
;
1670 const char *cconv_str
;
1671 gboolean seen_vararg
= 0;
1673 int i
, gen_count
= 0;
1676 /* signature_len = */ mono_metadata_decode_value (ptr
, &ptr
);
1680 g_string_append (res
, "explicit-this ");
1682 g_string_append (res
, "instance "); /* has-this */
1687 cconv
= *ptr
& 0x0f;
1688 cconv_str
= map (cconv
, call_conv_type_map
);
1689 if (strcmp (cconv_str
, "default") != 0) {
1690 g_string_append (res
, cconv_str
);
1691 g_string_append (res
, " ");
1696 gen_count
= mono_metadata_decode_value (ptr
, &ptr
);
1697 param_count
= mono_metadata_decode_value (ptr
, &ptr
);
1699 ptr
= get_ret_type (m
, ptr
, &allocated_ret_type
, NULL
);
1700 g_string_append (res
, allocated_ret_type
);
1701 g_free (allocated_ret_type
);
1705 g_string_append_c (res
, ' ');
1706 g_string_append (res
, fancy_name
);
1709 g_string_append (res
, "(");
1712 * param_count describes parameters *before* and *after*
1713 * the vararg sentinel
1715 for (i
= 0; i
< param_count
; i
++){
1719 * If ptr is a SENTINEL
1723 g_string_append (res
, "..., ");
1730 ptr
= get_param (m
, ptr
, ¶m
, NULL
);
1731 g_string_append (res
, param
);
1732 if (i
+1 != param_count
)
1733 g_string_append (res
, ", ");
1736 g_string_append (res
, ")");
1739 * cleanup and return
1742 g_string_free (res
, FALSE
);
1747 * Returns a stringifed representation of a field ref
1750 get_fieldref_signature (MonoImage
*m
, int idx
, MonoGenericContainer
*container
)
1752 guint32 cols
[MONO_MEMBERREF_SIZE
];
1754 MonoGenericContainer
*new_container
;
1755 char *type
, *esname
;
1759 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MEMBERREF
],
1760 idx
- 1, cols
, MONO_MEMBERREF_SIZE
);
1762 new_container
= get_memberref_container (m
, cols
[MONO_MEMBERREF_CLASS
], container
, error
);
1763 mono_error_assert_ok (error
);
1764 sig
= get_field_signature (m
, cols
[MONO_MEMBERREF_SIGNATURE
], new_container
);
1766 type
= get_memberref_parent (m
, cols
[MONO_MEMBERREF_CLASS
], container
);
1767 esname
= get_escaped_name (mono_metadata_string_heap (m
, cols
[MONO_MEMBERREF_NAME
]));
1769 full_sig
= g_strdup_printf ("%s %s%s%s",
1782 * get_token_comment:
1784 * If show_tokens is TRUE, return "prefix""token(table)".
1785 * If show_tokens is FALSE, return "prefix" or NULL if prefix is NULL.
1786 * Caller is responsible for freeing.
1789 get_token_comment (const char *prefix
, guint32 token
)
1792 return prefix
? g_strdup_printf ("%s", prefix
) : NULL
;
1793 gint32 tableidx
= mono_metadata_token_table (token
);
1794 if ((tableidx
< 0) || (tableidx
> MONO_TABLE_LAST
))
1795 return g_strdup_printf ("%s/*%08x*/", prefix
? prefix
: "", token
);
1797 return g_strdup_printf ("%s/*%08x(%s)*/", prefix
? prefix
: "", token
, mono_meta_table_name (tableidx
));
1802 * @m: metadata context
1803 * @token: a FIELD_DEF token
1805 * This routine has to locate the TypeDef that "owns" this Field.
1806 * Since there is no backpointer in the Field table, we have to scan
1807 * the TypeDef table and locate the actual "owner" of the field
1810 get_field (MonoImage
*m
, guint32 token
, MonoGenericContainer
*container
)
1812 int idx
= mono_metadata_token_index (token
);
1813 guint32 cols
[MONO_FIELD_SIZE
];
1814 char *sig
, *res
, *type
, *estype
, *esname
, *token_comment
;
1818 * We can get here also with a MenberRef token (for a field
1819 * defined in another module/assembly, just like in get_method ()
1821 if (mono_metadata_token_code (token
) == MONO_TOKEN_MEMBER_REF
) {
1822 return get_fieldref_signature (m
, idx
, container
);
1824 g_assert (mono_metadata_token_code (token
) == MONO_TOKEN_FIELD_DEF
);
1826 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_FIELD
], idx
- 1, cols
, MONO_FIELD_SIZE
);
1827 sig
= get_field_signature (m
, cols
[MONO_FIELD_SIGNATURE
], container
);
1830 * To locate the actual "container" for this field, we have to scan
1831 * the TypeDef table. LAME!
1833 type_idx
= mono_metadata_typedef_from_field (m
, idx
);
1835 res
= g_strdup_printf ("<invalid> %s", sig
);
1840 type
= get_typedef (m
, type_idx
);
1841 estype
= get_escaped_name (type
);
1842 esname
= get_escaped_name (mono_metadata_string_heap (m
, cols
[MONO_FIELD_NAME
]));
1843 token_comment
= get_token_comment (NULL
, token
);
1844 res
= g_strdup_printf ("%s %s%s%s%s",
1846 estype
? estype
: "",
1849 token_comment
? token_comment
: ""
1856 g_free (token_comment
);
1862 * get_memberref_container:
1863 * \param m The \c MonoImage
1864 * \param mrp_token a \c MemberRefParent token in \p m
1865 * \param container the parent generic container
1866 * \param error set on error
1868 * \returns the generic container given a MemberRefParent token, or \c NULL if
1869 * the \c MemberRefParent is not a generic type.
1871 * On error returns NULL and sets \p error.
1873 static MonoGenericContainer
*
1874 get_memberref_container (MonoImage
*m
, guint32 mrp_token
, MonoGenericContainer
*container
, MonoError
*error
)
1879 * mrp_index is a MemberRefParent coded index
1881 guint32 table
= mrp_token
& 7;
1882 guint32 idx
= mrp_token
>> 3;
1885 case 0: /* TypeDef */
1886 return mono_metadata_load_generic_params (m
, MONO_TOKEN_TYPE_DEF
| idx
, NULL
, NULL
);
1888 case 1: /* TypeRef */
1891 case 4: /* TypeSpec */
1892 klass
= mono_class_get_and_inflate_typespec_checked (m
, MONO_TOKEN_TYPE_SPEC
| idx
, &container
->context
, error
);
1893 return_val_if_nok (error
, NULL
);
1895 return mono_class_is_ginst (klass
) ? mono_class_get_generic_container (mono_class_get_generic_class (klass
)->container_class
) : NULL
;
1897 g_assert_not_reached ();
1902 get_memberref_parent (MonoImage
*m
, guint32 mrp_token
, MonoGenericContainer
*container
)
1905 * mrp_index is a MemberRefParent coded index
1907 guint32 table
= mrp_token
& 7;
1908 guint32 idx
= mrp_token
>> 3;
1911 case 0: /* TypeDef */
1912 return get_typedef (m
, idx
);
1914 case 1: /* TypeRef */
1915 return get_typeref (m
, idx
);
1917 case 2: /* ModuleRef */
1918 return g_strdup_printf ("TODO:MemberRefParent-ModuleRef");
1920 case 3: /* MethodDef */
1921 return g_strdup ("TODO:MethodDef");
1923 case 4: /* TypeSpec */
1924 return get_typespec (m
, idx
, FALSE
, container
);
1926 g_assert_not_reached ();
1932 * @m: metadata context
1933 * @token: a METHOD_DEF or MEMBER_REF token
1935 * This routine has to locate the TypeDef that "owns" this Field.
1936 * Since there is no backpointer in the Field table, we have to scan
1937 * the TypeDef table and locate the actual "owner" of the field
1940 get_method_core (MonoImage
*m
, guint32 token
, gboolean fullsig
, MonoGenericContainer
*container
)
1943 int idx
= mono_metadata_token_index (token
);
1944 guint32 member_cols
[MONO_MEMBERREF_SIZE
], method_cols
[MONO_METHOD_SIZE
];
1945 char *sig
= NULL
, *esname
;
1949 MonoGenericContainer
*type_container
= container
;
1951 mh
= mono_get_method_checked (m
, token
, NULL
, (MonoGenericContext
*) container
, error
);
1953 if (mono_method_signature_internal (mh
)->is_inflated
)
1954 container
= mono_method_get_generic_container (((MonoMethodInflated
*) mh
)->declaring
);
1955 esname
= get_escaped_name (mh
->name
);
1956 sig
= dis_stringify_type (m
, m_class_get_byval_arg (mh
->klass
), TRUE
);
1957 char *token_comment
= get_token_comment (NULL
, token
);
1958 name
= g_strdup_printf ("%s%s%s%s", sig
? sig
: "", token_comment
? token_comment
: "", sig
? "::" : "", esname
);
1961 g_free (token_comment
);
1964 mono_error_cleanup (error
);
1967 switch (mono_metadata_token_code (token
)){
1968 case MONO_TOKEN_METHOD_DEF
:
1969 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHOD
],
1970 idx
- 1, method_cols
, MONO_METHOD_SIZE
);
1972 sig
= get_methodref_signature (m
, method_cols
[MONO_METHOD_SIGNATURE
], name
);
1975 case MONO_TOKEN_MEMBER_REF
: {
1976 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MEMBERREF
],
1977 idx
- 1, member_cols
, MONO_MEMBERREF_SIZE
);
1979 char *parent
= get_memberref_parent (m
, member_cols
[MONO_MEMBERREF_CLASS
], container
);
1980 name
= g_strdup_printf ("%s%s%s",
1981 parent
? parent
: "",
1983 mono_metadata_string_heap (m
, member_cols
[MONO_MEMBERREF_NAME
]));
1990 arity
= mono_method_get_generic_container (mh
)->type_argc
;
1992 if (mh
->is_inflated
&& ((MonoMethodInflated
*)mh
)->declaring
->is_generic
)
1993 arity
= mono_method_get_generic_container (((MonoMethodInflated
*) mh
)->declaring
)->type_argc
;
1996 char *str
= g_strdup_printf ("%s <[%d]>", name
, arity
);
2002 sig
= get_methodref_signature (
2003 m
, member_cols
[MONO_MEMBERREF_SIGNATURE
], name
);
2006 case MONO_TOKEN_METHOD_SPEC
: {
2007 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHODSPEC
],
2008 idx
- 1, member_cols
, MONO_METHODSPEC_SIZE
);
2009 token
= member_cols
[MONO_METHODSPEC_METHOD
];
2010 sig
= get_methodspec (m
, idx
, token
, name
, type_container
);
2015 g_assert_not_reached ();
2026 char *retval
= get_token_comment (sig
, token
);
2034 get_method (MonoImage
*m
, guint32 token
, MonoGenericContainer
*container
)
2036 return get_method_core (m
, token
, TRUE
, container
);
2041 * @m: metadata context
2042 * @idx: index into the method table
2044 * Returns: A stringified version of the method signature.
2047 get_methoddef (MonoImage
*m
, guint32 idx
)
2050 guint32 cols
[MONO_METHOD_SIZE
];
2056 mh
= mono_get_method_checked (m
, MONO_TOKEN_METHOD_DEF
| idx
, NULL
, NULL
, error
);
2058 sig
= dis_stringify_type (m
, m_class_get_byval_arg (mh
->klass
), FALSE
);
2059 name
= g_strdup_printf ("%s%s%s",
2065 name
= g_strdup_printf ("!bad-method-name!");
2066 mono_error_cleanup (error
);
2068 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHOD
],
2069 idx
- 1, cols
, MONO_METHOD_SIZE
);
2070 sig
= get_methodref_signature (m
, cols
[MONO_METHOD_SIGNATURE
], name
);
2076 get_method_type_param (MonoImage
*m
, guint32 blob_signature
, MonoGenericContainer
*container
)
2078 GString
*res
= g_string_new ("");
2079 const char *ptr
= mono_metadata_blob_heap (m
, blob_signature
);
2084 mono_metadata_decode_value (ptr
, &ptr
);
2086 param_count
= mono_metadata_decode_value (ptr
, &ptr
);
2088 g_string_append_c (res
, '<');
2090 for (i
= 0; i
< param_count
; i
++){
2093 ptr
= get_param (m
, ptr
, ¶m
, container
);
2094 g_string_append (res
, param
);
2095 if (i
+1 != param_count
)
2096 g_string_append (res
, ", ");
2099 g_string_append_c (res
, '>');
2102 g_string_free (res
, FALSE
);
2109 * Returns: An allocated stringified version of the methodspec signature.
2113 get_methodspec (MonoImage
*m
, int idx
, guint32 token
, const char *fancy_name
, MonoGenericContainer
*type_container
)
2116 GString
*res
= g_string_new ("");
2117 guint32 member_cols
[MONO_MEMBERREF_SIZE
], method_cols
[MONO_METHOD_SIZE
];
2118 char *s
, *type_param
;
2121 int param_count
, cconv
, i
, gen_count
= 0;
2122 MonoGenericContainer
*container
;
2123 MonoMethod
*mh
= NULL
;
2125 switch (token
& MONO_METHODDEFORREF_MASK
) {
2126 case MONO_METHODDEFORREF_METHODDEF
:
2127 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHOD
],
2128 (token
>> MONO_METHODDEFORREF_BITS
) - 1,
2129 method_cols
, MONO_METHOD_SIZE
);
2130 sig
= method_cols
[MONO_METHOD_SIGNATURE
];
2132 case MONO_METHODDEFORREF_METHODREF
:
2133 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MEMBERREF
],
2134 (token
>> MONO_METHODDEFORREF_BITS
) - 1,
2135 member_cols
, MONO_MEMBERREF_SIZE
);
2136 sig
= member_cols
[MONO_MEMBERREF_SIGNATURE
];
2139 g_assert_not_reached ();
2142 ptr
= mono_metadata_blob_heap (m
, sig
);
2143 mono_metadata_decode_value (ptr
, &ptr
);
2145 mh
= mono_get_method_checked (m
, method_dor_to_token (token
), NULL
, (MonoGenericContext
*) type_container
, error
);
2147 g_string_append_printf (res
, "Could not decode method token 0x%x due to %s", token
, mono_error_get_message (error
));
2148 mono_error_cleanup (error
);
2149 return g_string_free (res
, FALSE
);
2152 container
= mono_method_get_generic_container (mh
);
2154 container
= type_container
;
2158 g_string_append (res
, "explicit-this ");
2160 g_string_append (res
, "instance "); /* has-this */
2165 cconv
= *ptr
& 0x0f;
2168 gen_count
= mono_metadata_decode_value (ptr
, &ptr
);
2169 param_count
= mono_metadata_decode_value (ptr
, &ptr
);
2171 char *allocated_ret_type
;
2172 ptr
= get_ret_type (m
, ptr
, &allocated_ret_type
, container
);
2173 g_string_append (res
, allocated_ret_type
);
2174 g_free (allocated_ret_type
);
2178 g_string_append_c (res
, ' ');
2179 g_string_append (res
, fancy_name
);
2182 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_METHODSPEC
],
2183 idx
- 1, member_cols
, MONO_METHODSPEC_SIZE
);
2184 token
= member_cols
[MONO_METHODSPEC_SIGNATURE
];
2185 type_param
= get_method_type_param (m
, token
, type_container
);
2186 g_string_append (res
, type_param
);
2187 g_string_append (res
, " (");
2190 * methodspecs can not be varargs so we don't need to worry about that here
2193 for (i
= 0; i
< param_count
; i
++){
2196 ptr
= get_param (m
, ptr
, ¶m
, container
);
2197 g_string_append (res
, param
);
2198 if (i
+1 != param_count
)
2199 g_string_append (res
, ", ");
2202 g_string_append (res
, ")");
2205 * cleanup and return
2208 g_string_free (res
, FALSE
);
2213 * get_encoded_user_string_bytearray:
2214 * @ptr: pointer into the US heap
2215 * @len: length of string in the heap.
2217 * Strings on the US heap are encoded using UTF-16. Print a bytearray.
2220 get_encoded_user_string_bytearray (const unsigned char* ptr
, int len
)
2223 int i
, j
, tspaces
= (len
% 16);
2227 return g_strdup_printf ("\"\"");
2229 res
= g_string_new ("bytearray (\n\t");
2231 for (i
= 1; i
<= len
; ++i
) {
2232 g_string_append_printf (res
, "%02x ", ptr
[i
-1]);
2236 g_string_append (res
, ")// ");
2238 g_string_append (res
, " // ");
2240 for(j
= i
- 16; j
< i
; ++j
)
2241 g_string_append_printf (res
, "%c", isprint (ptr
[j
]) ? ptr
[j
] : '.');
2242 g_string_append (res
, "\n\t");
2247 g_string_append (res
, ") ");
2248 for (i
= tspaces
+ 1; i
< 16; ++i
)
2249 g_string_append_printf (res
, " ");
2251 g_string_append (res
, " // ");
2252 for(i
= len
- tspaces
; i
< len
; ++i
)
2253 g_string_append_printf (res
, "%c", isprint (ptr
[i
]) ? ptr
[i
] : '.');
2254 g_string_append (res
, "\n\t");
2258 g_string_free (res
, FALSE
);
2263 * get_encoded_user_string_or_bytearray:
2264 * @ptr: pointer into the US heap
2266 * Strings on the US heap are encoded using UTF-16. Print as string
2267 * if possible, else emit a bytearray.
2270 get_encoded_user_string_or_bytearray (const unsigned char *ptr
, int len
)
2272 char *res
, *eres
, *result
;
2275 res
= (char *)g_malloc ((len
>> 1) + 1);
2278 * I should really use some kind of libunicode here
2280 for (i
= 0; i
+ 1 < len
; i
+= 2) {
2282 (!isprint (ptr
[i
]) && ptr
[i
] != '\\' && ptr
[i
] != '"' &&
2283 ptr
[i
] != '\r' && ptr
[i
] != '\n' && ptr
[i
] != '\t')) {
2285 return get_encoded_user_string_bytearray (ptr
, len
);
2288 res
[i
>> 1] = ptr
[i
];
2293 eres
= g_strescape (res
, NULL
);
2294 result
= g_strdup_printf ("\"%s\"", eres
);
2302 stringify_double (double r
)
2306 ret
= g_strdup_printf ("%.17g.", r
);
2307 ptr
= ret
+ strlen (ret
) - 1;
2308 if (strpbrk (ret
, ".eE") != ptr
)
2316 * @m: metadata context
2317 * @blob_index: index into the blob where the constant is stored
2319 * Returns: An allocated value representing a stringified version of the
2323 get_constant (MonoImage
*m
, MonoTypeEnum t
, guint32 blob_index
)
2325 const char *ptr
= mono_metadata_blob_heap (m
, blob_index
);
2328 len
= mono_metadata_decode_value (ptr
, &ptr
);
2331 case MONO_TYPE_BOOLEAN
:
2332 return g_strdup_printf ("%s", *ptr
? "bool(true)" : "bool(false)");
2334 case MONO_TYPE_CHAR
:
2335 return g_strdup_printf ("char(0x%04x)", read16(ptr
));
2339 return g_strdup_printf ("int8(0x%02x)", (int) ((*ptr
) & 0xFF));
2344 return g_strdup_printf ("int16(0x%08x)", (int) read16 (ptr
));
2348 return g_strdup_printf ("int32(0x%08x)", read32 (ptr
));
2351 case MONO_TYPE_I8
: {
2354 high
= read32 (ptr
+ 4);
2355 return g_strdup_printf ("int64(0x%08x%08x)", high
, low
);
2357 case MONO_TYPE_R4
: {
2361 if (!mono_isfinite (r
)) {
2362 return g_strdup_printf ("float32(0x%08x)", read32 (ptr
));
2364 char *str
= stringify_double ((double) r
);
2365 char *ret
= g_strdup_printf ("float32(%s)", str
);
2370 case MONO_TYPE_R8
: {
2374 if (!mono_isfinite (r
)) {
2377 high
= read32 (ptr
+ 4);
2378 return g_strdup_printf ("float64(0x%08x%08x)", high
, low
);
2380 char *str
= stringify_double (r
);
2381 char *ret
= g_strdup_printf ("float64(%s)", str
);
2386 case MONO_TYPE_STRING
:
2387 return get_encoded_user_string_or_bytearray ((const guchar
*)ptr
, len
);
2389 case MONO_TYPE_CLASS
:
2390 return g_strdup ("nullref");
2393 g_error ("Unknown MONO_TYPE (%d) on constant at Blob index (0x%08x)\n",
2394 (int) *ptr
, blob_index
);
2395 return g_strdup_printf ("Unknown");
2402 * @m: metadata context
2403 * @token: token that we want to decode.
2405 * Returns: An allocated value representing a stringified version of the
2409 get_token (MonoImage
*m
, guint32 token
, MonoGenericContainer
*container
)
2411 char *temp
, *result
;
2412 guint32 idx
= mono_metadata_token_index (token
);
2414 switch (mono_metadata_token_code (token
)){
2415 case MONO_TOKEN_FIELD_DEF
:
2416 temp
= get_field (m
, token
, container
);
2417 result
= g_strdup_printf ("field %s", temp
);
2420 case MONO_TOKEN_METHOD_DEF
:
2421 case MONO_TOKEN_METHOD_SPEC
:
2422 temp
= get_method (m
, token
, container
);
2423 result
= g_strdup_printf ("method %s", temp
);
2426 case MONO_TOKEN_TYPE_DEF
:
2427 temp
= get_typedef (m
, idx
);
2428 result
= get_escaped_name (temp
);
2431 case MONO_TOKEN_TYPE_REF
:
2432 return get_typeref (m
, idx
);
2433 case MONO_TOKEN_TYPE_SPEC
:
2434 return get_typespec (m
, idx
, TRUE
, container
);
2435 case MONO_TOKEN_MEMBER_REF
: {
2436 guint32 cols
[MONO_MEMBERREF_SIZE
];
2438 mono_metadata_decode_row (&m
->tables
[MONO_TABLE_MEMBERREF
], mono_metadata_token_index (token
) - 1, cols
, MONO_MEMBERREF_SIZE
);
2439 sig
= mono_metadata_blob_heap (m
, cols
[MONO_MEMBERREF_SIGNATURE
]);
2440 mono_metadata_decode_blob_size (sig
, &sig
);
2441 if (*sig
== 0x6) { /* it's a field */
2442 temp
= get_field (m
, token
, container
);
2443 result
= g_strdup_printf ("field %s", temp
);
2447 temp
= get_method (m
, token
, container
);
2448 result
= g_strdup_printf ("method %s", temp
);
2455 g_error ("Do not know how to decode tokens of type 0x%08x", token
);
2458 g_assert_not_reached ();
2459 return g_strdup ("ERROR");
2464 * @m: metadata context
2465 * @token: the token can belong to any of the following tables:
2466 * MONO_TOKEN_TYPE_REF, MONO_TOKEN_TYPE_DEF, MONO_TOKEN_TYPE_SPEC
2468 * Returns: a stringified version of the MethodDef or MethodRef or TypeSpecn
2469 * at (token & 0xffffff)
2472 get_token_type (MonoImage
*m
, guint32 token
, MonoGenericContainer
*container
)
2474 char *temp
= NULL
, *s
= NULL
;
2477 idx
= mono_metadata_token_index (token
);
2479 switch (mono_metadata_token_code (token
)){
2480 case MONO_TOKEN_TYPE_DEF
:
2481 temp
= get_typedef (m
, idx
);
2482 s
= g_strdup_printf ("%s", temp
);
2485 case MONO_TOKEN_TYPE_REF
:
2486 temp
= get_typeref (m
, idx
);
2487 s
= g_strdup_printf ("%s", temp
);
2490 case MONO_TOKEN_TYPE_SPEC
:
2491 s
= get_typespec (m
, idx
, FALSE
, container
);
2495 g_error ("Unhandled encoding for token 0x%08x", token
);
2505 get_guid (MonoImage
*m
, guint32 guid_index
)
2507 const unsigned char *guid
;
2510 guid
= (const guchar
*)mono_metadata_guid_heap (m
, guid_index
);
2512 result
= g_strdup_printf ("{%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
2513 guid
[3], guid
[2], guid
[1], guid
[0], guid
[5], guid
[4], guid
[7], guid
[6],
2514 guid
[8], guid
[9], guid
[10], guid
[11], guid
[12], guid
[13], guid
[14], guid
[15]);
2519 dis_get_custom_attrs (MonoImage
*m
, guint32 token
)
2522 guint32 idx
, i
, len
, mtoken
;
2523 guint32 cols
[MONO_CUSTOM_ATTR_SIZE
];
2529 idx
= mono_metadata_token_index (token
);
2530 idx
<<= MONO_CUSTOM_ATTR_BITS
;
2532 switch (mono_metadata_token_table (token
)) {
2533 case MONO_TABLE_TYPEDEF
:
2534 idx
|= MONO_CUSTOM_ATTR_TYPEDEF
;
2536 case MONO_TABLE_ASSEMBLY
:
2537 idx
|= MONO_CUSTOM_ATTR_ASSEMBLY
;
2539 case MONO_TABLE_ASSEMBLYREF
:
2540 idx
|= MONO_CUSTOM_ATTR_ASSEMBLYREF
;
2542 case MONO_TABLE_MODULE
:
2543 idx
|= MONO_CUSTOM_ATTR_MODULE
;
2545 case MONO_TABLE_PROPERTY
:
2546 idx
|= MONO_CUSTOM_ATTR_PROPERTY
;
2548 case MONO_TABLE_EVENT
:
2549 idx
|= MONO_CUSTOM_ATTR_EVENT
;
2551 case MONO_TABLE_FIELD
:
2552 idx
|= MONO_CUSTOM_ATTR_FIELDDEF
;
2554 case MONO_TABLE_METHOD
:
2555 idx
|= MONO_CUSTOM_ATTR_METHODDEF
;
2557 case MONO_TABLE_PARAM
:
2558 idx
|= MONO_CUSTOM_ATTR_PARAMDEF
;
2560 case MONO_TABLE_GENERICPARAM
:
2561 idx
|= MONO_CUSTOM_ATTR_GENERICPAR
;
2564 g_print ("Missing custom attr get support for token 0x%08x\n", token
);
2568 ca
= &m
->tables
[MONO_TABLE_CUSTOMATTRIBUTE
];
2569 /* the table is not sorted */
2570 for (i
= 0; i
< ca
->rows
; ++i
) {
2572 mono_metadata_decode_row (ca
, i
, cols
, MONO_CUSTOM_ATTR_SIZE
);
2573 if (cols
[MONO_CUSTOM_ATTR_PARENT
] != idx
)
2575 mtoken
= cols
[MONO_CUSTOM_ATTR_TYPE
] >> MONO_CUSTOM_ATTR_TYPE_BITS
;
2576 switch (cols
[MONO_CUSTOM_ATTR_TYPE
] & MONO_CUSTOM_ATTR_TYPE_MASK
) {
2577 case MONO_CUSTOM_ATTR_TYPE_METHODDEF
:
2578 mtoken
|= MONO_TOKEN_METHOD_DEF
;
2580 case MONO_CUSTOM_ATTR_TYPE_MEMBERREF
:
2581 mtoken
|= MONO_TOKEN_MEMBER_REF
;
2584 g_error ("Unknown table for custom attr type %08x", cols
[MONO_CUSTOM_ATTR_TYPE
]);
2587 method
= get_method (m
, mtoken
, NULL
);
2588 val
= mono_metadata_blob_heap (m
, cols
[MONO_CUSTOM_ATTR_VALUE
]);
2589 len
= mono_metadata_decode_value (val
, &val
);
2590 attr
= g_string_new (".custom ");
2591 dump
= data_dump (val
, len
, "\t\t");
2592 g_string_append_printf (attr
, "%s = %s", method
, dump
);
2594 list
= g_list_append (list
, attr
->str
);
2595 g_string_free (attr
, FALSE
);
2602 get_marshal_info (MonoImage
*m
, const char *blob
) {
2605 /* len = */ mono_metadata_decode_blob_size (blob
, &blob
);
2608 case MONO_NATIVE_BOOLEAN
:
2609 return g_strdup ("bool");
2610 case MONO_NATIVE_I1
:
2611 return g_strdup ("int8");
2612 case MONO_NATIVE_U1
:
2613 return g_strdup ("unsigned int8");
2614 case MONO_NATIVE_I2
:
2615 return g_strdup ("int16");
2616 case MONO_NATIVE_U2
:
2617 return g_strdup ("unsigned int16");
2618 case MONO_NATIVE_I4
:
2619 return g_strdup ("int32");
2620 case MONO_NATIVE_U4
:
2621 return g_strdup ("unsigned int32");
2622 case MONO_NATIVE_I8
:
2623 return g_strdup ("int64");
2624 case MONO_NATIVE_U8
:
2625 return g_strdup ("unsigned int64");
2626 case MONO_NATIVE_R4
:
2627 return g_strdup ("float32");
2628 case MONO_NATIVE_R8
:
2629 return g_strdup ("float64");
2630 case MONO_NATIVE_CURRENCY
:
2631 return g_strdup ("currency");
2632 case MONO_NATIVE_BSTR
:
2633 return g_strdup ("bstr");
2634 case MONO_NATIVE_LPSTR
:
2635 return g_strdup ("lpstr");
2636 case MONO_NATIVE_LPWSTR
:
2637 return g_strdup ("lpwstr");
2638 case MONO_NATIVE_LPTSTR
:
2639 return g_strdup ("lptstr");
2640 case MONO_NATIVE_BYVALTSTR
:
2641 size
= mono_metadata_decode_value (blob
+ 1, &blob
);
2642 return g_strdup_printf ("fixed sysstring [%d]", size
);
2643 case MONO_NATIVE_IUNKNOWN
:
2644 return g_strdup ("iunknown");
2645 case MONO_NATIVE_IDISPATCH
:
2646 return g_strdup ("idispatch");
2647 case MONO_NATIVE_STRUCT
:
2648 return g_strdup ("struct");
2649 case MONO_NATIVE_INTERFACE
:
2650 return g_strdup ("interface");
2651 case MONO_NATIVE_SAFEARRAY
:
2652 return g_strdup ("safearray");
2653 case MONO_NATIVE_BYVALARRAY
:
2654 size
= mono_metadata_decode_value (blob
+ 1, &blob
);
2655 return g_strdup_printf ("fixed array [%d]", size
);
2656 case MONO_NATIVE_INT
:
2657 return g_strdup ("int");
2658 case MONO_NATIVE_UINT
:
2659 return g_strdup ("unsigned int");
2660 case MONO_NATIVE_VBBYREFSTR
:
2661 return g_strdup ("vbbyrefstr");
2662 case MONO_NATIVE_ANSIBSTR
:
2663 return g_strdup ("ansi bstr");
2664 case MONO_NATIVE_TBSTR
:
2665 return g_strdup ("tbstr");
2666 case MONO_NATIVE_VARIANTBOOL
:
2667 return g_strdup ("variant bool");
2668 case MONO_NATIVE_FUNC
:
2669 return g_strdup ("method");
2670 case MONO_NATIVE_ASANY
:
2671 return g_strdup ("as any");
2672 case MONO_NATIVE_LPARRAY
:
2673 return g_strdup ("[]");
2674 case MONO_NATIVE_LPSTRUCT
:
2675 return g_strdup ("lpstruct");
2676 case MONO_NATIVE_CUSTOM
:
2677 return g_strdup ("custom");
2678 case MONO_NATIVE_ERROR
:
2679 return g_strdup ("error");
2681 return g_strdup ("unknown");
2686 init_key_table (void)
2688 key_table
= g_hash_table_new (g_str_hash
, g_str_equal
);
2690 g_hash_table_insert (key_table
, (char *) "9", GINT_TO_POINTER (TRUE
));
2691 g_hash_table_insert (key_table
, (char *) "abstract", GINT_TO_POINTER (TRUE
));
2692 g_hash_table_insert (key_table
, (char *) "add", GINT_TO_POINTER (TRUE
));
2693 g_hash_table_insert (key_table
, (char *) "add.ovf", GINT_TO_POINTER (TRUE
));
2694 g_hash_table_insert (key_table
, (char *) "add.ovf.un", GINT_TO_POINTER (TRUE
));
2695 g_hash_table_insert (key_table
, (char *) "algorithm", GINT_TO_POINTER (TRUE
));
2696 g_hash_table_insert (key_table
, (char *) "alignment", GINT_TO_POINTER (TRUE
));
2697 g_hash_table_insert (key_table
, (char *) "and", GINT_TO_POINTER (TRUE
));
2698 g_hash_table_insert (key_table
, (char *) "ansi", GINT_TO_POINTER (TRUE
));
2699 g_hash_table_insert (key_table
, (char *) "any", GINT_TO_POINTER (TRUE
));
2700 g_hash_table_insert (key_table
, (char *) "arglist", GINT_TO_POINTER (TRUE
));
2701 g_hash_table_insert (key_table
, (char *) "array", GINT_TO_POINTER (TRUE
));
2702 g_hash_table_insert (key_table
, (char *) "as", GINT_TO_POINTER (TRUE
));
2703 g_hash_table_insert (key_table
, (char *) "assembly", GINT_TO_POINTER (TRUE
));
2704 g_hash_table_insert (key_table
, (char *) "assert", GINT_TO_POINTER (TRUE
));
2705 g_hash_table_insert (key_table
, (char *) "at", GINT_TO_POINTER (TRUE
));
2706 g_hash_table_insert (key_table
, (char *) "autochar", GINT_TO_POINTER (TRUE
));
2707 g_hash_table_insert (key_table
, (char *) "auto", GINT_TO_POINTER (TRUE
));
2708 g_hash_table_insert (key_table
, (char *) "beforefieldinit", GINT_TO_POINTER (TRUE
));
2709 g_hash_table_insert (key_table
, (char *) "bestfit", GINT_TO_POINTER (TRUE
));
2710 g_hash_table_insert (key_table
, (char *) "beq", GINT_TO_POINTER (TRUE
));
2711 g_hash_table_insert (key_table
, (char *) "beq.s", GINT_TO_POINTER (TRUE
));
2712 g_hash_table_insert (key_table
, (char *) "bge", GINT_TO_POINTER (TRUE
));
2713 g_hash_table_insert (key_table
, (char *) "bge.s", GINT_TO_POINTER (TRUE
));
2714 g_hash_table_insert (key_table
, (char *) "bge.un", GINT_TO_POINTER (TRUE
));
2715 g_hash_table_insert (key_table
, (char *) "bge.un.s", GINT_TO_POINTER (TRUE
));
2716 g_hash_table_insert (key_table
, (char *) "bgt", GINT_TO_POINTER (TRUE
));
2717 g_hash_table_insert (key_table
, (char *) "bgt.s", GINT_TO_POINTER (TRUE
));
2718 g_hash_table_insert (key_table
, (char *) "bgt.un", GINT_TO_POINTER (TRUE
));
2719 g_hash_table_insert (key_table
, (char *) "bgt.un.s", GINT_TO_POINTER (TRUE
));
2720 g_hash_table_insert (key_table
, (char *) "ble", GINT_TO_POINTER (TRUE
));
2721 g_hash_table_insert (key_table
, (char *) "ble.s", GINT_TO_POINTER (TRUE
));
2722 g_hash_table_insert (key_table
, (char *) "ble.un", GINT_TO_POINTER (TRUE
));
2723 g_hash_table_insert (key_table
, (char *) "ble.un.s", GINT_TO_POINTER (TRUE
));
2724 g_hash_table_insert (key_table
, (char *) "blob", GINT_TO_POINTER (TRUE
));
2725 g_hash_table_insert (key_table
, (char *) "blob_object", GINT_TO_POINTER (TRUE
));
2726 g_hash_table_insert (key_table
, (char *) "blt", GINT_TO_POINTER (TRUE
));
2727 g_hash_table_insert (key_table
, (char *) "blt.s", GINT_TO_POINTER (TRUE
));
2728 g_hash_table_insert (key_table
, (char *) "blt.un", GINT_TO_POINTER (TRUE
));
2729 g_hash_table_insert (key_table
, (char *) "blt.un.s", GINT_TO_POINTER (TRUE
));
2730 g_hash_table_insert (key_table
, (char *) "bne.un", GINT_TO_POINTER (TRUE
));
2731 g_hash_table_insert (key_table
, (char *) "bne.un.s", GINT_TO_POINTER (TRUE
));
2732 g_hash_table_insert (key_table
, (char *) "bool", GINT_TO_POINTER (TRUE
));
2733 g_hash_table_insert (key_table
, (char *) "box", GINT_TO_POINTER (TRUE
));
2734 g_hash_table_insert (key_table
, (char *) "break", GINT_TO_POINTER (TRUE
));
2735 g_hash_table_insert (key_table
, (char *) "brfalse", GINT_TO_POINTER (TRUE
));
2736 g_hash_table_insert (key_table
, (char *) "brfalse.s", GINT_TO_POINTER (TRUE
));
2737 g_hash_table_insert (key_table
, (char *) "br", GINT_TO_POINTER (TRUE
));
2738 g_hash_table_insert (key_table
, (char *) "brinst", GINT_TO_POINTER (TRUE
));
2739 g_hash_table_insert (key_table
, (char *) "brinst.s", GINT_TO_POINTER (TRUE
));
2740 g_hash_table_insert (key_table
, (char *) "brnull", GINT_TO_POINTER (TRUE
));
2741 g_hash_table_insert (key_table
, (char *) "brnull.s", GINT_TO_POINTER (TRUE
));
2742 g_hash_table_insert (key_table
, (char *) "br.s", GINT_TO_POINTER (TRUE
));
2743 g_hash_table_insert (key_table
, (char *) "brtrue", GINT_TO_POINTER (TRUE
));
2744 g_hash_table_insert (key_table
, (char *) "brtrue.s", GINT_TO_POINTER (TRUE
));
2745 g_hash_table_insert (key_table
, (char *) "brzero", GINT_TO_POINTER (TRUE
));
2746 g_hash_table_insert (key_table
, (char *) "brzero.s", GINT_TO_POINTER (TRUE
));
2747 g_hash_table_insert (key_table
, (char *) "bstr", GINT_TO_POINTER (TRUE
));
2748 g_hash_table_insert (key_table
, (char *) "bytearray", GINT_TO_POINTER (TRUE
));
2749 g_hash_table_insert (key_table
, (char *) "byvalstr", GINT_TO_POINTER (TRUE
));
2750 g_hash_table_insert (key_table
, (char *) "call", GINT_TO_POINTER (TRUE
));
2751 g_hash_table_insert (key_table
, (char *) "callconv", GINT_TO_POINTER (TRUE
));
2752 g_hash_table_insert (key_table
, (char *) "calli", GINT_TO_POINTER (TRUE
));
2753 g_hash_table_insert (key_table
, (char *) "callmostderived", GINT_TO_POINTER (TRUE
));
2754 g_hash_table_insert (key_table
, (char *) "callvirt", GINT_TO_POINTER (TRUE
));
2755 g_hash_table_insert (key_table
, (char *) "carray", GINT_TO_POINTER (TRUE
));
2756 g_hash_table_insert (key_table
, (char *) "castclass", GINT_TO_POINTER (TRUE
));
2757 g_hash_table_insert (key_table
, (char *) "catch", GINT_TO_POINTER (TRUE
));
2758 g_hash_table_insert (key_table
, (char *) "cdecl", GINT_TO_POINTER (TRUE
));
2759 g_hash_table_insert (key_table
, (char *) "ceq", GINT_TO_POINTER (TRUE
));
2760 g_hash_table_insert (key_table
, (char *) "cf", GINT_TO_POINTER (TRUE
));
2761 g_hash_table_insert (key_table
, (char *) "cgt", GINT_TO_POINTER (TRUE
));
2762 g_hash_table_insert (key_table
, (char *) "cgt.un", GINT_TO_POINTER (TRUE
));
2763 g_hash_table_insert (key_table
, (char *) "char", GINT_TO_POINTER (TRUE
));
2764 g_hash_table_insert (key_table
, (char *) "charmaperror", GINT_TO_POINTER (TRUE
));
2765 g_hash_table_insert (key_table
, (char *) "cil", GINT_TO_POINTER (TRUE
));
2766 g_hash_table_insert (key_table
, (char *) "ckfinite", GINT_TO_POINTER (TRUE
));
2767 g_hash_table_insert (key_table
, (char *) "class", GINT_TO_POINTER (TRUE
));
2768 g_hash_table_insert (key_table
, (char *) "clsid", GINT_TO_POINTER (TRUE
));
2769 g_hash_table_insert (key_table
, (char *) "clt", GINT_TO_POINTER (TRUE
));
2770 g_hash_table_insert (key_table
, (char *) "clt.un", GINT_TO_POINTER (TRUE
));
2771 g_hash_table_insert (key_table
, (char *) "Compilercontrolled", GINT_TO_POINTER (TRUE
));
2772 g_hash_table_insert (key_table
, (char *) "const", GINT_TO_POINTER (TRUE
));
2773 g_hash_table_insert (key_table
, (char *) "conv.i1", GINT_TO_POINTER (TRUE
));
2774 g_hash_table_insert (key_table
, (char *) "conv.i2", GINT_TO_POINTER (TRUE
));
2775 g_hash_table_insert (key_table
, (char *) "conv.i4", GINT_TO_POINTER (TRUE
));
2776 g_hash_table_insert (key_table
, (char *) "conv.i8", GINT_TO_POINTER (TRUE
));
2777 g_hash_table_insert (key_table
, (char *) "conv.i", GINT_TO_POINTER (TRUE
));
2778 g_hash_table_insert (key_table
, (char *) "conv.ovf.i1", GINT_TO_POINTER (TRUE
));
2779 g_hash_table_insert (key_table
, (char *) "conv.ovf.i1.un", GINT_TO_POINTER (TRUE
));
2780 g_hash_table_insert (key_table
, (char *) "conv.ovf.i2", GINT_TO_POINTER (TRUE
));
2781 g_hash_table_insert (key_table
, (char *) "conv.ovf.i2.un", GINT_TO_POINTER (TRUE
));
2782 g_hash_table_insert (key_table
, (char *) "conv.ovf.i4", GINT_TO_POINTER (TRUE
));
2783 g_hash_table_insert (key_table
, (char *) "conv.ovf.i4.un", GINT_TO_POINTER (TRUE
));
2784 g_hash_table_insert (key_table
, (char *) "conv.ovf.i8", GINT_TO_POINTER (TRUE
));
2785 g_hash_table_insert (key_table
, (char *) "conv.ovf.i8.un", GINT_TO_POINTER (TRUE
));
2786 g_hash_table_insert (key_table
, (char *) "conv.ovf.i", GINT_TO_POINTER (TRUE
));
2787 g_hash_table_insert (key_table
, (char *) "conv.ovf.i.un", GINT_TO_POINTER (TRUE
));
2788 g_hash_table_insert (key_table
, (char *) "conv.ovf.u1", GINT_TO_POINTER (TRUE
));
2789 g_hash_table_insert (key_table
, (char *) "conv.ovf.u1.un", GINT_TO_POINTER (TRUE
));
2790 g_hash_table_insert (key_table
, (char *) "conv.ovf.u2", GINT_TO_POINTER (TRUE
));
2791 g_hash_table_insert (key_table
, (char *) "conv.ovf.u2.un", GINT_TO_POINTER (TRUE
));
2792 g_hash_table_insert (key_table
, (char *) "conv.ovf.u4", GINT_TO_POINTER (TRUE
));
2793 g_hash_table_insert (key_table
, (char *) "conv.ovf.u4.un", GINT_TO_POINTER (TRUE
));
2794 g_hash_table_insert (key_table
, (char *) "conv.ovf.u8", GINT_TO_POINTER (TRUE
));
2795 g_hash_table_insert (key_table
, (char *) "conv.ovf.u8.un", GINT_TO_POINTER (TRUE
));
2796 g_hash_table_insert (key_table
, (char *) "conv.ovf.u", GINT_TO_POINTER (TRUE
));
2797 g_hash_table_insert (key_table
, (char *) "conv.ovf.u.un", GINT_TO_POINTER (TRUE
));
2798 g_hash_table_insert (key_table
, (char *) "conv.r4", GINT_TO_POINTER (TRUE
));
2799 g_hash_table_insert (key_table
, (char *) "conv.r8", GINT_TO_POINTER (TRUE
));
2800 g_hash_table_insert (key_table
, (char *) "conv.r.un", GINT_TO_POINTER (TRUE
));
2801 g_hash_table_insert (key_table
, (char *) "conv.u1", GINT_TO_POINTER (TRUE
));
2802 g_hash_table_insert (key_table
, (char *) "conv.u2", GINT_TO_POINTER (TRUE
));
2803 g_hash_table_insert (key_table
, (char *) "conv.u4", GINT_TO_POINTER (TRUE
));
2804 g_hash_table_insert (key_table
, (char *) "conv.u8", GINT_TO_POINTER (TRUE
));
2805 g_hash_table_insert (key_table
, (char *) "conv.u", GINT_TO_POINTER (TRUE
));
2806 g_hash_table_insert (key_table
, (char *) "cpblk", GINT_TO_POINTER (TRUE
));
2807 g_hash_table_insert (key_table
, (char *) "cpobj", GINT_TO_POINTER (TRUE
));
2808 g_hash_table_insert (key_table
, (char *) "currency", GINT_TO_POINTER (TRUE
));
2809 g_hash_table_insert (key_table
, (char *) "custom", GINT_TO_POINTER (TRUE
));
2810 g_hash_table_insert (key_table
, (char *) "date", GINT_TO_POINTER (TRUE
));
2811 g_hash_table_insert (key_table
, (char *) "decimal", GINT_TO_POINTER (TRUE
));
2812 g_hash_table_insert (key_table
, (char *) "default", GINT_TO_POINTER (TRUE
));
2813 g_hash_table_insert (key_table
, (char *) "demand", GINT_TO_POINTER (TRUE
));
2814 g_hash_table_insert (key_table
, (char *) "deny", GINT_TO_POINTER (TRUE
));
2815 g_hash_table_insert (key_table
, (char *) "div", GINT_TO_POINTER (TRUE
));
2816 g_hash_table_insert (key_table
, (char *) "div.un", GINT_TO_POINTER (TRUE
));
2817 g_hash_table_insert (key_table
, (char *) "dup", GINT_TO_POINTER (TRUE
));
2818 g_hash_table_insert (key_table
, (char *) "endfault", GINT_TO_POINTER (TRUE
));
2819 g_hash_table_insert (key_table
, (char *) "endfilter", GINT_TO_POINTER (TRUE
));
2820 g_hash_table_insert (key_table
, (char *) "endfinally", GINT_TO_POINTER (TRUE
));
2821 g_hash_table_insert (key_table
, (char *) "endmac", GINT_TO_POINTER (TRUE
));
2822 g_hash_table_insert (key_table
, (char *) "enum", GINT_TO_POINTER (TRUE
));
2823 g_hash_table_insert (key_table
, (char *) "error", GINT_TO_POINTER (TRUE
));
2824 g_hash_table_insert (key_table
, (char *) "explicit", GINT_TO_POINTER (TRUE
));
2825 g_hash_table_insert (key_table
, (char *) "extends", GINT_TO_POINTER (TRUE
));
2826 g_hash_table_insert (key_table
, (char *) "extern", GINT_TO_POINTER (TRUE
));
2827 g_hash_table_insert (key_table
, (char *) "false", GINT_TO_POINTER (TRUE
));
2828 g_hash_table_insert (key_table
, (char *) "famandassem", GINT_TO_POINTER (TRUE
));
2829 g_hash_table_insert (key_table
, (char *) "family", GINT_TO_POINTER (TRUE
));
2830 g_hash_table_insert (key_table
, (char *) "famorassem", GINT_TO_POINTER (TRUE
));
2831 g_hash_table_insert (key_table
, (char *) "fastcall", GINT_TO_POINTER (TRUE
));
2832 g_hash_table_insert (key_table
, (char *) "fault", GINT_TO_POINTER (TRUE
));
2833 g_hash_table_insert (key_table
, (char *) "field", GINT_TO_POINTER (TRUE
));
2834 g_hash_table_insert (key_table
, (char *) "filetime", GINT_TO_POINTER (TRUE
));
2835 g_hash_table_insert (key_table
, (char *) "filter", GINT_TO_POINTER (TRUE
));
2836 g_hash_table_insert (key_table
, (char *) "final", GINT_TO_POINTER (TRUE
));
2837 g_hash_table_insert (key_table
, (char *) "finally", GINT_TO_POINTER (TRUE
));
2838 g_hash_table_insert (key_table
, (char *) "fixed", GINT_TO_POINTER (TRUE
));
2839 g_hash_table_insert (key_table
, (char *) "flags", GINT_TO_POINTER (TRUE
));
2840 g_hash_table_insert (key_table
, (char *) "float32", GINT_TO_POINTER (TRUE
));
2841 g_hash_table_insert (key_table
, (char *) "float64", GINT_TO_POINTER (TRUE
));
2842 g_hash_table_insert (key_table
, (char *) "float", GINT_TO_POINTER (TRUE
));
2843 g_hash_table_insert (key_table
, (char *) "forwardref", GINT_TO_POINTER (TRUE
));
2844 g_hash_table_insert (key_table
, (char *) "fromunmanaged", GINT_TO_POINTER (TRUE
));
2845 g_hash_table_insert (key_table
, (char *) "handler", GINT_TO_POINTER (TRUE
));
2846 g_hash_table_insert (key_table
, (char *) "hidebysig", GINT_TO_POINTER (TRUE
));
2847 g_hash_table_insert (key_table
, (char *) "hresult", GINT_TO_POINTER (TRUE
));
2848 g_hash_table_insert (key_table
, (char *) "idispatch", GINT_TO_POINTER (TRUE
));
2849 g_hash_table_insert (key_table
, (char *) "il", GINT_TO_POINTER (TRUE
));
2850 g_hash_table_insert (key_table
, (char *) "illegal", GINT_TO_POINTER (TRUE
));
2851 g_hash_table_insert (key_table
, (char *) "implements", GINT_TO_POINTER (TRUE
));
2852 g_hash_table_insert (key_table
, (char *) "implicitcom", GINT_TO_POINTER (TRUE
));
2853 g_hash_table_insert (key_table
, (char *) "implicitres", GINT_TO_POINTER (TRUE
));
2854 g_hash_table_insert (key_table
, (char *) "import", GINT_TO_POINTER (TRUE
));
2855 g_hash_table_insert (key_table
, (char *) "in", GINT_TO_POINTER (TRUE
));
2856 g_hash_table_insert (key_table
, (char *) "inheritcheck", GINT_TO_POINTER (TRUE
));
2857 g_hash_table_insert (key_table
, (char *) "initblk", GINT_TO_POINTER (TRUE
));
2858 g_hash_table_insert (key_table
, (char *) "init", GINT_TO_POINTER (TRUE
));
2859 g_hash_table_insert (key_table
, (char *) "initobj", GINT_TO_POINTER (TRUE
));
2860 g_hash_table_insert (key_table
, (char *) "initonly", GINT_TO_POINTER (TRUE
));
2861 g_hash_table_insert (key_table
, (char *) "instance", GINT_TO_POINTER (TRUE
));
2862 g_hash_table_insert (key_table
, (char *) "int16", GINT_TO_POINTER (TRUE
));
2863 g_hash_table_insert (key_table
, (char *) "int32", GINT_TO_POINTER (TRUE
));
2864 g_hash_table_insert (key_table
, (char *) "int64", GINT_TO_POINTER (TRUE
));
2865 g_hash_table_insert (key_table
, (char *) "int8", GINT_TO_POINTER (TRUE
));
2866 g_hash_table_insert (key_table
, (char *) "interface", GINT_TO_POINTER (TRUE
));
2867 g_hash_table_insert (key_table
, (char *) "internalcall", GINT_TO_POINTER (TRUE
));
2868 g_hash_table_insert (key_table
, (char *) "int", GINT_TO_POINTER (TRUE
));
2869 g_hash_table_insert (key_table
, (char *) "isinst", GINT_TO_POINTER (TRUE
));
2870 g_hash_table_insert (key_table
, (char *) "iunknown", GINT_TO_POINTER (TRUE
));
2871 g_hash_table_insert (key_table
, (char *) "jmp", GINT_TO_POINTER (TRUE
));
2872 g_hash_table_insert (key_table
, (char *) "lasterr", GINT_TO_POINTER (TRUE
));
2873 g_hash_table_insert (key_table
, (char *) "lcid", GINT_TO_POINTER (TRUE
));
2874 g_hash_table_insert (key_table
, (char *) "ldarg.0", GINT_TO_POINTER (TRUE
));
2875 g_hash_table_insert (key_table
, (char *) "ldarg.1", GINT_TO_POINTER (TRUE
));
2876 g_hash_table_insert (key_table
, (char *) "ldarg.2", GINT_TO_POINTER (TRUE
));
2877 g_hash_table_insert (key_table
, (char *) "ldarg.3", GINT_TO_POINTER (TRUE
));
2878 g_hash_table_insert (key_table
, (char *) "ldarga", GINT_TO_POINTER (TRUE
));
2879 g_hash_table_insert (key_table
, (char *) "ldarga.s", GINT_TO_POINTER (TRUE
));
2880 g_hash_table_insert (key_table
, (char *) "ldarg", GINT_TO_POINTER (TRUE
));
2881 g_hash_table_insert (key_table
, (char *) "ldarg.s", GINT_TO_POINTER (TRUE
));
2882 g_hash_table_insert (key_table
, (char *) "ldc.i4.0", GINT_TO_POINTER (TRUE
));
2883 g_hash_table_insert (key_table
, (char *) "ldc.i4.1", GINT_TO_POINTER (TRUE
));
2884 g_hash_table_insert (key_table
, (char *) "ldc.i4.2", GINT_TO_POINTER (TRUE
));
2885 g_hash_table_insert (key_table
, (char *) "ldc.i4.3", GINT_TO_POINTER (TRUE
));
2886 g_hash_table_insert (key_table
, (char *) "ldc.i4.4", GINT_TO_POINTER (TRUE
));
2887 g_hash_table_insert (key_table
, (char *) "ldc.i4.5", GINT_TO_POINTER (TRUE
));
2888 g_hash_table_insert (key_table
, (char *) "ldc.i4.6", GINT_TO_POINTER (TRUE
));
2889 g_hash_table_insert (key_table
, (char *) "ldc.i4.7", GINT_TO_POINTER (TRUE
));
2890 g_hash_table_insert (key_table
, (char *) "ldc.i4.8", GINT_TO_POINTER (TRUE
));
2891 g_hash_table_insert (key_table
, (char *) "ldc.i4", GINT_TO_POINTER (TRUE
));
2892 g_hash_table_insert (key_table
, (char *) "ldc.i4.m1", GINT_TO_POINTER (TRUE
));
2893 g_hash_table_insert (key_table
, (char *) "ldc.i4.M1", GINT_TO_POINTER (TRUE
));
2894 g_hash_table_insert (key_table
, (char *) "ldc.i4.s", GINT_TO_POINTER (TRUE
));
2895 g_hash_table_insert (key_table
, (char *) "ldc.i8", GINT_TO_POINTER (TRUE
));
2896 g_hash_table_insert (key_table
, (char *) "ldc.r4", GINT_TO_POINTER (TRUE
));
2897 g_hash_table_insert (key_table
, (char *) "ldc.r8", GINT_TO_POINTER (TRUE
));
2898 g_hash_table_insert (key_table
, (char *) "ldelem", GINT_TO_POINTER (TRUE
));
2899 g_hash_table_insert (key_table
, (char *) "ldelema", GINT_TO_POINTER (TRUE
));
2900 g_hash_table_insert (key_table
, (char *) "ldelem.i1", GINT_TO_POINTER (TRUE
));
2901 g_hash_table_insert (key_table
, (char *) "ldelem.i2", GINT_TO_POINTER (TRUE
));
2902 g_hash_table_insert (key_table
, (char *) "ldelem.i4", GINT_TO_POINTER (TRUE
));
2903 g_hash_table_insert (key_table
, (char *) "ldelem.i8", GINT_TO_POINTER (TRUE
));
2904 g_hash_table_insert (key_table
, (char *) "ldelem.i", GINT_TO_POINTER (TRUE
));
2905 g_hash_table_insert (key_table
, (char *) "ldelem.r4", GINT_TO_POINTER (TRUE
));
2906 g_hash_table_insert (key_table
, (char *) "ldelem.r8", GINT_TO_POINTER (TRUE
));
2907 g_hash_table_insert (key_table
, (char *) "ldelem.ref", GINT_TO_POINTER (TRUE
));
2908 g_hash_table_insert (key_table
, (char *) "ldelem.u1", GINT_TO_POINTER (TRUE
));
2909 g_hash_table_insert (key_table
, (char *) "ldelem.u2", GINT_TO_POINTER (TRUE
));
2910 g_hash_table_insert (key_table
, (char *) "ldelem.u4", GINT_TO_POINTER (TRUE
));
2911 g_hash_table_insert (key_table
, (char *) "ldelem.u8", GINT_TO_POINTER (TRUE
));
2912 g_hash_table_insert (key_table
, (char *) "ldflda", GINT_TO_POINTER (TRUE
));
2913 g_hash_table_insert (key_table
, (char *) "ldfld", GINT_TO_POINTER (TRUE
));
2914 g_hash_table_insert (key_table
, (char *) "ldftn", GINT_TO_POINTER (TRUE
));
2915 g_hash_table_insert (key_table
, (char *) "ldind.i1", GINT_TO_POINTER (TRUE
));
2916 g_hash_table_insert (key_table
, (char *) "ldind.i2", GINT_TO_POINTER (TRUE
));
2917 g_hash_table_insert (key_table
, (char *) "ldind.i4", GINT_TO_POINTER (TRUE
));
2918 g_hash_table_insert (key_table
, (char *) "ldind.i8", GINT_TO_POINTER (TRUE
));
2919 g_hash_table_insert (key_table
, (char *) "ldind.i", GINT_TO_POINTER (TRUE
));
2920 g_hash_table_insert (key_table
, (char *) "ldind.r4", GINT_TO_POINTER (TRUE
));
2921 g_hash_table_insert (key_table
, (char *) "ldind.r8", GINT_TO_POINTER (TRUE
));
2922 g_hash_table_insert (key_table
, (char *) "ldind.ref", GINT_TO_POINTER (TRUE
));
2923 g_hash_table_insert (key_table
, (char *) "ldind.u1", GINT_TO_POINTER (TRUE
));
2924 g_hash_table_insert (key_table
, (char *) "ldind.u2", GINT_TO_POINTER (TRUE
));
2925 g_hash_table_insert (key_table
, (char *) "ldind.u4", GINT_TO_POINTER (TRUE
));
2926 g_hash_table_insert (key_table
, (char *) "ldind.u8", GINT_TO_POINTER (TRUE
));
2927 g_hash_table_insert (key_table
, (char *) "ldlen", GINT_TO_POINTER (TRUE
));
2928 g_hash_table_insert (key_table
, (char *) "ldloc.0", GINT_TO_POINTER (TRUE
));
2929 g_hash_table_insert (key_table
, (char *) "ldloc.1", GINT_TO_POINTER (TRUE
));
2930 g_hash_table_insert (key_table
, (char *) "ldloc.2", GINT_TO_POINTER (TRUE
));
2931 g_hash_table_insert (key_table
, (char *) "ldloc.3", GINT_TO_POINTER (TRUE
));
2932 g_hash_table_insert (key_table
, (char *) "ldloca", GINT_TO_POINTER (TRUE
));
2933 g_hash_table_insert (key_table
, (char *) "ldloca.s", GINT_TO_POINTER (TRUE
));
2934 g_hash_table_insert (key_table
, (char *) "ldloc", GINT_TO_POINTER (TRUE
));
2935 g_hash_table_insert (key_table
, (char *) "ldloc.s", GINT_TO_POINTER (TRUE
));
2936 g_hash_table_insert (key_table
, (char *) "ldnull", GINT_TO_POINTER (TRUE
));
2937 g_hash_table_insert (key_table
, (char *) "ldobj", GINT_TO_POINTER (TRUE
));
2938 g_hash_table_insert (key_table
, (char *) "ldsflda", GINT_TO_POINTER (TRUE
));
2939 g_hash_table_insert (key_table
, (char *) "ldsfld", GINT_TO_POINTER (TRUE
));
2940 g_hash_table_insert (key_table
, (char *) "ldstr", GINT_TO_POINTER (TRUE
));
2941 g_hash_table_insert (key_table
, (char *) "ldtoken", GINT_TO_POINTER (TRUE
));
2942 g_hash_table_insert (key_table
, (char *) "ldvirtftn", GINT_TO_POINTER (TRUE
));
2943 g_hash_table_insert (key_table
, (char *) "leave", GINT_TO_POINTER (TRUE
));
2944 g_hash_table_insert (key_table
, (char *) "leave.s", GINT_TO_POINTER (TRUE
));
2945 g_hash_table_insert (key_table
, (char *) "legacy", GINT_TO_POINTER (TRUE
));
2946 g_hash_table_insert (key_table
, (char *) "linkcheck", GINT_TO_POINTER (TRUE
));
2947 g_hash_table_insert (key_table
, (char *) "literal", GINT_TO_POINTER (TRUE
));
2948 g_hash_table_insert (key_table
, (char *) "localloc", GINT_TO_POINTER (TRUE
));
2949 g_hash_table_insert (key_table
, (char *) "lpstr", GINT_TO_POINTER (TRUE
));
2950 g_hash_table_insert (key_table
, (char *) "lpstruct", GINT_TO_POINTER (TRUE
));
2951 g_hash_table_insert (key_table
, (char *) "lptstr", GINT_TO_POINTER (TRUE
));
2952 g_hash_table_insert (key_table
, (char *) "lpvoid", GINT_TO_POINTER (TRUE
));
2953 g_hash_table_insert (key_table
, (char *) "lpwstr", GINT_TO_POINTER (TRUE
));
2954 g_hash_table_insert (key_table
, (char *) "managed", GINT_TO_POINTER (TRUE
));
2955 g_hash_table_insert (key_table
, (char *) "marshal", GINT_TO_POINTER (TRUE
));
2956 g_hash_table_insert (key_table
, (char *) "method", GINT_TO_POINTER (TRUE
));
2957 g_hash_table_insert (key_table
, (char *) "mkrefany", GINT_TO_POINTER (TRUE
));
2958 g_hash_table_insert (key_table
, (char *) "modopt", GINT_TO_POINTER (TRUE
));
2959 g_hash_table_insert (key_table
, (char *) "modreq", GINT_TO_POINTER (TRUE
));
2960 g_hash_table_insert (key_table
, (char *) "mul", GINT_TO_POINTER (TRUE
));
2961 g_hash_table_insert (key_table
, (char *) "mul.ovf", GINT_TO_POINTER (TRUE
));
2962 g_hash_table_insert (key_table
, (char *) "mul.ovf.un", GINT_TO_POINTER (TRUE
));
2963 g_hash_table_insert (key_table
, (char *) "native", GINT_TO_POINTER (TRUE
));
2964 g_hash_table_insert (key_table
, (char *) "neg", GINT_TO_POINTER (TRUE
));
2965 g_hash_table_insert (key_table
, (char *) "nested", GINT_TO_POINTER (TRUE
));
2966 g_hash_table_insert (key_table
, (char *) "newarr", GINT_TO_POINTER (TRUE
));
2967 g_hash_table_insert (key_table
, (char *) "newobj", GINT_TO_POINTER (TRUE
));
2968 g_hash_table_insert (key_table
, (char *) "newslot", GINT_TO_POINTER (TRUE
));
2969 g_hash_table_insert (key_table
, (char *) "noappdomain", GINT_TO_POINTER (TRUE
));
2970 g_hash_table_insert (key_table
, (char *) "noinlining", GINT_TO_POINTER (TRUE
));
2971 g_hash_table_insert (key_table
, (char *) "nomachine", GINT_TO_POINTER (TRUE
));
2972 g_hash_table_insert (key_table
, (char *) "nomangle", GINT_TO_POINTER (TRUE
));
2973 g_hash_table_insert (key_table
, (char *) "nometadata", GINT_TO_POINTER (TRUE
));
2974 g_hash_table_insert (key_table
, (char *) "noncasdemand", GINT_TO_POINTER (TRUE
));
2975 g_hash_table_insert (key_table
, (char *) "noncasinheritance", GINT_TO_POINTER (TRUE
));
2976 g_hash_table_insert (key_table
, (char *) "noncaslinkdemand", GINT_TO_POINTER (TRUE
));
2977 g_hash_table_insert (key_table
, (char *) "nop", GINT_TO_POINTER (TRUE
));
2978 g_hash_table_insert (key_table
, (char *) "noprocess", GINT_TO_POINTER (TRUE
));
2979 g_hash_table_insert (key_table
, (char *) "not", GINT_TO_POINTER (TRUE
));
2980 g_hash_table_insert (key_table
, (char *) "not_in_gc_heap", GINT_TO_POINTER (TRUE
));
2981 g_hash_table_insert (key_table
, (char *) "notremotable", GINT_TO_POINTER (TRUE
));
2982 g_hash_table_insert (key_table
, (char *) "notserialized", GINT_TO_POINTER (TRUE
));
2983 g_hash_table_insert (key_table
, (char *) "null", GINT_TO_POINTER (TRUE
));
2984 g_hash_table_insert (key_table
, (char *) "nullref", GINT_TO_POINTER (TRUE
));
2985 g_hash_table_insert (key_table
, (char *) "object", GINT_TO_POINTER (TRUE
));
2986 g_hash_table_insert (key_table
, (char *) "objectref", GINT_TO_POINTER (TRUE
));
2987 g_hash_table_insert (key_table
, (char *) "off", GINT_TO_POINTER (TRUE
));
2988 g_hash_table_insert (key_table
, (char *) "on", GINT_TO_POINTER (TRUE
));
2989 g_hash_table_insert (key_table
, (char *) "opt", GINT_TO_POINTER (TRUE
));
2990 g_hash_table_insert (key_table
, (char *) "optil", GINT_TO_POINTER (TRUE
));
2991 g_hash_table_insert (key_table
, (char *) "or", GINT_TO_POINTER (TRUE
));
2992 g_hash_table_insert (key_table
, (char *) "out", GINT_TO_POINTER (TRUE
));
2993 g_hash_table_insert (key_table
, (char *) "permitonly", GINT_TO_POINTER (TRUE
));
2994 g_hash_table_insert (key_table
, (char *) "pinned", GINT_TO_POINTER (TRUE
));
2995 g_hash_table_insert (key_table
, (char *) "pinvokeimpl", GINT_TO_POINTER (TRUE
));
2996 g_hash_table_insert (key_table
, (char *) "pop", GINT_TO_POINTER (TRUE
));
2997 g_hash_table_insert (key_table
, (char *) "prefix1", GINT_TO_POINTER (TRUE
));
2998 g_hash_table_insert (key_table
, (char *) "prefix2", GINT_TO_POINTER (TRUE
));
2999 g_hash_table_insert (key_table
, (char *) "prefix3", GINT_TO_POINTER (TRUE
));
3000 g_hash_table_insert (key_table
, (char *) "prefix4", GINT_TO_POINTER (TRUE
));
3001 g_hash_table_insert (key_table
, (char *) "prefix5", GINT_TO_POINTER (TRUE
));
3002 g_hash_table_insert (key_table
, (char *) "prefix6", GINT_TO_POINTER (TRUE
));
3003 g_hash_table_insert (key_table
, (char *) "prefix7", GINT_TO_POINTER (TRUE
));
3004 g_hash_table_insert (key_table
, (char *) "prefixref", GINT_TO_POINTER (TRUE
));
3005 g_hash_table_insert (key_table
, (char *) "prejitdeny", GINT_TO_POINTER (TRUE
));
3006 g_hash_table_insert (key_table
, (char *) "prejitgrant", GINT_TO_POINTER (TRUE
));
3007 g_hash_table_insert (key_table
, (char *) "preservesig", GINT_TO_POINTER (TRUE
));
3008 g_hash_table_insert (key_table
, (char *) "private", GINT_TO_POINTER (TRUE
));
3009 g_hash_table_insert (key_table
, (char *) "privatescope", GINT_TO_POINTER (TRUE
));
3010 g_hash_table_insert (key_table
, (char *) "property", GINT_TO_POINTER (TRUE
));
3011 g_hash_table_insert (key_table
, (char *) "protected", GINT_TO_POINTER (TRUE
));
3012 g_hash_table_insert (key_table
, (char *) "public", GINT_TO_POINTER (TRUE
));
3013 g_hash_table_insert (key_table
, (char *) "readonly", GINT_TO_POINTER (TRUE
));
3014 g_hash_table_insert (key_table
, (char *) "record", GINT_TO_POINTER (TRUE
));
3015 g_hash_table_insert (key_table
, (char *) "refany", GINT_TO_POINTER (TRUE
));
3016 g_hash_table_insert (key_table
, (char *) "refanytype", GINT_TO_POINTER (TRUE
));
3017 g_hash_table_insert (key_table
, (char *) "refanyval", GINT_TO_POINTER (TRUE
));
3018 g_hash_table_insert (key_table
, (char *) "rem", GINT_TO_POINTER (TRUE
));
3019 g_hash_table_insert (key_table
, (char *) "rem.un", GINT_TO_POINTER (TRUE
));
3020 g_hash_table_insert (key_table
, (char *) "reqmin", GINT_TO_POINTER (TRUE
));
3021 g_hash_table_insert (key_table
, (char *) "reqopt", GINT_TO_POINTER (TRUE
));
3022 g_hash_table_insert (key_table
, (char *) "reqrefuse", GINT_TO_POINTER (TRUE
));
3023 g_hash_table_insert (key_table
, (char *) "reqsecobj", GINT_TO_POINTER (TRUE
));
3024 g_hash_table_insert (key_table
, (char *) "request", GINT_TO_POINTER (TRUE
));
3025 g_hash_table_insert (key_table
, (char *) "ret", GINT_TO_POINTER (TRUE
));
3026 g_hash_table_insert (key_table
, (char *) "rethrow", GINT_TO_POINTER (TRUE
));
3027 g_hash_table_insert (key_table
, (char *) "retval", GINT_TO_POINTER (TRUE
));
3028 g_hash_table_insert (key_table
, (char *) "rtspecialname", GINT_TO_POINTER (TRUE
));
3029 g_hash_table_insert (key_table
, (char *) "runtime", GINT_TO_POINTER (TRUE
));
3030 g_hash_table_insert (key_table
, (char *) "safearray", GINT_TO_POINTER (TRUE
));
3031 g_hash_table_insert (key_table
, (char *) "sealed", GINT_TO_POINTER (TRUE
));
3032 g_hash_table_insert (key_table
, (char *) "sequential", GINT_TO_POINTER (TRUE
));
3033 g_hash_table_insert (key_table
, (char *) "serializable", GINT_TO_POINTER (TRUE
));
3034 g_hash_table_insert (key_table
, (char *) "shl", GINT_TO_POINTER (TRUE
));
3035 g_hash_table_insert (key_table
, (char *) "shr", GINT_TO_POINTER (TRUE
));
3036 g_hash_table_insert (key_table
, (char *) "shr.un", GINT_TO_POINTER (TRUE
));
3037 g_hash_table_insert (key_table
, (char *) "sizeof", GINT_TO_POINTER (TRUE
));
3038 g_hash_table_insert (key_table
, (char *) "special", GINT_TO_POINTER (TRUE
));
3039 g_hash_table_insert (key_table
, (char *) "specialname", GINT_TO_POINTER (TRUE
));
3040 g_hash_table_insert (key_table
, (char *) "starg", GINT_TO_POINTER (TRUE
));
3041 g_hash_table_insert (key_table
, (char *) "starg.s", GINT_TO_POINTER (TRUE
));
3042 g_hash_table_insert (key_table
, (char *) "static", GINT_TO_POINTER (TRUE
));
3043 g_hash_table_insert (key_table
, (char *) "stdcall", GINT_TO_POINTER (TRUE
));
3044 g_hash_table_insert (key_table
, (char *) "stelem", GINT_TO_POINTER (TRUE
));
3045 g_hash_table_insert (key_table
, (char *) "stelem.i1", GINT_TO_POINTER (TRUE
));
3046 g_hash_table_insert (key_table
, (char *) "stelem.i2", GINT_TO_POINTER (TRUE
));
3047 g_hash_table_insert (key_table
, (char *) "stelem.i4", GINT_TO_POINTER (TRUE
));
3048 g_hash_table_insert (key_table
, (char *) "stelem.i8", GINT_TO_POINTER (TRUE
));
3049 g_hash_table_insert (key_table
, (char *) "stelem.i", GINT_TO_POINTER (TRUE
));
3050 g_hash_table_insert (key_table
, (char *) "stelem.r4", GINT_TO_POINTER (TRUE
));
3051 g_hash_table_insert (key_table
, (char *) "stelem.r8", GINT_TO_POINTER (TRUE
));
3052 g_hash_table_insert (key_table
, (char *) "stelem.ref", GINT_TO_POINTER (TRUE
));
3053 g_hash_table_insert (key_table
, (char *) "stfld", GINT_TO_POINTER (TRUE
));
3054 g_hash_table_insert (key_table
, (char *) "stind.i1", GINT_TO_POINTER (TRUE
));
3055 g_hash_table_insert (key_table
, (char *) "stind.i2", GINT_TO_POINTER (TRUE
));
3056 g_hash_table_insert (key_table
, (char *) "stind.i4", GINT_TO_POINTER (TRUE
));
3057 g_hash_table_insert (key_table
, (char *) "stind.i8", GINT_TO_POINTER (TRUE
));
3058 g_hash_table_insert (key_table
, (char *) "stind.i", GINT_TO_POINTER (TRUE
));
3059 g_hash_table_insert (key_table
, (char *) "stind.r4", GINT_TO_POINTER (TRUE
));
3060 g_hash_table_insert (key_table
, (char *) "stind.r8", GINT_TO_POINTER (TRUE
));
3061 g_hash_table_insert (key_table
, (char *) "stloc", GINT_TO_POINTER (TRUE
));
3062 g_hash_table_insert (key_table
, (char *) "stobj", GINT_TO_POINTER (TRUE
));
3063 g_hash_table_insert (key_table
, (char *) "storage", GINT_TO_POINTER (TRUE
));
3064 g_hash_table_insert (key_table
, (char *) "stored_object", GINT_TO_POINTER (TRUE
));
3065 g_hash_table_insert (key_table
, (char *) "streamed_object", GINT_TO_POINTER (TRUE
));
3066 g_hash_table_insert (key_table
, (char *) "stream", GINT_TO_POINTER (TRUE
));
3067 g_hash_table_insert (key_table
, (char *) "strict", GINT_TO_POINTER (TRUE
));
3068 g_hash_table_insert (key_table
, (char *) "string", GINT_TO_POINTER (TRUE
));
3069 g_hash_table_insert (key_table
, (char *) "struct", GINT_TO_POINTER (TRUE
));
3070 g_hash_table_insert (key_table
, (char *) "stsfld", GINT_TO_POINTER (TRUE
));
3071 g_hash_table_insert (key_table
, (char *) "sub", GINT_TO_POINTER (TRUE
));
3072 g_hash_table_insert (key_table
, (char *) "sub.ovf", GINT_TO_POINTER (TRUE
));
3073 g_hash_table_insert (key_table
, (char *) "sub.ovf.un", GINT_TO_POINTER (TRUE
));
3074 g_hash_table_insert (key_table
, (char *) "switch", GINT_TO_POINTER (TRUE
));
3075 g_hash_table_insert (key_table
, (char *) "synchronized", GINT_TO_POINTER (TRUE
));
3076 g_hash_table_insert (key_table
, (char *) "syschar", GINT_TO_POINTER (TRUE
));
3077 g_hash_table_insert (key_table
, (char *) "sysstring", GINT_TO_POINTER (TRUE
));
3078 g_hash_table_insert (key_table
, (char *) "tbstr", GINT_TO_POINTER (TRUE
));
3079 g_hash_table_insert (key_table
, (char *) "thiscall", GINT_TO_POINTER (TRUE
));
3080 g_hash_table_insert (key_table
, (char *) "tls", GINT_TO_POINTER (TRUE
));
3081 g_hash_table_insert (key_table
, (char *) "to", GINT_TO_POINTER (TRUE
));
3082 g_hash_table_insert (key_table
, (char *) "true", GINT_TO_POINTER (TRUE
));
3083 g_hash_table_insert (key_table
, (char *) "type", GINT_TO_POINTER (TRUE
));
3084 g_hash_table_insert (key_table
, (char *) "typedref", GINT_TO_POINTER (TRUE
));
3085 g_hash_table_insert (key_table
, (char *) "uint", GINT_TO_POINTER (TRUE
));
3086 g_hash_table_insert (key_table
, (char *) "uint8", GINT_TO_POINTER (TRUE
));
3087 g_hash_table_insert (key_table
, (char *) "uint16", GINT_TO_POINTER (TRUE
));
3088 g_hash_table_insert (key_table
, (char *) "uint32", GINT_TO_POINTER (TRUE
));
3089 g_hash_table_insert (key_table
, (char *) "uint64", GINT_TO_POINTER (TRUE
));
3090 g_hash_table_insert (key_table
, (char *) "unbox", GINT_TO_POINTER (TRUE
));
3091 g_hash_table_insert (key_table
, (char *) "unicode", GINT_TO_POINTER (TRUE
));
3092 g_hash_table_insert (key_table
, (char *) "unmanagedexp", GINT_TO_POINTER (TRUE
));
3093 g_hash_table_insert (key_table
, (char *) "unmanaged", GINT_TO_POINTER (TRUE
));
3094 g_hash_table_insert (key_table
, (char *) "unsigned", GINT_TO_POINTER (TRUE
));
3095 g_hash_table_insert (key_table
, (char *) "userdefined", GINT_TO_POINTER (TRUE
));
3096 g_hash_table_insert (key_table
, (char *) "value", GINT_TO_POINTER (TRUE
));
3097 g_hash_table_insert (key_table
, (char *) "valuetype", GINT_TO_POINTER (TRUE
));
3098 g_hash_table_insert (key_table
, (char *) "vararg", GINT_TO_POINTER (TRUE
));
3099 g_hash_table_insert (key_table
, (char *) "variant", GINT_TO_POINTER (TRUE
));
3100 g_hash_table_insert (key_table
, (char *) "vector", GINT_TO_POINTER (TRUE
));
3101 g_hash_table_insert (key_table
, (char *) "virtual", GINT_TO_POINTER (TRUE
));
3102 g_hash_table_insert (key_table
, (char *) "void", GINT_TO_POINTER (TRUE
));
3103 g_hash_table_insert (key_table
, (char *) "wchar", GINT_TO_POINTER (TRUE
));
3104 g_hash_table_insert (key_table
, (char *) "winapi", GINT_TO_POINTER (TRUE
));
3105 g_hash_table_insert (key_table
, (char *) "with", GINT_TO_POINTER (TRUE
));
3106 g_hash_table_insert (key_table
, (char *) "xor", GINT_TO_POINTER (TRUE
));
3110 method_dor_to_token (guint32 idx
) {
3111 switch (idx
& MONO_METHODDEFORREF_MASK
) {
3112 case MONO_METHODDEFORREF_METHODDEF
:
3113 return MONO_TOKEN_METHOD_DEF
| (idx
>> MONO_METHODDEFORREF_BITS
);
3114 case MONO_METHODDEFORREF_METHODREF
:
3115 return MONO_TOKEN_MEMBER_REF
| (idx
>> MONO_METHODDEFORREF_BITS
);
3121 get_method_override (MonoImage
*m
, guint32 token
, MonoGenericContainer
*container
)
3123 MonoTableInfo
*t
= &m
->tables
[MONO_TABLE_METHODIMPL
];
3126 for (i
= 1; i
<= t
->rows
; i
++){
3127 guint32 cols
[MONO_METHODIMPL_SIZE
];
3130 mono_metadata_decode_row (t
, i
- 1, cols
, MONO_METHODIMPL_SIZE
);
3132 impl
= method_dor_to_token (cols
[MONO_METHODIMPL_BODY
]);
3133 decl
= method_dor_to_token (cols
[MONO_METHODIMPL_DECLARATION
]);
3135 if (token
== impl
) {
3137 MonoMethod
*mh
= NULL
;
3138 mh
= mono_get_method_checked (m
, decl
, NULL
, (MonoGenericContext
*) container
, error
);
3140 if (mh
&& (mh
->klass
&& (mono_class_is_ginst (mh
->klass
) || mono_class_is_gtd (mh
->klass
)))) {
3144 meth_str
= get_method_core (m
, decl
, TRUE
, container
);
3145 ret
= g_strdup_printf ("method %s", meth_str
);
3149 if (!mono_error_ok (error
)) {
3150 char *meth_str
= get_method_core (m
, decl
, FALSE
, container
);
3151 char *ret
= g_strdup_printf ("Could not decode method override %s due to %s", meth_str
, mono_error_get_message (error
));
3153 mono_error_cleanup (error
);
3157 return get_method_core (m
, decl
, FALSE
, container
);
3167 check_ambiguous_genparams (MonoGenericContainer
*container
)
3169 GSList
*dup_list
= NULL
, *l
;
3170 GHashTable
*table
= NULL
;
3177 if (generic_containers
&& g_hash_table_lookup (generic_containers
, container
))
3178 /* Already been checked for ambiguous gen params */
3181 table
= g_hash_table_new (g_str_hash
, g_str_equal
);
3182 for (i
= 0; i
< container
->type_argc
; i
++) {
3183 MonoGenericParam
*param
= mono_generic_container_get_param (container
, i
);
3185 if ((p
= (gpointer
*)g_hash_table_lookup (table
, mono_generic_param_info (param
)->name
)))
3186 dup_list
= g_slist_prepend (g_slist_prepend (dup_list
, GUINT_TO_POINTER (i
+ 1)), p
);
3188 g_hash_table_insert (table
, (char*)mono_generic_param_info (param
)->name
, GUINT_TO_POINTER (i
+ 1));
3192 if (!mono_generic_params_with_ambiguous_names
)
3193 mono_generic_params_with_ambiguous_names
= g_hash_table_new (NULL
, NULL
);
3194 for (l
= dup_list
; l
; l
= l
->next
) {
3195 int param
= GPOINTER_TO_UINT (l
->data
);
3196 g_hash_table_insert (mono_generic_params_with_ambiguous_names
,
3197 mono_generic_container_get_param (container
, param
-1),
3198 mono_generic_container_get_param (container
, param
-1));
3200 g_slist_free (dup_list
);
3203 if (!generic_containers
)
3204 generic_containers
= g_hash_table_new (NULL
, NULL
);
3206 g_hash_table_insert (generic_containers
, container
, container
);
3207 g_hash_table_destroy (table
);
3211 cant_print_generic_param_name (MonoGenericParam
*gparam
)
3213 MonoGenericContainer
*container
;
3216 container
= mono_generic_param_owner (gparam
);
3217 check_ambiguous_genparams (container
);
3218 return (!container
|| (mono_generic_params_with_ambiguous_names
&&
3219 g_hash_table_lookup (mono_generic_params_with_ambiguous_names
, gparam
)) || !mono_generic_param_info (gparam
));
3223 static dis_map_t method_impl_map
[] = {
3224 { METHOD_IMPL_ATTRIBUTE_IL
, "cil " },
3225 { METHOD_IMPL_ATTRIBUTE_NATIVE
, "native " },
3226 { METHOD_IMPL_ATTRIBUTE_OPTIL
, "optil " },
3227 { METHOD_IMPL_ATTRIBUTE_RUNTIME
, "runtime " },
3231 static dis_map_t managed_type_map
[] = {
3232 { METHOD_IMPL_ATTRIBUTE_UNMANAGED
, "unmanaged " },
3233 { METHOD_IMPL_ATTRIBUTE_MANAGED
, "managed " },
3237 static dis_map_t managed_impl_flags
[] = {
3238 { METHOD_IMPL_ATTRIBUTE_FORWARD_REF
, "fwdref " },
3239 { METHOD_IMPL_ATTRIBUTE_PRESERVE_SIG
, "preservesig " },
3240 { METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL
, "internalcall " },
3241 { METHOD_IMPL_ATTRIBUTE_SYNCHRONIZED
, "synchronized " },
3242 { METHOD_IMPL_ATTRIBUTE_NOINLINING
, "noinlining " },
3243 { METHOD_IMPL_ATTRIBUTE_NOOPTIMIZATION
, "nooptimization " },
3244 { METHOD_IMPL_ATTRIBUTE_AGGRESSIVE_INLINING
, "agressive-inlining" },
3249 get_method_impl_flags (guint32 f
)
3251 GString
*str
= g_string_new ("");
3253 int code_type
= f
& METHOD_IMPL_ATTRIBUTE_CODE_TYPE_MASK
;
3254 int managed_type
= f
& METHOD_IMPL_ATTRIBUTE_MANAGED_MASK
;
3255 int rest
= f
& ~(code_type
| managed_type
);
3257 g_string_append (str
, map (code_type
, method_impl_map
));
3258 g_string_append (str
, map (managed_type
, managed_type_map
));
3259 g_string_append (str
, flags (rest
, managed_impl_flags
));
3262 g_string_free (str
, FALSE
);