5 * Dietmar Maurer (dietmar@ximian.com)
6 * Paolo Molaro (lupus@ximian.com)
7 * Patrik Torstensson (patrik.torstensson@labs2.com)
9 * (C) 2001 Ximian, Inc.
19 #if defined (PLATFORM_WIN32)
23 #include <mono/metadata/object.h>
24 #include <mono/metadata/threads.h>
25 #include <mono/metadata/threads-types.h>
26 #include <mono/metadata/threadpool.h>
27 #include <mono/metadata/monitor.h>
28 #include <mono/metadata/reflection.h>
29 #include <mono/metadata/assembly.h>
30 #include <mono/metadata/tabledefs.h>
31 #include <mono/metadata/exception.h>
32 #include <mono/metadata/file-io.h>
33 #include <mono/metadata/socket-io.h>
34 #include <mono/metadata/mono-endian.h>
35 #include <mono/metadata/tokentype.h>
36 #include <mono/metadata/unicode.h>
37 #include <mono/metadata/domain-internals.h>
38 #include <mono/metadata/metadata-internals.h>
39 #include <mono/metadata/class-internals.h>
40 #include <mono/metadata/marshal.h>
41 #include <mono/metadata/gc-internal.h>
42 #include <mono/metadata/rand.h>
43 #include <mono/metadata/sysmath.h>
44 #include <mono/metadata/string-icalls.h>
45 #include <mono/metadata/mono-debug-debugger.h>
46 #include <mono/metadata/process.h>
47 #include <mono/metadata/environment.h>
48 #include <mono/metadata/profiler-private.h>
49 #include <mono/metadata/locales.h>
50 #include <mono/metadata/filewatcher.h>
51 #include <mono/metadata/char-conversions.h>
52 #include <mono/metadata/security.h>
53 #include <mono/metadata/mono-config.h>
54 #include <mono/metadata/cil-coff.h>
55 #include <mono/io-layer/io-layer.h>
56 #include <mono/utils/strtod.h>
57 #include <mono/utils/monobitset.h>
59 #if defined (PLATFORM_WIN32)
65 static MonoReflectionAssembly
* ves_icall_System_Reflection_Assembly_GetCallingAssembly (void);
69 * We expect a pointer to a char, not a string
72 mono_double_ParseImpl (char *ptr
)
80 result
= bsd_strtod (ptr
, &endptr
);
82 if (!*ptr
|| (endptr
&& *endptr
))
83 mono_raise_exception (mono_exception_from_name (mono_defaults
.corlib
,
91 ves_icall_System_Double_AssertEndianity (double *value
)
95 MONO_DOUBLE_ASSERT_ENDIANITY (value
);
99 ves_icall_System_Array_GetValueImpl (MonoObject
*this, guint32 pos
)
108 ao
= (MonoArray
*)this;
109 ac
= (MonoClass
*)ao
->obj
.vtable
->klass
;
111 esize
= mono_array_element_size (ac
);
112 ea
= (gpointer
*)((char*)ao
->vector
+ (pos
* esize
));
114 if (ac
->element_class
->valuetype
)
115 return mono_value_box (this->vtable
->domain
, ac
->element_class
, ea
);
121 ves_icall_System_Array_GetValue (MonoObject
*this, MonoObject
*idxs
)
129 MONO_CHECK_ARG_NULL (idxs
);
131 io
= (MonoArray
*)idxs
;
132 ic
= (MonoClass
*)io
->obj
.vtable
->klass
;
134 ao
= (MonoArray
*)this;
135 ac
= (MonoClass
*)ao
->obj
.vtable
->klass
;
137 g_assert (ic
->rank
== 1);
138 if (io
->bounds
!= NULL
|| io
->max_length
!= ac
->rank
)
139 mono_raise_exception (mono_get_exception_argument (NULL
, NULL
));
141 ind
= (guint32
*)io
->vector
;
143 if (ao
->bounds
== NULL
) {
144 if (*ind
< 0 || *ind
>= ao
->max_length
)
145 mono_raise_exception (mono_get_exception_index_out_of_range ());
147 return ves_icall_System_Array_GetValueImpl (this, *ind
);
150 for (i
= 0; i
< ac
->rank
; i
++)
151 if ((ind
[i
] < ao
->bounds
[i
].lower_bound
) ||
152 (ind
[i
] >= ao
->bounds
[i
].length
+ ao
->bounds
[i
].lower_bound
))
153 mono_raise_exception (mono_get_exception_index_out_of_range ());
155 pos
= ind
[0] - ao
->bounds
[0].lower_bound
;
156 for (i
= 1; i
< ac
->rank
; i
++)
157 pos
= pos
*ao
->bounds
[i
].length
+ ind
[i
] -
158 ao
->bounds
[i
].lower_bound
;
160 return ves_icall_System_Array_GetValueImpl (this, pos
);
164 ves_icall_System_Array_SetValueImpl (MonoArray
*this, MonoObject
*value
, guint32 pos
)
166 MonoClass
*ac
, *vc
, *ec
;
177 vc
= value
->vtable
->klass
;
181 ac
= this->obj
.vtable
->klass
;
182 ec
= ac
->element_class
;
184 esize
= mono_array_element_size (ac
);
185 ea
= (gpointer
*)((char*)this->vector
+ (pos
* esize
));
186 va
= (gpointer
*)((char*)value
+ sizeof (MonoObject
));
189 memset (ea
, 0, esize
);
193 #define NO_WIDENING_CONVERSION G_STMT_START{\
194 mono_raise_exception (mono_get_exception_argument ( \
195 "value", "not a widening conversion")); \
198 #define CHECK_WIDENING_CONVERSION(extra) G_STMT_START{\
199 if (esize < vsize + (extra)) \
200 mono_raise_exception (mono_get_exception_argument ( \
201 "value", "not a widening conversion")); \
204 #define INVALID_CAST G_STMT_START{\
205 mono_raise_exception (mono_get_exception_invalid_cast ()); \
208 /* Check element (destination) type. */
209 switch (ec
->byval_arg
.type
) {
210 case MONO_TYPE_STRING
:
211 switch (vc
->byval_arg
.type
) {
212 case MONO_TYPE_STRING
:
218 case MONO_TYPE_BOOLEAN
:
219 switch (vc
->byval_arg
.type
) {
220 case MONO_TYPE_BOOLEAN
:
233 NO_WIDENING_CONVERSION
;
240 if (!ec
->valuetype
) {
241 if (!mono_object_isinst (value
, ec
))
243 *ea
= (gpointer
)value
;
247 if (mono_object_isinst (value
, ec
)) {
248 memcpy (ea
, (char *)value
+ sizeof (MonoObject
), esize
);
255 vsize
= mono_class_instance_size (vc
) - sizeof (MonoObject
);
257 #define ASSIGN_UNSIGNED(etype) G_STMT_START{\
258 switch (vc->byval_arg.type) { \
263 case MONO_TYPE_CHAR: \
264 CHECK_WIDENING_CONVERSION(0); \
265 *(etype *) ea = (etype) u64; \
267 /* You can't assign a signed value to an unsigned array. */ \
272 /* You can't assign a floating point number to an integer array. */ \
275 NO_WIDENING_CONVERSION; \
279 #define ASSIGN_SIGNED(etype) G_STMT_START{\
280 switch (vc->byval_arg.type) { \
285 CHECK_WIDENING_CONVERSION(0); \
286 *(etype *) ea = (etype) i64; \
288 /* You can assign an unsigned value to a signed array if the array's */ \
289 /* element size is larger than the value size. */ \
294 case MONO_TYPE_CHAR: \
295 CHECK_WIDENING_CONVERSION(1); \
296 *(etype *) ea = (etype) u64; \
298 /* You can't assign a floating point number to an integer array. */ \
301 NO_WIDENING_CONVERSION; \
305 #define ASSIGN_REAL(etype) G_STMT_START{\
306 switch (vc->byval_arg.type) { \
309 CHECK_WIDENING_CONVERSION(0); \
310 *(etype *) ea = (etype) r64; \
312 /* All integer values fit into a floating point array, so we don't */ \
313 /* need to CHECK_WIDENING_CONVERSION here. */ \
318 *(etype *) ea = (etype) i64; \
324 case MONO_TYPE_CHAR: \
325 *(etype *) ea = (etype) u64; \
330 switch (vc
->byval_arg
.type
) {
332 u64
= *(guint8
*) va
;
335 u64
= *(guint16
*) va
;
338 u64
= *(guint32
*) va
;
341 u64
= *(guint64
*) va
;
347 i64
= *(gint16
*) va
;
350 i64
= *(gint32
*) va
;
353 i64
= *(gint64
*) va
;
356 r64
= *(gfloat
*) va
;
359 r64
= *(gdouble
*) va
;
362 u64
= *(guint16
*) va
;
364 case MONO_TYPE_BOOLEAN
:
365 /* Boolean is only compatible with itself. */
366 switch (ec
->byval_arg
.type
) {
378 NO_WIDENING_CONVERSION
;
385 /* If we can't do a direct copy, let's try a widening conversion. */
386 switch (ec
->byval_arg
.type
) {
388 ASSIGN_UNSIGNED (guint16
);
390 ASSIGN_UNSIGNED (guint8
);
392 ASSIGN_UNSIGNED (guint16
);
394 ASSIGN_UNSIGNED (guint32
);
396 ASSIGN_UNSIGNED (guint64
);
398 ASSIGN_SIGNED (gint8
);
400 ASSIGN_SIGNED (gint16
);
402 ASSIGN_SIGNED (gint32
);
404 ASSIGN_SIGNED (gint64
);
406 ASSIGN_REAL (gfloat
);
408 ASSIGN_REAL (gdouble
);
412 /* Not reached, INVALID_CAST does not return. Just to avoid a compiler warning ... */
416 #undef NO_WIDENING_CONVERSION
417 #undef CHECK_WIDENING_CONVERSION
418 #undef ASSIGN_UNSIGNED
424 ves_icall_System_Array_SetValue (MonoArray
*this, MonoObject
*value
,
432 MONO_CHECK_ARG_NULL (idxs
);
434 ic
= idxs
->obj
.vtable
->klass
;
435 ac
= this->obj
.vtable
->klass
;
437 g_assert (ic
->rank
== 1);
438 if (idxs
->bounds
!= NULL
|| idxs
->max_length
!= ac
->rank
)
439 mono_raise_exception (mono_get_exception_argument (NULL
, NULL
));
441 ind
= (guint32
*)idxs
->vector
;
443 if (this->bounds
== NULL
) {
444 if (*ind
< 0 || *ind
>= this->max_length
)
445 mono_raise_exception (mono_get_exception_index_out_of_range ());
447 ves_icall_System_Array_SetValueImpl (this, value
, *ind
);
451 for (i
= 0; i
< ac
->rank
; i
++)
452 if ((ind
[i
] < this->bounds
[i
].lower_bound
) ||
453 (ind
[i
] >= this->bounds
[i
].length
+ this->bounds
[i
].lower_bound
))
454 mono_raise_exception (mono_get_exception_index_out_of_range ());
456 pos
= ind
[0] - this->bounds
[0].lower_bound
;
457 for (i
= 1; i
< ac
->rank
; i
++)
458 pos
= pos
* this->bounds
[i
].length
+ ind
[i
] -
459 this->bounds
[i
].lower_bound
;
461 ves_icall_System_Array_SetValueImpl (this, value
, pos
);
465 ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType
*type
, MonoArray
*lengths
, MonoArray
*bounds
)
470 gboolean bounded
= FALSE
;
474 MONO_CHECK_ARG_NULL (type
);
475 MONO_CHECK_ARG_NULL (lengths
);
477 MONO_CHECK_ARG (lengths
, mono_array_length (lengths
) > 0);
479 MONO_CHECK_ARG (bounds
, mono_array_length (lengths
) == mono_array_length (bounds
));
481 for (i
= 0; i
< mono_array_length (lengths
); i
++)
482 if (mono_array_get (lengths
, gint32
, i
) < 0)
483 mono_raise_exception (mono_get_exception_argument_out_of_range (NULL
));
485 if (bounds
&& (mono_array_length (bounds
) == 1) && (mono_array_get (bounds
, gint32
, 0) != 0))
486 /* vectors are not the same as one dimensional arrays with no-zero bounds */
491 aklass
= mono_bounded_array_class_get (mono_class_from_mono_type (type
->type
), mono_array_length (lengths
), bounded
);
493 sizes
= alloca (aklass
->rank
* sizeof(guint32
) * 2);
494 for (i
= 0; i
< aklass
->rank
; ++i
) {
495 sizes
[i
] = mono_array_get (lengths
, gint32
, i
);
497 sizes
[i
+ aklass
->rank
] = mono_array_get (bounds
, gint32
, i
);
499 sizes
[i
+ aklass
->rank
] = 0;
502 array
= mono_array_new_full (mono_object_domain (type
), aklass
, sizes
, sizes
+ aklass
->rank
);
508 ves_icall_System_Array_GetRank (MonoObject
*this)
512 return this->vtable
->klass
->rank
;
516 ves_icall_System_Array_GetLength (MonoArray
*this, gint32 dimension
)
518 gint32 rank
= ((MonoObject
*)this)->vtable
->klass
->rank
;
522 if ((dimension
< 0) || (dimension
>= rank
))
523 mono_raise_exception (mono_get_exception_index_out_of_range ());
525 if (this->bounds
== NULL
)
526 return this->max_length
;
528 return this->bounds
[dimension
].length
;
532 ves_icall_System_Array_GetLowerBound (MonoArray
*this, gint32 dimension
)
534 gint32 rank
= ((MonoObject
*)this)->vtable
->klass
->rank
;
538 if ((dimension
< 0) || (dimension
>= rank
))
539 mono_raise_exception (mono_get_exception_index_out_of_range ());
541 if (this->bounds
== NULL
)
544 return this->bounds
[dimension
].lower_bound
;
548 ves_icall_System_Array_ClearInternal (MonoArray
*arr
, int idx
, int length
)
550 int sz
= mono_array_element_size (mono_object_class (arr
));
551 memset (mono_array_addr_with_size (arr
, idx
, sz
), 0, length
* sz
);
555 ves_icall_System_Array_FastCopy (MonoArray
*source
, int source_idx
, MonoArray
* dest
, int dest_idx
, int length
)
560 MonoClass
*src_class
;
561 MonoClass
*dest_class
;
566 if (source
->obj
.vtable
->klass
->rank
!= dest
->obj
.vtable
->klass
->rank
)
569 if (source
->bounds
|| dest
->bounds
)
572 if ((dest_idx
+ length
> mono_array_length (dest
)) ||
573 (source_idx
+ length
> mono_array_length (source
)))
576 element_size
= mono_array_element_size (source
->obj
.vtable
->klass
);
577 dest_addr
= mono_array_addr_with_size (dest
, element_size
, dest_idx
);
578 source_addr
= mono_array_addr_with_size (source
, element_size
, source_idx
);
580 src_class
= source
->obj
.vtable
->klass
->element_class
;
581 dest_class
= dest
->obj
.vtable
->klass
->element_class
;
584 * Handle common cases.
587 /* Case1: object[] -> valuetype[] (ArrayList::ToArray) */
588 if (src_class
== mono_defaults
.object_class
&& dest_class
->valuetype
) {
589 for (i
= source_idx
; i
< source_idx
+ length
; ++i
) {
590 MonoObject
*elem
= mono_array_get (source
, MonoObject
*, i
);
591 if (elem
&& !mono_object_isinst (elem
, dest_class
))
595 element_size
= mono_array_element_size (dest
->obj
.vtable
->klass
);
596 for (i
= 0; i
< length
; ++i
) {
597 MonoObject
*elem
= mono_array_get (source
, MonoObject
*, source_idx
+ i
);
598 void *addr
= mono_array_addr_with_size (dest
, element_size
, dest_idx
+ i
);
600 memset (addr
, 0, element_size
);
602 memcpy (addr
, (char *)elem
+ sizeof (MonoObject
), element_size
);
607 if (src_class
!= dest_class
) {
608 if (dest_class
->valuetype
|| dest_class
->enumtype
|| src_class
->valuetype
|| src_class
->enumtype
)
611 if (mono_class_is_subclass_of (src_class
, dest_class
, FALSE
))
613 /* Case2: object[] -> reftype[] (ArrayList::ToArray) */
614 else if (mono_class_is_subclass_of (dest_class
, src_class
, FALSE
))
615 for (i
= source_idx
; i
< source_idx
+ length
; ++i
) {
616 MonoObject
*elem
= mono_array_get (source
, MonoObject
*, i
);
617 if (elem
&& !mono_object_isinst (elem
, dest_class
))
624 memmove (dest_addr
, source_addr
, element_size
* length
);
630 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoArray
*array
, MonoClassField
*field_handle
)
632 MonoClass
*klass
= array
->obj
.vtable
->klass
;
633 guint32 size
= mono_array_element_size (klass
);
638 if (array
->bounds
== NULL
)
639 size
*= array
->max_length
;
641 for (i
= 0; i
< klass
->rank
; ++i
)
642 size
*= array
->bounds
[i
].length
;
644 memcpy (mono_array_addr (array
, char, 0), field_handle
->data
, size
);
646 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
650 guint ## n *data = (guint ## n *) mono_array_addr (array, char, 0); \
652 for (i = 0; i < size; i += n/8, data++) { \
653 tmp = read ## n (data); \
658 /* printf ("Initialize array with elements of %s type\n", klass->element_class->name); */
660 switch (klass
->element_class
->byval_arg
.type
) {
680 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData (void)
684 return offsetof (MonoString
, chars
);
688 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObject
*obj
)
692 if ((obj
== NULL
) || (! (obj
->vtable
->klass
->valuetype
)))
695 return mono_object_clone (obj
);
699 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (MonoType
*handle
)
705 MONO_CHECK_ARG_NULL (handle
);
707 klass
= mono_class_from_mono_type (handle
);
708 MONO_CHECK_ARG (handle
, klass
);
710 /* This will call the type constructor */
711 if (! (klass
->flags
& TYPE_ATTRIBUTE_INTERFACE
))
712 mono_runtime_class_init (mono_class_vtable (mono_domain_get (), klass
));
716 ves_icall_System_Object_MemberwiseClone (MonoObject
*this)
720 return mono_object_clone (this);
724 #define MONO_OBJECT_ALIGNMENT_SHIFT 3
726 #define MONO_OBJECT_ALIGNMENT_SHIFT 2
730 * Return hashcode based on object address. This function will need to be
731 * smarter in the presence of a moving garbage collector, which will cache
732 * the address hash before relocating the object.
734 * Wang's address-based hash function:
735 * http://www.concentric.net/~Ttwang/tech/addrhash.htm
738 ves_icall_System_Object_GetHashCode (MonoObject
*this)
740 register guint32 key
;
744 key
= (GPOINTER_TO_UINT (this) >> MONO_OBJECT_ALIGNMENT_SHIFT
) * 2654435761u;
746 return key
& 0x7fffffff;
750 ves_icall_System_ValueType_InternalGetHashCode (MonoObject
*this, MonoArray
**fields
)
754 MonoObject
**values
= NULL
;
761 klass
= this->vtable
->klass
;
763 if (klass
->field
.count
== 0)
764 return ves_icall_System_Object_GetHashCode (this);
767 * Compute the starting value of the hashcode for fields of primitive
768 * types, and return the remaining fields in an array to the managed side.
769 * This way, we can avoid costly reflection operations in managed code.
771 for (i
= 0; i
< klass
->field
.count
; ++i
) {
772 MonoClassField
*field
= &klass
->fields
[i
];
773 if (field
->type
->attrs
& FIELD_ATTRIBUTE_STATIC
)
775 if (mono_field_is_deleted (field
))
777 /* FIXME: Add more types */
778 switch (field
->type
->type
) {
780 result
^= *(gint32
*)((guint8
*)this + field
->offset
);
782 case MONO_TYPE_STRING
: {
784 s
= *(MonoString
**)((guint8
*)this + field
->offset
);
786 result
^= ves_icall_System_String_GetHashCode (s
);
791 values
= alloca (klass
->field
.count
* sizeof (MonoObject
*));
792 o
= mono_field_get_value_object (mono_object_domain (this), field
, this);
793 values
[count
++] = o
;
798 *fields
= mono_array_new (mono_domain_get (), mono_defaults
.object_class
, count
);
799 memcpy (mono_array_addr (*fields
, MonoObject
*, 0), values
, count
* sizeof (MonoObject
*));
807 ves_icall_System_ValueType_Equals (MonoObject
*this, MonoObject
*that
, MonoArray
**fields
)
811 MonoObject
**values
= NULL
;
817 MONO_CHECK_ARG_NULL (that
);
819 if (this->vtable
!= that
->vtable
)
822 klass
= this->vtable
->klass
;
825 * Do the comparison for fields of primitive type and return a result if
826 * possible. Otherwise, return the remaining fields in an array to the
827 * managed side. This way, we can avoid costly reflection operations in
831 for (i
= 0; i
< klass
->field
.count
; ++i
) {
832 MonoClassField
*field
= &klass
->fields
[i
];
833 if (field
->type
->attrs
& FIELD_ATTRIBUTE_STATIC
)
835 if (mono_field_is_deleted (field
))
837 /* FIXME: Add more types */
838 switch (field
->type
->type
) {
840 if (*(gint32
*)((guint8
*)this + field
->offset
) != *(gint32
*)((guint8
*)that
+ field
->offset
))
843 case MONO_TYPE_STRING
: {
845 guint32 s1len
, s2len
;
846 s1
= *(MonoString
**)((guint8
*)this + field
->offset
);
847 s2
= *(MonoString
**)((guint8
*)that
+ field
->offset
);
850 if ((s1
== NULL
) || (s2
== NULL
))
852 s1len
= mono_string_length (s1
);
853 s2len
= mono_string_length (s2
);
857 if (memcmp (mono_string_chars (s1
), mono_string_chars (s2
), s1len
* sizeof (gunichar2
)) != 0)
863 values
= alloca (klass
->field
.count
* 2 * sizeof (MonoObject
*));
864 o
= mono_field_get_value_object (mono_object_domain (this), field
, this);
865 values
[count
++] = o
;
866 o
= mono_field_get_value_object (mono_object_domain (this), field
, that
);
867 values
[count
++] = o
;
872 *fields
= mono_array_new (mono_domain_get (), mono_defaults
.object_class
, count
);
873 memcpy (mono_array_addr (*fields
, MonoObject
*, 0), values
, count
* sizeof (MonoObject
*));
881 static MonoReflectionType
*
882 ves_icall_System_Object_GetType (MonoObject
*obj
)
886 if (obj
->vtable
->klass
!= mono_defaults
.transparent_proxy_class
)
887 return mono_type_get_object (mono_object_domain (obj
), &obj
->vtable
->klass
->byval_arg
);
889 return mono_type_get_object (mono_object_domain (obj
), &((MonoTransparentProxy
*)obj
)->remote_class
->proxy_class
->byval_arg
);
893 mono_type_type_from_obj (MonoReflectionType
*mtype
, MonoObject
*obj
)
897 mtype
->type
= &obj
->vtable
->klass
->byval_arg
;
898 g_assert (mtype
->type
->type
);
902 ves_icall_ModuleBuilder_getToken (MonoReflectionModuleBuilder
*mb
, MonoObject
*obj
)
906 MONO_CHECK_ARG_NULL (obj
);
908 return mono_image_create_token (mb
->dynamic_image
, obj
, TRUE
);
912 ves_icall_ModuleBuilder_getMethodToken (MonoReflectionModuleBuilder
*mb
,
913 MonoReflectionMethod
*method
,
914 MonoArray
*opt_param_types
)
918 MONO_CHECK_ARG_NULL (method
);
920 return mono_image_create_method_token (
921 mb
->dynamic_image
, (MonoObject
*) method
, opt_param_types
);
925 ves_icall_ModuleBuilder_WriteToFile (MonoReflectionModuleBuilder
*mb
, HANDLE file
)
929 mono_image_create_pefile (mb
, file
);
933 ves_icall_ModuleBuilder_build_metadata (MonoReflectionModuleBuilder
*mb
)
937 mono_image_build_metadata (mb
);
940 static MonoReflectionType
*
941 type_from_name (const char *str
, MonoBoolean ignoreCase
)
943 MonoType
*type
= NULL
;
944 MonoAssembly
*assembly
;
945 MonoTypeNameParse info
;
946 char *temp_str
= g_strdup (str
);
947 gboolean type_resolve
= FALSE
;
951 /* mono_reflection_parse_type() mangles the string */
952 if (!mono_reflection_parse_type (temp_str
, &info
)) {
953 g_list_free (info
.modifiers
);
954 g_list_free (info
.nested
);
959 if (info
.assembly
.name
) {
960 assembly
= mono_assembly_load (&info
.assembly
, NULL
, NULL
);
962 MonoReflectionAssembly
*refass
;
964 refass
= ves_icall_System_Reflection_Assembly_GetCallingAssembly ();
965 assembly
= refass
->assembly
;
969 type
= mono_reflection_get_type (assembly
->image
, &info
, ignoreCase
, &type_resolve
);
971 if (!info
.assembly
.name
&& !type
) /* try mscorlib */
972 type
= mono_reflection_get_type (NULL
, &info
, ignoreCase
, &type_resolve
);
974 g_list_free (info
.modifiers
);
975 g_list_free (info
.nested
);
981 return mono_type_get_object (mono_domain_get (), type
);
986 mono_type_get (const char *str
)
988 char *copy
= g_strdup (str
);
989 MonoReflectionType
*type
= type_from_name (copy
, FALSE
);
996 static MonoReflectionType
*
997 ves_icall_type_from_name (MonoString
*name
,
998 MonoBoolean throwOnError
,
999 MonoBoolean ignoreCase
)
1001 char *str
= mono_string_to_utf8 (name
);
1002 MonoReflectionType
*type
;
1004 type
= type_from_name (str
, ignoreCase
);
1008 mono_raise_exception (mono_get_exception_type_load (name
));
1015 static MonoReflectionType
*
1016 ves_icall_type_from_handle (MonoType
*handle
)
1018 MonoDomain
*domain
= mono_domain_get ();
1019 MonoClass
*klass
= mono_class_from_mono_type (handle
);
1021 MONO_ARCH_SAVE_REGS
;
1023 mono_class_init (klass
);
1024 return mono_type_get_object (domain
, handle
);
1028 ves_icall_type_Equals (MonoReflectionType
*type
, MonoReflectionType
*c
)
1030 MONO_ARCH_SAVE_REGS
;
1032 if (type
->type
&& c
->type
)
1033 return mono_metadata_type_equal (type
->type
, c
->type
);
1034 g_print ("type equals\n");
1038 /* System.TypeCode */
1057 TYPECODE_STRING
= 18
1061 ves_icall_type_GetTypeCode (MonoReflectionType
*type
)
1063 int t
= type
->type
->type
;
1065 MONO_ARCH_SAVE_REGS
;
1067 if (type
->type
->byref
)
1068 return TYPECODE_OBJECT
;
1072 case MONO_TYPE_VOID
:
1073 return TYPECODE_OBJECT
;
1074 case MONO_TYPE_BOOLEAN
:
1075 return TYPECODE_BOOLEAN
;
1077 return TYPECODE_BYTE
;
1079 return TYPECODE_SBYTE
;
1081 return TYPECODE_UINT16
;
1083 return TYPECODE_INT16
;
1084 case MONO_TYPE_CHAR
:
1085 return TYPECODE_CHAR
;
1089 return TYPECODE_OBJECT
;
1091 return TYPECODE_UINT32
;
1093 return TYPECODE_INT32
;
1095 return TYPECODE_UINT64
;
1097 return TYPECODE_INT64
;
1099 return TYPECODE_SINGLE
;
1101 return TYPECODE_DOUBLE
;
1102 case MONO_TYPE_VALUETYPE
:
1103 if (type
->type
->data
.klass
->enumtype
) {
1104 t
= type
->type
->data
.klass
->enum_basetype
->type
;
1107 MonoClass
*k
= type
->type
->data
.klass
;
1108 if (strcmp (k
->name_space
, "System") == 0) {
1109 if (strcmp (k
->name
, "Decimal") == 0)
1110 return TYPECODE_DECIMAL
;
1111 else if (strcmp (k
->name
, "DateTime") == 0)
1112 return TYPECODE_DATETIME
;
1115 return TYPECODE_OBJECT
;
1116 case MONO_TYPE_STRING
:
1117 return TYPECODE_STRING
;
1118 case MONO_TYPE_SZARRAY
:
1119 case MONO_TYPE_ARRAY
:
1120 case MONO_TYPE_OBJECT
:
1122 case MONO_TYPE_MVAR
:
1123 return TYPECODE_OBJECT
;
1124 case MONO_TYPE_CLASS
:
1126 MonoClass
*k
= type
->type
->data
.klass
;
1127 if (strcmp (k
->name_space
, "System") == 0) {
1128 if (strcmp (k
->name
, "DBNull") == 0)
1129 return TYPECODE_DBNULL
;
1132 return TYPECODE_OBJECT
;
1133 case MONO_TYPE_GENERICINST
:
1134 return TYPECODE_OBJECT
;
1136 g_error ("type 0x%02x not handled in GetTypeCode()", t
);
1142 ves_icall_type_is_subtype_of (MonoReflectionType
*type
, MonoReflectionType
*c
, MonoBoolean check_interfaces
)
1148 MONO_ARCH_SAVE_REGS
;
1150 g_assert (type
!= NULL
);
1152 domain
= ((MonoObject
*)type
)->vtable
->domain
;
1154 if (!c
) /* FIXME: dont know what do do here */
1157 klass
= mono_class_from_mono_type (type
->type
);
1158 klassc
= mono_class_from_mono_type (c
->type
);
1160 if (type
->type
->byref
)
1161 return klassc
== mono_defaults
.object_class
;
1163 return mono_class_is_subclass_of (klass
, klassc
, check_interfaces
);
1167 ves_icall_type_is_assignable_from (MonoReflectionType
*type
, MonoReflectionType
*c
)
1173 MONO_ARCH_SAVE_REGS
;
1175 g_assert (type
!= NULL
);
1177 domain
= ((MonoObject
*)type
)->vtable
->domain
;
1179 klass
= mono_class_from_mono_type (type
->type
);
1180 klassc
= mono_class_from_mono_type (c
->type
);
1182 if (type
->type
->byref
&& !c
->type
->byref
)
1185 return mono_class_is_assignable_from (klass
, klassc
);
1189 ves_icall_type_IsInstanceOfType (MonoReflectionType
*type
, MonoObject
*obj
)
1191 MonoClass
*klass
= mono_class_from_mono_type (type
->type
);
1192 return mono_object_isinst (obj
, klass
) != NULL
;
1196 ves_icall_get_attributes (MonoReflectionType
*type
)
1198 MonoClass
*klass
= mono_class_from_mono_type (type
->type
);
1200 MONO_ARCH_SAVE_REGS
;
1202 return klass
->flags
;
1205 static MonoReflectionMarshal
*
1206 ves_icall_System_Reflection_FieldInfo_GetUnmanagedMarshal (MonoReflectionField
*field
)
1208 MonoClass
*klass
= field
->field
->parent
;
1209 MonoMarshalType
*info
;
1212 if (klass
->generic_container
||
1213 (klass
->generic_class
&& klass
->generic_class
->inst
->is_open
))
1216 info
= mono_marshal_load_type_info (klass
);
1218 for (i
= 0; i
< info
->num_fields
; ++i
) {
1219 if (info
->fields
[i
].field
== field
->field
) {
1220 if (!info
->fields
[i
].mspec
)
1223 return mono_reflection_marshal_from_marshal_spec (field
->object
.vtable
->domain
, klass
, info
->fields
[i
].mspec
);
1230 static MonoReflectionField
*
1231 ves_icall_System_Reflection_FieldInfo_internal_from_handle (MonoClassField
*handle
)
1233 MONO_ARCH_SAVE_REGS
;
1237 return mono_field_get_object (mono_domain_get (), handle
->parent
, handle
);
1241 ves_icall_get_method_info (MonoMethod
*method
, MonoMethodInfo
*info
)
1243 MonoDomain
*domain
= mono_domain_get ();
1245 MONO_ARCH_SAVE_REGS
;
1247 info
->parent
= mono_type_get_object (domain
, &method
->klass
->byval_arg
);
1248 info
->ret
= mono_type_get_object (domain
, method
->signature
->ret
);
1249 info
->attrs
= method
->flags
;
1250 info
->implattrs
= method
->iflags
;
1251 if (method
->signature
->call_convention
== MONO_CALL_DEFAULT
)
1254 if (method
->signature
->call_convention
== MONO_CALL_VARARG
)
1259 info
->callconv
|= (method
->signature
->hasthis
<< 5) | (method
->signature
->explicit_this
<< 6);
1263 ves_icall_get_parameter_info (MonoMethod
*method
)
1265 MonoDomain
*domain
= mono_domain_get ();
1267 MONO_ARCH_SAVE_REGS
;
1269 return mono_param_get_objects (domain
, method
);
1273 ves_icall_MonoField_GetFieldOffset (MonoReflectionField
*field
)
1275 return field
->field
->offset
- sizeof (MonoObject
);
1278 static MonoReflectionType
*
1279 ves_icall_MonoField_GetParentType (MonoReflectionField
*field
, MonoBoolean declaring
)
1282 MONO_ARCH_SAVE_REGS
;
1284 parent
= declaring
? field
->field
->parent
: field
->klass
;
1286 return mono_type_get_object (mono_object_domain (field
), &parent
->byval_arg
);
1290 ves_icall_MonoField_GetValueInternal (MonoReflectionField
*field
, MonoObject
*obj
)
1293 MonoClassField
*cf
= field
->field
;
1296 MonoDomain
*domain
= mono_object_domain (field
);
1298 gboolean is_static
= FALSE
;
1299 gboolean is_ref
= FALSE
;
1301 MONO_ARCH_SAVE_REGS
;
1303 mono_class_init (field
->klass
);
1305 switch (cf
->type
->type
) {
1306 case MONO_TYPE_STRING
:
1307 case MONO_TYPE_OBJECT
:
1308 case MONO_TYPE_CLASS
:
1309 case MONO_TYPE_ARRAY
:
1310 case MONO_TYPE_SZARRAY
:
1315 case MONO_TYPE_BOOLEAN
:
1318 case MONO_TYPE_CHAR
:
1327 case MONO_TYPE_VALUETYPE
:
1328 is_ref
= cf
->type
->byref
;
1331 g_error ("type 0x%x not handled in "
1332 "ves_icall_Monofield_GetValue", cf
->type
->type
);
1337 if (cf
->type
->attrs
& FIELD_ATTRIBUTE_STATIC
) {
1339 vtable
= mono_class_vtable (domain
, field
->klass
);
1340 if (!vtable
->initialized
&& !(cf
->type
->attrs
& FIELD_ATTRIBUTE_LITERAL
))
1341 mono_runtime_class_init (vtable
);
1346 mono_field_static_get_value (vtable
, cf
, &o
);
1348 mono_field_get_value (obj
, cf
, &o
);
1353 /* boxed value type */
1354 klass
= mono_class_from_mono_type (cf
->type
);
1355 o
= mono_object_new (domain
, klass
);
1356 v
= ((gchar
*) o
) + sizeof (MonoObject
);
1358 mono_field_static_get_value (vtable
, cf
, v
);
1360 mono_field_get_value (obj
, cf
, v
);
1367 ves_icall_FieldInfo_SetValueInternal (MonoReflectionField
*field
, MonoObject
*obj
, MonoObject
*value
)
1369 MonoClassField
*cf
= field
->field
;
1372 MONO_ARCH_SAVE_REGS
;
1374 v
= (gchar
*) value
;
1375 if (!cf
->type
->byref
) {
1376 switch (cf
->type
->type
) {
1379 case MONO_TYPE_BOOLEAN
:
1382 case MONO_TYPE_CHAR
:
1391 case MONO_TYPE_VALUETYPE
:
1392 v
+= sizeof (MonoObject
);
1394 case MONO_TYPE_STRING
:
1395 case MONO_TYPE_OBJECT
:
1396 case MONO_TYPE_CLASS
:
1397 case MONO_TYPE_ARRAY
:
1398 case MONO_TYPE_SZARRAY
:
1402 g_error ("type 0x%x not handled in "
1403 "ves_icall_FieldInfo_SetValueInternal", cf
->type
->type
);
1408 if (cf
->type
->attrs
& FIELD_ATTRIBUTE_STATIC
) {
1409 MonoVTable
*vtable
= mono_class_vtable (mono_object_domain (field
), field
->klass
);
1410 if (!vtable
->initialized
)
1411 mono_runtime_class_init (vtable
);
1412 mono_field_static_set_value (vtable
, cf
, v
);
1414 mono_field_set_value (obj
, cf
, v
);
1418 static MonoReflectionField
*
1419 ves_icall_MonoField_Mono_GetGenericFieldDefinition (MonoReflectionField
*field
)
1421 MONO_ARCH_SAVE_REGS
;
1423 if (field
->field
->generic_info
&& field
->field
->generic_info
->reflection_info
)
1424 return field
->field
->generic_info
->reflection_info
;
1429 /* From MonoProperty.cs */
1431 PInfo_Attributes
= 1,
1432 PInfo_GetMethod
= 1 << 1,
1433 PInfo_SetMethod
= 1 << 2,
1434 PInfo_ReflectedType
= 1 << 3,
1435 PInfo_DeclaringType
= 1 << 4,
1440 ves_icall_get_property_info (MonoReflectionProperty
*property
, MonoPropertyInfo
*info
, PInfo req_info
)
1442 MonoDomain
*domain
= mono_object_domain (property
);
1444 MONO_ARCH_SAVE_REGS
;
1446 if ((req_info
& PInfo_ReflectedType
) != 0)
1447 info
->parent
= mono_type_get_object (domain
, &property
->klass
->byval_arg
);
1448 else if ((req_info
& PInfo_DeclaringType
) != 0)
1449 info
->parent
= mono_type_get_object (domain
, &property
->property
->parent
->byval_arg
);
1451 if ((req_info
& PInfo_Name
) != 0)
1452 info
->name
= mono_string_new (domain
, property
->property
->name
);
1454 if ((req_info
& PInfo_Attributes
) != 0)
1455 info
->attrs
= property
->property
->attrs
;
1457 if ((req_info
& PInfo_GetMethod
) != 0)
1458 info
->get
= property
->property
->get
?
1459 mono_method_get_object (domain
, property
->property
->get
, NULL
): NULL
;
1461 if ((req_info
& PInfo_SetMethod
) != 0)
1462 info
->set
= property
->property
->set
?
1463 mono_method_get_object (domain
, property
->property
->set
, NULL
): NULL
;
1465 * There may be other methods defined for properties, though, it seems they are not exposed
1466 * in the reflection API
1471 ves_icall_get_event_info (MonoReflectionEvent
*event
, MonoEventInfo
*info
)
1473 MonoDomain
*domain
= mono_object_domain (event
);
1475 MONO_ARCH_SAVE_REGS
;
1477 info
->declaring_type
= mono_type_get_object (domain
, &event
->klass
->byval_arg
);
1478 info
->reflected_type
= mono_type_get_object (domain
, &event
->event
->parent
->byval_arg
);
1480 info
->name
= mono_string_new (domain
, event
->event
->name
);
1481 info
->attrs
= event
->event
->attrs
;
1482 info
->add_method
= event
->event
->add
? mono_method_get_object (domain
, event
->event
->add
, NULL
): NULL
;
1483 info
->remove_method
= event
->event
->remove
? mono_method_get_object (domain
, event
->event
->remove
, NULL
): NULL
;
1484 info
->raise_method
= event
->event
->raise
? mono_method_get_object (domain
, event
->event
->raise
, NULL
): NULL
;
1486 if (event
->event
->other
) {
1488 while (event
->event
->other
[n
])
1490 info
->other_methods
= mono_array_new (domain
, mono_defaults
.method_info_class
, n
);
1492 for (i
= 0; i
< n
; i
++)
1493 mono_array_set (info
->other_methods
, gpointer
, i
,
1494 mono_method_get_object (domain
, event
->event
->other
[i
], NULL
));
1499 ves_icall_Type_GetInterfaces (MonoReflectionType
* type
)
1501 MonoDomain
*domain
= mono_object_domain (type
);
1503 GPtrArray
*ifaces
= NULL
;
1505 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1507 MonoBitSet
*slots
= mono_bitset_new (class->max_interface_id
+ 1, 0);
1509 MONO_ARCH_SAVE_REGS
;
1512 /* GetInterfaces() returns an empty array in MS.NET (this may be a bug) */
1513 mono_bitset_free (slots
);
1514 return mono_array_new (domain
, mono_defaults
.monotype_class
, 0);
1517 for (parent
= class; parent
; parent
= parent
->parent
) {
1518 GPtrArray
*tmp_ifaces
= mono_class_get_implemented_interfaces (parent
);
1520 for (i
= 0; i
< tmp_ifaces
->len
; ++i
) {
1521 MonoClass
*ic
= g_ptr_array_index (tmp_ifaces
, i
);
1523 if (mono_bitset_test (slots
, ic
->interface_id
))
1526 mono_bitset_set (slots
, ic
->interface_id
);
1528 ifaces
= g_ptr_array_new ();
1529 g_ptr_array_add (ifaces
, ic
);
1531 g_ptr_array_free (tmp_ifaces
, TRUE
);
1534 mono_bitset_free (slots
);
1537 return mono_array_new (domain
, mono_defaults
.monotype_class
, 0);
1539 intf
= mono_array_new (domain
, mono_defaults
.monotype_class
, ifaces
->len
);
1540 for (i
= 0; i
< ifaces
->len
; ++i
) {
1541 MonoClass
*ic
= g_ptr_array_index (ifaces
, i
);
1543 mono_array_set (intf
, gpointer
, i
,
1544 mono_type_get_object (domain
, &ic
->byval_arg
));
1546 g_ptr_array_free (ifaces
, TRUE
);
1552 ves_icall_Type_GetInterfaceMapData (MonoReflectionType
*type
, MonoReflectionType
*iface
, MonoArray
**targets
, MonoArray
**methods
)
1554 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1555 MonoClass
*iclass
= mono_class_from_mono_type (iface
->type
);
1556 MonoReflectionMethod
*member
;
1557 int i
, len
, ioffset
;
1560 MONO_ARCH_SAVE_REGS
;
1562 /* type doesn't implement iface: the exception is thrown in managed code */
1563 if ((iclass
->interface_id
> class->max_interface_id
) || !class->interface_offsets
[iclass
->interface_id
])
1566 len
= iclass
->method
.count
;
1567 ioffset
= class->interface_offsets
[iclass
->interface_id
];
1568 domain
= mono_object_domain (type
);
1569 *targets
= mono_array_new (domain
, mono_defaults
.method_info_class
, len
);
1570 *methods
= mono_array_new (domain
, mono_defaults
.method_info_class
, len
);
1571 for (i
= 0; i
< len
; ++i
) {
1572 member
= mono_method_get_object (domain
, iclass
->methods
[i
], iclass
);
1573 mono_array_set (*methods
, gpointer
, i
, member
);
1574 member
= mono_method_get_object (domain
, class->vtable
[i
+ ioffset
], class);
1575 mono_array_set (*targets
, gpointer
, i
, member
);
1580 ves_icall_Type_GetPacking (MonoReflectionType
*type
, guint32
*packing
, guint32
*size
)
1582 MonoClass
*klass
= mono_class_from_mono_type (type
->type
);
1584 g_assert (!klass
->image
->dynamic
);
1586 mono_metadata_packing_from_typedef (klass
->image
, klass
->type_token
, packing
, size
);
1589 static MonoReflectionType
*
1590 ves_icall_MonoType_GetElementType (MonoReflectionType
*type
)
1592 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1594 MONO_ARCH_SAVE_REGS
;
1596 // GelElementType should only return a type for:
1597 // Array Pointer PassedByRef
1598 if (type
->type
->byref
)
1599 return mono_type_get_object (mono_object_domain (type
), &class->byval_arg
);
1600 if (class->enumtype
&& class->enum_basetype
) /* types that are modifierd typebuilkders may not have enum_basetype set */
1601 return mono_type_get_object (mono_object_domain (type
), class->enum_basetype
);
1602 else if (class->element_class
&& MONO_CLASS_IS_ARRAY (class))
1603 return mono_type_get_object (mono_object_domain (type
), &class->element_class
->byval_arg
);
1604 else if (class->element_class
&& type
->type
->type
== MONO_TYPE_PTR
)
1605 return mono_type_get_object (mono_object_domain (type
), &class->element_class
->byval_arg
);
1610 static MonoReflectionType
*
1611 ves_icall_get_type_parent (MonoReflectionType
*type
)
1613 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1615 MONO_ARCH_SAVE_REGS
;
1617 return class->parent
? mono_type_get_object (mono_object_domain (type
), &class->parent
->byval_arg
): NULL
;
1621 ves_icall_type_ispointer (MonoReflectionType
*type
)
1623 MONO_ARCH_SAVE_REGS
;
1625 return type
->type
->type
== MONO_TYPE_PTR
;
1629 ves_icall_type_isprimitive (MonoReflectionType
*type
)
1631 MONO_ARCH_SAVE_REGS
;
1633 return (!type
->type
->byref
&& (((type
->type
->type
>= MONO_TYPE_BOOLEAN
) && (type
->type
->type
<= MONO_TYPE_R8
)) || (type
->type
->type
== MONO_TYPE_I
) || (type
->type
->type
== MONO_TYPE_U
)));
1637 ves_icall_type_isbyref (MonoReflectionType
*type
)
1639 MONO_ARCH_SAVE_REGS
;
1641 return type
->type
->byref
;
1644 static MonoReflectionModule
*
1645 ves_icall_MonoType_get_Module (MonoReflectionType
*type
)
1647 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1649 MONO_ARCH_SAVE_REGS
;
1651 return mono_module_get_object (mono_object_domain (type
), class->image
);
1654 static MonoReflectionAssembly
*
1655 ves_icall_MonoType_get_Assembly (MonoReflectionType
*type
)
1657 MonoDomain
*domain
= mono_domain_get ();
1658 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1660 MONO_ARCH_SAVE_REGS
;
1662 return mono_assembly_get_object (domain
, class->image
->assembly
);
1665 static MonoReflectionType
*
1666 ves_icall_MonoType_get_DeclaringType (MonoReflectionType
*type
)
1668 MonoDomain
*domain
= mono_domain_get ();
1669 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1671 MONO_ARCH_SAVE_REGS
;
1673 return class->nested_in
? mono_type_get_object (domain
, &class->nested_in
->byval_arg
) : NULL
;
1676 static MonoReflectionType
*
1677 ves_icall_MonoType_get_UnderlyingSystemType (MonoReflectionType
*type
)
1679 MonoDomain
*domain
= mono_domain_get ();
1680 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1682 MONO_ARCH_SAVE_REGS
;
1684 if (class->enumtype
&& class->enum_basetype
) /* types that are modified typebuilders may not have enum_basetype set */
1685 return mono_type_get_object (domain
, class->enum_basetype
);
1686 else if (class->element_class
)
1687 return mono_type_get_object (domain
, &class->element_class
->byval_arg
);
1693 ves_icall_MonoType_get_Name (MonoReflectionType
*type
)
1695 MonoDomain
*domain
= mono_domain_get ();
1696 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1698 MONO_ARCH_SAVE_REGS
;
1700 return mono_string_new (domain
, class->name
);
1704 ves_icall_MonoType_get_Namespace (MonoReflectionType
*type
)
1706 MonoDomain
*domain
= mono_domain_get ();
1707 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1709 MONO_ARCH_SAVE_REGS
;
1711 while (class->nested_in
)
1712 class = class->nested_in
;
1714 if (class->name_space
[0] == '\0')
1717 return mono_string_new (domain
, class->name_space
);
1721 ves_icall_MonoType_GetArrayRank (MonoReflectionType
*type
)
1723 MonoClass
*class = mono_class_from_mono_type (type
->type
);
1725 MONO_ARCH_SAVE_REGS
;
1731 ves_icall_MonoType_GetGenericArguments (MonoReflectionType
*type
)
1734 MonoClass
*klass
, *pklass
;
1736 MONO_ARCH_SAVE_REGS
;
1738 klass
= mono_class_from_mono_type (type
->type
);
1740 if (klass
->generic_container
) {
1741 MonoGenericContainer
*container
= klass
->generic_container
;
1742 res
= mono_array_new (mono_object_domain (type
), mono_defaults
.monotype_class
, container
->type_argc
);
1743 for (i
= 0; i
< container
->type_argc
; ++i
) {
1744 pklass
= mono_class_from_generic_parameter (&container
->type_params
[i
], klass
->image
, FALSE
);
1745 mono_array_set (res
, gpointer
, i
, mono_type_get_object (mono_object_domain (type
), &pklass
->byval_arg
));
1747 } else if (klass
->generic_class
) {
1748 MonoGenericInst
*inst
= klass
->generic_class
->inst
;
1749 res
= mono_array_new (mono_object_domain (type
), mono_defaults
.monotype_class
, inst
->type_argc
);
1750 for (i
= 0; i
< inst
->type_argc
; ++i
) {
1751 mono_array_set (res
, gpointer
, i
, mono_type_get_object (mono_object_domain (type
), inst
->type_argv
[i
]));
1754 res
= mono_array_new (mono_object_domain (type
), mono_defaults
.monotype_class
, 0);
1760 ves_icall_Type_get_IsGenericTypeDefinition (MonoReflectionType
*type
)
1763 MONO_ARCH_SAVE_REGS
;
1765 klass
= mono_class_from_mono_type (type
->type
);
1767 return klass
->generic_container
!= NULL
;
1770 static MonoReflectionType
*
1771 ves_icall_Type_GetGenericTypeDefinition_impl (MonoReflectionType
*type
)
1774 MONO_ARCH_SAVE_REGS
;
1776 klass
= mono_class_from_mono_type (type
->type
);
1777 if (klass
->generic_container
) {
1778 return type
; /* check this one */
1780 if (klass
->generic_class
) {
1781 MonoType
*generic_type
= klass
->generic_class
->generic_type
;
1782 MonoClass
*generic_class
= mono_class_from_mono_type (generic_type
);
1784 if (generic_class
->wastypebuilder
&& generic_class
->reflection_info
)
1785 return generic_class
->reflection_info
;
1787 return mono_type_get_object (mono_object_domain (type
), generic_type
);
1792 static MonoReflectionType
*
1793 ves_icall_Type_BindGenericParameters (MonoReflectionType
*type
, MonoArray
*type_array
)
1795 MonoType
*geninst
, **types
;
1798 MONO_ARCH_SAVE_REGS
;
1800 count
= mono_array_length (type_array
);
1801 types
= g_new0 (MonoType
*, count
);
1803 for (i
= 0; i
< count
; i
++) {
1804 MonoReflectionType
*t
= mono_array_get (type_array
, gpointer
, i
);
1805 types
[i
] = t
->type
;
1808 geninst
= mono_reflection_bind_generic_parameters (type
, count
, types
);
1810 return mono_type_get_object (mono_object_domain (type
), geninst
);
1814 ves_icall_Type_get_IsGenericInstance (MonoReflectionType
*type
)
1817 MONO_ARCH_SAVE_REGS
;
1819 klass
= mono_class_from_mono_type (type
->type
);
1820 return klass
->generic_class
!= NULL
;
1824 ves_icall_Type_GetGenericParameterPosition (MonoReflectionType
*type
)
1826 MONO_ARCH_SAVE_REGS
;
1828 if (type
->type
->type
== MONO_TYPE_VAR
|| type
->type
->type
== MONO_TYPE_MVAR
)
1829 return type
->type
->data
.generic_param
->num
;
1833 static GenericParameterAttributes
1834 ves_icall_Type_GetGenericParameterAttributes (MonoReflectionType
*type
)
1836 MONO_ARCH_SAVE_REGS
;
1837 return type
->type
->data
.generic_param
->flags
;
1841 ves_icall_Type_GetGenericParameterConstraints (MonoReflectionType
*type
)
1843 MonoGenericParam
*param
;
1849 MONO_ARCH_SAVE_REGS
;
1851 domain
= mono_object_domain (type
);
1852 param
= type
->type
->data
.generic_param
;
1853 for (count
= 0, ptr
= param
->constraints
; ptr
&& *ptr
; ptr
++, count
++)
1856 res
= mono_array_new (domain
, mono_defaults
.monotype_class
, count
);
1857 for (i
= 0; i
< count
; i
++)
1858 mono_array_set (res
, gpointer
, i
,
1859 mono_type_get_object (domain
, ¶m
->constraints
[i
]->byval_arg
));
1866 ves_icall_MonoType_get_HasGenericArguments (MonoReflectionType
*type
)
1869 MONO_ARCH_SAVE_REGS
;
1871 klass
= mono_class_from_mono_type (type
->type
);
1872 if (klass
->generic_container
|| klass
->generic_class
)
1878 ves_icall_MonoType_get_IsGenericParameter (MonoReflectionType
*type
)
1880 MONO_ARCH_SAVE_REGS
;
1882 if (type
->type
->type
== MONO_TYPE_VAR
|| type
->type
->type
== MONO_TYPE_MVAR
)
1888 ves_icall_TypeBuilder_get_IsGenericParameter (MonoReflectionTypeBuilder
*tb
)
1890 MONO_ARCH_SAVE_REGS
;
1892 if (tb
->type
.type
->type
== MONO_TYPE_VAR
|| tb
->type
.type
->type
== MONO_TYPE_MVAR
)
1898 ves_icall_EnumBuilder_setup_enum_type (MonoReflectionType
*enumtype
,
1899 MonoReflectionType
*t
)
1901 enumtype
->type
= t
->type
;
1904 static MonoReflectionType
*
1905 ves_icall_MonoGenericClass_GetParentType (MonoReflectionGenericClass
*type
)
1907 MonoGenericClass
*gclass
;
1910 MONO_ARCH_SAVE_REGS
;
1912 gclass
= type
->type
.type
->data
.generic_class
;
1913 if (!gclass
|| !gclass
->parent
|| (gclass
->parent
->type
!= MONO_TYPE_GENERICINST
))
1916 klass
= mono_class_from_mono_type (gclass
->parent
);
1917 if (!klass
->generic_class
&& !klass
->generic_container
)
1920 return mono_type_get_object (mono_object_domain (type
), gclass
->parent
);
1924 ves_icall_MonoGenericClass_GetInterfaces (MonoReflectionGenericClass
*type
)
1926 static MonoClass
*System_Reflection_MonoGenericClass
;
1927 MonoGenericClass
*gclass
;
1933 MONO_ARCH_SAVE_REGS
;
1935 if (!System_Reflection_MonoGenericClass
) {
1936 System_Reflection_MonoGenericClass
= mono_class_from_name (
1937 mono_defaults
.corlib
, "System.Reflection", "MonoGenericClass");
1938 g_assert (System_Reflection_MonoGenericClass
);
1941 domain
= mono_object_domain (type
);
1943 gclass
= type
->type
.type
->data
.generic_class
;
1944 if (!gclass
|| !gclass
->ifaces
)
1945 return mono_array_new (domain
, System_Reflection_MonoGenericClass
, 0);
1947 klass
= mono_class_from_mono_type (gclass
->generic_type
);
1949 res
= mono_array_new (domain
, System_Reflection_MonoGenericClass
, gclass
->count_ifaces
);
1951 for (i
= 0; i
< gclass
->count_ifaces
; i
++) {
1952 MonoReflectionType
*iface
= mono_type_get_object (domain
, gclass
->ifaces
[i
]);
1954 mono_array_set (res
, gpointer
, i
, iface
);
1961 ves_icall_MonoGenericClass_GetMethods (MonoReflectionGenericClass
*type
,
1962 MonoReflectionType
*reflected_type
)
1964 MonoGenericClass
*gclass
;
1965 MonoDynamicGenericClass
*dgclass
;
1967 MonoClass
*refclass
;
1971 MONO_ARCH_SAVE_REGS
;
1973 gclass
= type
->type
.type
->data
.generic_class
;
1974 g_assert ((dgclass
= gclass
->dynamic_info
) != NULL
);
1976 refclass
= mono_class_from_mono_type (reflected_type
->type
);
1978 domain
= mono_object_domain (type
);
1979 res
= mono_array_new (domain
, mono_defaults
.method_info_class
, dgclass
->count_methods
);
1981 for (i
= 0; i
< dgclass
->count_methods
; i
++)
1982 mono_array_set (res
, gpointer
, i
,
1983 mono_method_get_object (domain
, dgclass
->methods
[i
], refclass
));
1989 ves_icall_MonoGenericClass_GetConstructors (MonoReflectionGenericClass
*type
,
1990 MonoReflectionType
*reflected_type
)
1992 static MonoClass
*System_Reflection_ConstructorInfo
;
1993 MonoGenericClass
*gclass
;
1994 MonoDynamicGenericClass
*dgclass
;
1996 MonoClass
*refclass
;
2000 MONO_ARCH_SAVE_REGS
;
2002 if (!System_Reflection_ConstructorInfo
)
2003 System_Reflection_ConstructorInfo
= mono_class_from_name (
2004 mono_defaults
.corlib
, "System.Reflection", "ConstructorInfo");
2006 gclass
= type
->type
.type
->data
.generic_class
;
2007 g_assert ((dgclass
= gclass
->dynamic_info
) != NULL
);
2009 refclass
= mono_class_from_mono_type (reflected_type
->type
);
2011 domain
= mono_object_domain (type
);
2012 res
= mono_array_new (domain
, System_Reflection_ConstructorInfo
, dgclass
->count_ctors
);
2014 for (i
= 0; i
< dgclass
->count_ctors
; i
++)
2015 mono_array_set (res
, gpointer
, i
,
2016 mono_method_get_object (domain
, dgclass
->ctors
[i
], refclass
));
2022 ves_icall_MonoGenericClass_GetFields (MonoReflectionGenericClass
*type
,
2023 MonoReflectionType
*reflected_type
)
2025 MonoGenericClass
*gclass
;
2026 MonoDynamicGenericClass
*dgclass
;
2028 MonoClass
*refclass
;
2032 MONO_ARCH_SAVE_REGS
;
2034 gclass
= type
->type
.type
->data
.generic_class
;
2035 g_assert ((dgclass
= gclass
->dynamic_info
) != NULL
);
2037 refclass
= mono_class_from_mono_type (reflected_type
->type
);
2039 domain
= mono_object_domain (type
);
2040 res
= mono_array_new (domain
, mono_defaults
.field_info_class
, dgclass
->count_fields
);
2042 for (i
= 0; i
< dgclass
->count_fields
; i
++)
2043 mono_array_set (res
, gpointer
, i
,
2044 mono_field_get_object (domain
, refclass
, &dgclass
->fields
[i
]));
2050 ves_icall_MonoGenericClass_GetProperties (MonoReflectionGenericClass
*type
,
2051 MonoReflectionType
*reflected_type
)
2053 static MonoClass
*System_Reflection_PropertyInfo
;
2054 MonoGenericClass
*gclass
;
2055 MonoDynamicGenericClass
*dgclass
;
2057 MonoClass
*refclass
;
2061 MONO_ARCH_SAVE_REGS
;
2063 if (!System_Reflection_PropertyInfo
)
2064 System_Reflection_PropertyInfo
= mono_class_from_name (
2065 mono_defaults
.corlib
, "System.Reflection", "PropertyInfo");
2067 gclass
= type
->type
.type
->data
.generic_class
;
2068 g_assert ((dgclass
= gclass
->dynamic_info
) != NULL
);
2070 refclass
= mono_class_from_mono_type (reflected_type
->type
);
2072 domain
= mono_object_domain (type
);
2073 res
= mono_array_new (domain
, System_Reflection_PropertyInfo
, dgclass
->count_properties
);
2075 for (i
= 0; i
< dgclass
->count_properties
; i
++)
2076 mono_array_set (res
, gpointer
, i
,
2077 mono_property_get_object (domain
, refclass
, &dgclass
->properties
[i
]));
2083 ves_icall_MonoGenericClass_GetEvents (MonoReflectionGenericClass
*type
,
2084 MonoReflectionType
*reflected_type
)
2086 static MonoClass
*System_Reflection_EventInfo
;
2087 MonoGenericClass
*gclass
;
2088 MonoDynamicGenericClass
*dgclass
;
2090 MonoClass
*refclass
;
2094 MONO_ARCH_SAVE_REGS
;
2096 if (!System_Reflection_EventInfo
)
2097 System_Reflection_EventInfo
= mono_class_from_name (
2098 mono_defaults
.corlib
, "System.Reflection", "EventInfo");
2100 gclass
= type
->type
.type
->data
.generic_class
;
2101 g_assert ((dgclass
= gclass
->dynamic_info
) != NULL
);
2103 refclass
= mono_class_from_mono_type (reflected_type
->type
);
2105 domain
= mono_object_domain (type
);
2106 res
= mono_array_new (domain
, System_Reflection_EventInfo
, dgclass
->count_events
);
2108 for (i
= 0; i
< dgclass
->count_events
; i
++)
2109 mono_array_set (res
, gpointer
, i
,
2110 mono_event_get_object (domain
, refclass
, &dgclass
->events
[i
]));
2115 static MonoReflectionMethod
*
2116 ves_icall_MonoType_get_DeclaringMethod (MonoReflectionType
*type
)
2121 MONO_ARCH_SAVE_REGS
;
2123 method
= type
->type
->data
.generic_param
->method
;
2127 klass
= mono_class_from_mono_type (type
->type
);
2128 return mono_method_get_object (mono_object_domain (type
), method
, klass
);
2131 static MonoReflectionDllImportAttribute
*
2132 ves_icall_MonoMethod_GetDllImportAttribute (MonoMethod
*method
)
2134 static MonoClass
*DllImportAttributeClass
= NULL
;
2135 MonoDomain
*domain
= mono_domain_get ();
2136 MonoReflectionDllImportAttribute
*attr
;
2137 MonoImage
*image
= method
->klass
->image
;
2138 MonoMethodPInvoke
*piinfo
= (MonoMethodPInvoke
*)method
;
2139 MonoTableInfo
*tables
= image
->tables
;
2140 MonoTableInfo
*im
= &tables
[MONO_TABLE_IMPLMAP
];
2141 MonoTableInfo
*mr
= &tables
[MONO_TABLE_MODULEREF
];
2142 guint32 im_cols
[MONO_IMPLMAP_SIZE
];
2143 guint32 scope_token
;
2144 const char *import
= NULL
;
2145 const char *scope
= NULL
;
2148 if (!method
->flags
& METHOD_ATTRIBUTE_PINVOKE_IMPL
)
2151 if (!DllImportAttributeClass
) {
2152 DllImportAttributeClass
=
2153 mono_class_from_name (mono_defaults
.corlib
,
2154 "System.Runtime.InteropServices", "DllImportAttribute");
2155 g_assert (DllImportAttributeClass
);
2158 if (method
->klass
->image
->dynamic
) {
2159 MonoReflectionMethodAux
*method_aux
=
2160 mono_g_hash_table_lookup (
2161 ((MonoDynamicImage
*)method
->klass
->image
)->method_aux_hash
, method
);
2163 import
= method_aux
->dllentry
;
2164 scope
= method_aux
->dll
;
2168 if (piinfo
->implmap_idx
) {
2169 mono_metadata_decode_row (im
, piinfo
->implmap_idx
- 1, im_cols
, MONO_IMPLMAP_SIZE
);
2171 piinfo
->piflags
= im_cols
[MONO_IMPLMAP_FLAGS
];
2172 import
= mono_metadata_string_heap (image
, im_cols
[MONO_IMPLMAP_NAME
]);
2173 scope_token
= mono_metadata_decode_row_col (mr
, im_cols
[MONO_IMPLMAP_SCOPE
] - 1, MONO_MODULEREF_NAME
);
2174 scope
= mono_metadata_string_heap (image
, scope_token
);
2177 flags
= piinfo
->piflags
;
2179 attr
= (MonoReflectionDllImportAttribute
*)mono_object_new (domain
, DllImportAttributeClass
);
2181 attr
->dll
= mono_string_new (domain
, scope
);
2182 attr
->entry_point
= mono_string_new (domain
, import
);
2183 attr
->call_conv
= (flags
& 0x700) >> 8;
2184 attr
->charset
= ((flags
& 0x6) >> 1) + 1;
2185 if (attr
->charset
== 1)
2187 attr
->exact_spelling
= (flags
& 0x1) != 0;
2188 attr
->set_last_error
= (flags
& 0x4) != 0;
2189 attr
->best_fit_mapping
= (flags
& 0x10) != 0;
2190 attr
->throw_on_unmappable
= (flags
& 0x1000) != 0;
2191 attr
->preserve_sig
= FALSE
;
2196 static MonoReflectionMethod
*
2197 ves_icall_MonoMethod_GetGenericMethodDefinition (MonoReflectionMethod
*method
)
2199 MonoMethodInflated
*imethod
;
2201 MONO_ARCH_SAVE_REGS
;
2203 if (!method
->method
->signature
->is_inflated
) {
2204 if (method
->method
->signature
->generic_param_count
)
2210 imethod
= (MonoMethodInflated
*) method
->method
;
2211 if (imethod
->context
->gmethod
&& imethod
->context
->gmethod
->reflection_info
)
2212 return imethod
->context
->gmethod
->reflection_info
;
2214 return mono_method_get_object (
2215 mono_object_domain (method
), imethod
->declaring
, NULL
);
2219 ves_icall_MonoMethod_get_HasGenericParameters (MonoReflectionMethod
*method
)
2221 MONO_ARCH_SAVE_REGS
;
2223 if ((method
->method
->flags
& METHOD_ATTRIBUTE_PINVOKE_IMPL
) ||
2224 (method
->method
->iflags
& METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL
))
2227 return method
->method
->signature
->generic_param_count
!= 0;
2231 ves_icall_MonoMethod_get_Mono_IsInflatedMethod (MonoReflectionMethod
*method
)
2233 MONO_ARCH_SAVE_REGS
;
2235 if ((method
->method
->flags
& METHOD_ATTRIBUTE_PINVOKE_IMPL
) ||
2236 (method
->method
->iflags
& METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL
))
2239 return method
->method
->signature
->is_inflated
;
2243 ves_icall_MonoMethod_get_IsGenericMethodDefinition (MonoReflectionMethod
*method
)
2245 MONO_ARCH_SAVE_REGS
;
2247 if ((method
->method
->flags
& METHOD_ATTRIBUTE_PINVOKE_IMPL
) ||
2248 (method
->method
->iflags
& METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL
))
2251 return method
->method
->signature
->generic_param_count
!= 0;
2255 ves_icall_MonoMethod_GetGenericArguments (MonoReflectionMethod
*method
)
2259 MonoMethodNormal
*mn
;
2261 MONO_ARCH_SAVE_REGS
;
2263 domain
= mono_object_domain (method
);
2265 if ((method
->method
->flags
& METHOD_ATTRIBUTE_PINVOKE_IMPL
) ||
2266 (method
->method
->iflags
& METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL
))
2267 return mono_array_new (domain
, mono_defaults
.monotype_class
, 0);
2269 if (method
->method
->signature
->is_inflated
) {
2270 MonoMethodInflated
*imethod
= (MonoMethodInflated
*) method
->method
;
2271 MonoGenericMethod
*gmethod
= imethod
->context
->gmethod
;
2274 count
= gmethod
->inst
->type_argc
;
2275 res
= mono_array_new (domain
, mono_defaults
.monotype_class
, count
);
2277 for (i
= 0; i
< count
; i
++) {
2278 MonoType
*t
= gmethod
->inst
->type_argv
[i
];
2280 res
, gpointer
, i
, mono_type_get_object (domain
, t
));
2287 mn
= (MonoMethodNormal
*) method
->method
;
2288 count
= method
->method
->signature
->generic_param_count
;
2289 res
= mono_array_new (domain
, mono_defaults
.monotype_class
, count
);
2291 for (i
= 0; i
< count
; i
++) {
2292 MonoGenericParam
*param
= &mn
->generic_container
->type_params
[i
];
2293 MonoClass
*pklass
= mono_class_from_generic_parameter (
2294 param
, method
->method
->klass
->image
, TRUE
);
2295 mono_array_set (res
, gpointer
, i
,
2296 mono_type_get_object (domain
, &pklass
->byval_arg
));
2303 ves_icall_InternalInvoke (MonoReflectionMethod
*method
, MonoObject
*this, MonoArray
*params
)
2306 * Invoke from reflection is supposed to always be a virtual call (the API
2307 * is stupid), mono_runtime_invoke_*() calls the provided method, allowing
2308 * greater flexibility.
2310 MonoMethod
*m
= method
->method
;
2314 MONO_ARCH_SAVE_REGS
;
2317 if (!mono_object_isinst (this, m
->klass
))
2318 mono_raise_exception (mono_exception_from_name (mono_defaults
.corlib
, "System.Reflection", "TargetException"));
2319 m
= mono_object_get_virtual_method (this, m
);
2320 /* must pass the pointer to the value for valuetype methods */
2321 if (m
->klass
->valuetype
)
2322 obj
= mono_object_unbox (this);
2323 } else if (!(m
->flags
& METHOD_ATTRIBUTE_STATIC
) && strcmp (m
->name
, ".ctor") && !m
->wrapper_type
)
2324 mono_raise_exception (mono_exception_from_name (mono_defaults
.corlib
, "System.Reflection", "TargetException"));
2326 pcount
= params
? mono_array_length (params
): 0;
2327 if (pcount
!= m
->signature
->param_count
)
2328 mono_raise_exception (mono_exception_from_name (mono_defaults
.corlib
, "System.Reflection", "TargetParameterCountException"));
2330 if ((m
->klass
->flags
& TYPE_ATTRIBUTE_ABSTRACT
) && !strcmp (m
->name
, ".ctor"))
2331 mono_raise_exception (mono_exception_from_name_msg (mono_defaults
.corlib
, "System", "MethodAccessException", "Cannot invoke constructor of an abstract class."));
2333 if (m
->klass
->rank
&& !strcmp (m
->name
, ".ctor")) {
2336 guint32
*lower_bounds
;
2337 pcount
= mono_array_length (params
);
2338 lengths
= alloca (sizeof (guint32
) * pcount
);
2339 for (i
= 0; i
< pcount
; ++i
)
2340 lengths
[i
] = *(gint32
*) ((char*)mono_array_get (params
, gpointer
, i
) + sizeof (MonoObject
));
2342 if (m
->klass
->rank
== pcount
) {
2343 /* Only lengths provided. */
2344 lower_bounds
= NULL
;
2346 g_assert (pcount
== (m
->klass
->rank
* 2));
2347 /* lower bounds are first. */
2348 lower_bounds
= lengths
;
2349 lengths
+= m
->klass
->rank
;
2352 return (MonoObject
*)mono_array_new_full (mono_object_domain (params
), m
->klass
, lengths
, lower_bounds
);
2354 return mono_runtime_invoke_array (m
, obj
, params
, NULL
);
2358 ves_icall_InternalExecute (MonoReflectionMethod
*method
, MonoObject
*this, MonoArray
*params
, MonoArray
**outArgs
)
2360 MonoDomain
*domain
= mono_object_domain (method
);
2361 MonoMethod
*m
= method
->method
;
2362 MonoMethodSignature
*sig
= m
->signature
;
2363 MonoArray
*out_args
;
2365 int i
, j
, outarg_count
= 0;
2367 MONO_ARCH_SAVE_REGS
;
2369 if (m
->klass
== mono_defaults
.object_class
) {
2371 if (!strcmp (m
->name
, "FieldGetter")) {
2372 MonoClass
*k
= this->vtable
->klass
;
2376 /* If this is a proxy, then it must be a CBO */
2377 if (k
== mono_defaults
.transparent_proxy_class
) {
2378 MonoTransparentProxy
*tp
= (MonoTransparentProxy
*) this;
2379 this = tp
->rp
->unwrapped_server
;
2381 k
= this->vtable
->klass
;
2384 name
= mono_array_get (params
, MonoString
*, 1);
2385 str
= mono_string_to_utf8 (name
);
2388 for (i
= 0; i
< k
->field
.count
; i
++) {
2389 if (!strcmp (k
->fields
[i
].name
, str
)) {
2390 MonoClass
*field_klass
= mono_class_from_mono_type (k
->fields
[i
].type
);
2391 if (field_klass
->valuetype
)
2392 result
= mono_value_box (domain
, field_klass
,
2393 (char *)this + k
->fields
[i
].offset
);
2395 result
= *((gpointer
*)((char *)this + k
->fields
[i
].offset
));
2398 out_args
= mono_array_new (domain
, mono_defaults
.object_class
, 1);
2399 *outArgs
= out_args
;
2400 mono_array_set (out_args
, gpointer
, 0, result
);
2410 g_assert_not_reached ();
2412 } else if (!strcmp (m
->name
, "FieldSetter")) {
2413 MonoClass
*k
= this->vtable
->klass
;
2418 /* If this is a proxy, then it must be a CBO */
2419 if (k
== mono_defaults
.transparent_proxy_class
) {
2420 MonoTransparentProxy
*tp
= (MonoTransparentProxy
*) this;
2421 this = tp
->rp
->unwrapped_server
;
2423 k
= this->vtable
->klass
;
2426 name
= mono_array_get (params
, MonoString
*, 1);
2427 str
= mono_string_to_utf8 (name
);
2430 for (i
= 0; i
< k
->field
.count
; i
++) {
2431 if (!strcmp (k
->fields
[i
].name
, str
)) {
2432 MonoClass
*field_klass
= mono_class_from_mono_type (k
->fields
[i
].type
);
2433 MonoObject
*val
= mono_array_get (params
, gpointer
, 2);
2435 if (field_klass
->valuetype
) {
2436 size
= mono_type_size (k
->fields
[i
].type
, &align
);
2437 memcpy ((char *)this + k
->fields
[i
].offset
,
2438 ((char *)val
) + sizeof (MonoObject
), size
);
2440 *(MonoObject
**)((char *)this + k
->fields
[i
].offset
) = val
;
2442 out_args
= mono_array_new (domain
, mono_defaults
.object_class
, 0);
2443 *outArgs
= out_args
;
2454 g_assert_not_reached ();
2459 for (i
= 0; i
< mono_array_length (params
); i
++) {
2460 if (sig
->params
[i
]->byref
)
2464 out_args
= mono_array_new (domain
, mono_defaults
.object_class
, outarg_count
);
2466 /* handle constructors only for objects already allocated */
2467 if (!strcmp (method
->method
->name
, ".ctor"))
2470 /* This can be called only on MBR objects, so no need to unbox for valuetypes. */
2471 g_assert (!method
->method
->klass
->valuetype
);
2472 result
= mono_runtime_invoke_array (method
->method
, this, params
, NULL
);
2474 for (i
= 0, j
= 0; i
< mono_array_length (params
); i
++) {
2475 if (sig
->params
[i
]->byref
) {
2477 arg
= mono_array_get (params
, gpointer
, i
);
2478 mono_array_set (out_args
, gpointer
, j
, arg
);
2483 *outArgs
= out_args
;
2489 ves_icall_System_Enum_ToObject (MonoReflectionType
*type
, MonoObject
*obj
)
2492 MonoClass
*enumc
, *objc
;
2496 MONO_ARCH_SAVE_REGS
;
2498 MONO_CHECK_ARG_NULL (type
);
2499 MONO_CHECK_ARG_NULL (obj
);
2501 domain
= mono_object_domain (type
);
2502 enumc
= mono_class_from_mono_type (type
->type
);
2503 objc
= obj
->vtable
->klass
;
2505 MONO_CHECK_ARG (obj
, enumc
->enumtype
== TRUE
);
2506 MONO_CHECK_ARG (obj
, (objc
->enumtype
) || (objc
->byval_arg
.type
>= MONO_TYPE_I1
&&
2507 objc
->byval_arg
.type
<= MONO_TYPE_U8
));
2509 s1
= mono_class_value_size (enumc
, NULL
);
2510 s2
= mono_class_value_size (objc
, NULL
);
2512 res
= mono_object_new (domain
, enumc
);
2514 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
2515 memcpy ((char *)res
+ sizeof (MonoObject
), (char *)obj
+ sizeof (MonoObject
), MIN (s1
, s2
));
2517 memcpy ((char *)res
+ sizeof (MonoObject
) + (s1
> s2
? s1
- s2
: 0),
2518 (char *)obj
+ sizeof (MonoObject
) + (s2
> s1
? s2
- s1
: 0),
2525 ves_icall_System_Enum_get_value (MonoObject
*this)
2533 MONO_ARCH_SAVE_REGS
;
2538 g_assert (this->vtable
->klass
->enumtype
);
2540 enumc
= mono_class_from_mono_type (this->vtable
->klass
->enum_basetype
);
2541 res
= mono_object_new (mono_object_domain (this), enumc
);
2542 dst
= (char *)res
+ sizeof (MonoObject
);
2543 src
= (char *)this + sizeof (MonoObject
);
2544 size
= mono_class_value_size (enumc
, NULL
);
2546 memcpy (dst
, src
, size
);
2552 ves_icall_get_enum_info (MonoReflectionType
*type
, MonoEnumInfo
*info
)
2554 MonoDomain
*domain
= mono_object_domain (type
);
2555 MonoClass
*enumc
= mono_class_from_mono_type (type
->type
);
2556 guint i
, j
, nvalues
, crow
;
2557 MonoClassField
*field
;
2559 MONO_ARCH_SAVE_REGS
;
2561 info
->utype
= mono_type_get_object (domain
, enumc
->enum_basetype
);
2562 nvalues
= enumc
->field
.count
? enumc
->field
.count
- 1 : 0;
2563 info
->names
= mono_array_new (domain
, mono_defaults
.string_class
, nvalues
);
2564 info
->values
= mono_array_new (domain
, enumc
, nvalues
);
2567 for (i
= 0, j
= 0; i
< enumc
->field
.count
; ++i
) {
2571 field
= &enumc
->fields
[i
];
2572 if (strcmp ("value__", field
->name
) == 0)
2574 if (mono_field_is_deleted (field
))
2576 mono_array_set (info
->names
, gpointer
, j
, mono_string_new (domain
, field
->name
));
2579 crow
= mono_metadata_get_constant_index (enumc
->image
, MONO_TOKEN_FIELD_DEF
| (i
+enumc
->field
.first
+1), crow
+ 1);
2580 field
->def_type
= mono_metadata_decode_row_col (&enumc
->image
->tables
[MONO_TABLE_CONSTANT
], crow
-1, MONO_CONSTANT_TYPE
);
2581 crow
= mono_metadata_decode_row_col (&enumc
->image
->tables
[MONO_TABLE_CONSTANT
], crow
-1, MONO_CONSTANT_VALUE
);
2582 field
->data
= (gpointer
)mono_metadata_blob_heap (enumc
->image
, crow
);
2586 len
= mono_metadata_decode_blob_size (p
, &p
);
2587 switch (enumc
->enum_basetype
->type
) {
2590 mono_array_set (info
->values
, gchar
, j
, *p
);
2592 case MONO_TYPE_CHAR
:
2595 mono_array_set (info
->values
, gint16
, j
, read16 (p
));
2599 mono_array_set (info
->values
, gint32
, j
, read32 (p
));
2603 mono_array_set (info
->values
, gint64
, j
, read64 (p
));
2606 g_error ("Implement type 0x%02x in get_enum_info", enumc
->enum_basetype
->type
);
2613 BFLAGS_IgnoreCase
= 1,
2614 BFLAGS_DeclaredOnly
= 2,
2615 BFLAGS_Instance
= 4,
2617 BFLAGS_Public
= 0x10,
2618 BFLAGS_NonPublic
= 0x20,
2619 BFLAGS_FlattenHierarchy
= 0x40,
2620 BFLAGS_InvokeMethod
= 0x100,
2621 BFLAGS_CreateInstance
= 0x200,
2622 BFLAGS_GetField
= 0x400,
2623 BFLAGS_SetField
= 0x800,
2624 BFLAGS_GetProperty
= 0x1000,
2625 BFLAGS_SetProperty
= 0x2000,
2626 BFLAGS_ExactBinding
= 0x10000,
2627 BFLAGS_SuppressChangeType
= 0x20000,
2628 BFLAGS_OptionalParamBinding
= 0x40000
2631 static MonoReflectionField
*
2632 ves_icall_Type_GetField (MonoReflectionType
*type
, MonoString
*name
, guint32 bflags
)
2635 MonoClass
*startklass
, *klass
;
2637 MonoClassField
*field
;
2639 int (*compare_func
) (const char *s1
, const char *s2
) = NULL
;
2640 domain
= ((MonoObject
*)type
)->vtable
->domain
;
2641 klass
= startklass
= mono_class_from_mono_type (type
->type
);
2643 MONO_ARCH_SAVE_REGS
;
2646 mono_raise_exception (mono_get_exception_argument_null ("name"));
2648 compare_func
= (bflags
& BFLAGS_IgnoreCase
) ? g_strcasecmp
: strcmp
;
2651 for (i
= 0; i
< klass
->field
.count
; ++i
) {
2653 field
= &klass
->fields
[i
];
2654 if (mono_field_is_deleted (field
))
2656 if ((field
->type
->attrs
& FIELD_ATTRIBUTE_FIELD_ACCESS_MASK
) == FIELD_ATTRIBUTE_PUBLIC
) {
2657 if (bflags
& BFLAGS_Public
)
2660 if (bflags
& BFLAGS_NonPublic
)
2666 if (field
->type
->attrs
& FIELD_ATTRIBUTE_STATIC
) {
2667 if (bflags
& BFLAGS_Static
)
2668 if ((bflags
& BFLAGS_FlattenHierarchy
) || (klass
== startklass
))
2671 if (bflags
& BFLAGS_Instance
)
2678 utf8_name
= mono_string_to_utf8 (name
);
2680 if (compare_func (field
->name
, utf8_name
)) {
2686 return mono_field_get_object (domain
, startklass
, field
);
2688 if (!(bflags
& BFLAGS_DeclaredOnly
) && (klass
= klass
->parent
))
2695 ves_icall_Type_GetFields_internal (MonoReflectionType
*type
, guint32 bflags
, MonoReflectionType
*reftype
)
2698 GSList
*l
= NULL
, *tmp
;
2699 MonoClass
*startklass
, *klass
, *refklass
;
2703 MonoClassField
*field
;
2705 MONO_ARCH_SAVE_REGS
;
2707 domain
= ((MonoObject
*)type
)->vtable
->domain
;
2708 klass
= startklass
= mono_class_from_mono_type (type
->type
);
2709 refklass
= mono_class_from_mono_type (reftype
->type
);
2712 for (i
= 0; i
< klass
->field
.count
; ++i
) {
2714 field
= &klass
->fields
[i
];
2715 if (mono_field_is_deleted (field
))
2717 if ((field
->type
->attrs
& FIELD_ATTRIBUTE_FIELD_ACCESS_MASK
) == FIELD_ATTRIBUTE_PUBLIC
) {
2718 if (bflags
& BFLAGS_Public
)
2721 if (bflags
& BFLAGS_NonPublic
)
2727 if (field
->type
->attrs
& FIELD_ATTRIBUTE_STATIC
) {
2728 if (bflags
& BFLAGS_Static
)
2729 if ((bflags
& BFLAGS_FlattenHierarchy
) || (klass
== startklass
))
2732 if (bflags
& BFLAGS_Instance
)
2738 member
= (MonoObject
*)mono_field_get_object (domain
, refklass
, field
);
2739 l
= g_slist_prepend (l
, member
);
2741 if (!(bflags
& BFLAGS_DeclaredOnly
) && (klass
= klass
->parent
))
2743 len
= g_slist_length (l
);
2744 res
= mono_array_new (domain
, mono_defaults
.field_info_class
, len
);
2746 tmp
= l
= g_slist_reverse (l
);
2747 for (; tmp
; tmp
= tmp
->next
, ++i
)
2748 mono_array_set (res
, gpointer
, i
, tmp
->data
);
2754 ves_icall_Type_GetMethodsByName (MonoReflectionType
*type
, MonoString
*name
, guint32 bflags
, MonoBoolean ignore_case
, MonoReflectionType
*reftype
)
2757 GSList
*l
= NULL
, *tmp
;
2758 MonoClass
*startklass
, *klass
, *refklass
;
2763 GHashTable
*method_slots
= g_hash_table_new (NULL
, NULL
);
2764 gchar
*mname
= NULL
;
2765 int (*compare_func
) (const char *s1
, const char *s2
) = NULL
;
2767 MONO_ARCH_SAVE_REGS
;
2769 domain
= ((MonoObject
*)type
)->vtable
->domain
;
2770 klass
= startklass
= mono_class_from_mono_type (type
->type
);
2771 refklass
= mono_class_from_mono_type (reftype
->type
);
2774 mname
= mono_string_to_utf8 (name
);
2775 compare_func
= (ignore_case
) ? g_strcasecmp
: strcmp
;
2779 for (i
= 0; i
< klass
->method
.count
; ++i
) {
2781 method
= klass
->methods
[i
];
2782 if (strcmp (method
->name
, ".ctor") == 0 || strcmp (method
->name
, ".cctor") == 0)
2784 if ((method
->flags
& METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK
) == METHOD_ATTRIBUTE_PUBLIC
) {
2785 if (bflags
& BFLAGS_Public
)
2788 if (bflags
& BFLAGS_NonPublic
)
2794 if (method
->flags
& METHOD_ATTRIBUTE_STATIC
) {
2795 if (bflags
& BFLAGS_Static
)
2796 if ((bflags
& BFLAGS_FlattenHierarchy
) || (klass
== startklass
))
2799 if (bflags
& BFLAGS_Instance
)
2807 if (compare_func (mname
, method
->name
))
2812 if (method
->slot
!= -1) {
2813 if (g_hash_table_lookup (method_slots
, GUINT_TO_POINTER (method
->slot
)))
2815 g_hash_table_insert (method_slots
, GUINT_TO_POINTER (method
->slot
), method
);
2818 member
= (MonoObject
*)mono_method_get_object (domain
, method
, refklass
);
2820 l
= g_slist_prepend (l
, member
);
2823 if (!(bflags
& BFLAGS_DeclaredOnly
) && (klass
= klass
->parent
))
2827 res
= mono_array_new (domain
, mono_defaults
.method_info_class
, len
);
2830 tmp
= l
= g_slist_reverse (l
);
2832 for (; tmp
; tmp
= tmp
->next
, ++i
)
2833 mono_array_set (res
, gpointer
, i
, tmp
->data
);
2835 g_hash_table_destroy (method_slots
);
2840 ves_icall_Type_GetConstructors_internal (MonoReflectionType
*type
, guint32 bflags
, MonoReflectionType
*reftype
)
2843 GSList
*l
= NULL
, *tmp
;
2844 static MonoClass
*System_Reflection_ConstructorInfo
;
2845 MonoClass
*startklass
, *klass
, *refklass
;
2851 MONO_ARCH_SAVE_REGS
;
2853 domain
= ((MonoObject
*)type
)->vtable
->domain
;
2854 klass
= startklass
= mono_class_from_mono_type (type
->type
);
2855 refklass
= mono_class_from_mono_type (reftype
->type
);
2857 for (i
= 0; i
< klass
->method
.count
; ++i
) {
2859 method
= klass
->methods
[i
];
2860 if (strcmp (method
->name
, ".ctor") && strcmp (method
->name
, ".cctor"))
2862 if ((method
->flags
& METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK
) == METHOD_ATTRIBUTE_PUBLIC
) {
2863 if (bflags
& BFLAGS_Public
)
2866 if (bflags
& BFLAGS_NonPublic
)
2872 if (method
->flags
& METHOD_ATTRIBUTE_STATIC
) {
2873 if (bflags
& BFLAGS_Static
)
2874 if ((bflags
& BFLAGS_FlattenHierarchy
) || (klass
== startklass
))
2877 if (bflags
& BFLAGS_Instance
)
2883 member
= (MonoObject
*)mono_method_get_object (domain
, method
, refklass
);
2885 l
= g_slist_prepend (l
, member
);
2887 len
= g_slist_length (l
);
2888 if (!System_Reflection_ConstructorInfo
)
2889 System_Reflection_ConstructorInfo
= mono_class_from_name (
2890 mono_defaults
.corlib
, "System.Reflection", "ConstructorInfo");
2891 res
= mono_array_new (domain
, System_Reflection_ConstructorInfo
, len
);
2893 tmp
= l
= g_slist_reverse (l
);
2894 for (; tmp
; tmp
= tmp
->next
, ++i
)
2895 mono_array_set (res
, gpointer
, i
, tmp
->data
);
2901 ves_icall_Type_GetPropertiesByName (MonoReflectionType
*type
, MonoString
*name
, guint32 bflags
, MonoBoolean ignore_case
, MonoReflectionType
*reftype
)
2904 GSList
*l
= NULL
, *tmp
;
2905 static MonoClass
*System_Reflection_PropertyInfo
;
2906 MonoClass
*startklass
, *klass
;
2913 GHashTable
*method_slots
= g_hash_table_new (NULL
, NULL
);
2914 gchar
*propname
= NULL
;
2915 int (*compare_func
) (const char *s1
, const char *s2
) = NULL
;
2917 MONO_ARCH_SAVE_REGS
;
2919 domain
= ((MonoObject
*)type
)->vtable
->domain
;
2920 klass
= startklass
= mono_class_from_mono_type (type
->type
);
2922 propname
= mono_string_to_utf8 (name
);
2923 compare_func
= (ignore_case
) ? g_strcasecmp
: strcmp
;
2927 for (i
= 0; i
< klass
->property
.count
; ++i
) {
2928 prop
= &klass
->properties
[i
];
2934 flags
= method
->flags
;
2937 if ((prop
->get
&& ((prop
->get
->flags
& METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK
) == METHOD_ATTRIBUTE_PUBLIC
)) ||
2938 (prop
->set
&& ((prop
->set
->flags
& METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK
) == METHOD_ATTRIBUTE_PUBLIC
))) {
2939 if (bflags
& BFLAGS_Public
)
2942 if (bflags
& BFLAGS_NonPublic
)
2948 if (flags
& METHOD_ATTRIBUTE_STATIC
) {
2949 if (bflags
& BFLAGS_Static
)
2950 if ((bflags
& BFLAGS_FlattenHierarchy
) || (klass
== startklass
))
2953 if (bflags
& BFLAGS_Instance
)
2962 if (compare_func (propname
, prop
->name
))
2966 if (prop
->get
&& prop
->get
->slot
!= -1) {
2967 if (g_hash_table_lookup (method_slots
, GUINT_TO_POINTER (prop
->get
->slot
)))
2969 g_hash_table_insert (method_slots
, GUINT_TO_POINTER (prop
->get
->slot
), prop
);
2971 if (prop
->set
&& prop
->set
->slot
!= -1) {
2972 if (g_hash_table_lookup (method_slots
, GUINT_TO_POINTER (prop
->set
->slot
)))
2974 g_hash_table_insert (method_slots
, GUINT_TO_POINTER (prop
->set
->slot
), prop
);
2977 l
= g_slist_prepend (l
, mono_property_get_object (domain
, startklass
, prop
));
2980 if ((!(bflags
& BFLAGS_DeclaredOnly
) && (klass
= klass
->parent
)))
2984 if (!System_Reflection_PropertyInfo
)
2985 System_Reflection_PropertyInfo
= mono_class_from_name (
2986 mono_defaults
.corlib
, "System.Reflection", "PropertyInfo");
2987 res
= mono_array_new (domain
, System_Reflection_PropertyInfo
, len
);
2990 tmp
= l
= g_slist_reverse (l
);
2992 for (; tmp
; tmp
= tmp
->next
, ++i
)
2993 mono_array_set (res
, gpointer
, i
, tmp
->data
);
2995 g_hash_table_destroy (method_slots
);
2999 static MonoReflectionEvent
*
3000 ves_icall_MonoType_GetEvent (MonoReflectionType
*type
, MonoString
*name
, guint32 bflags
)
3003 MonoClass
*klass
, *startklass
;
3009 MONO_ARCH_SAVE_REGS
;
3011 event_name
= mono_string_to_utf8 (name
);
3012 klass
= startklass
= mono_class_from_mono_type (type
->type
);
3013 domain
= mono_object_domain (type
);
3016 for (i
= 0; i
< klass
->event
.count
; i
++) {
3017 event
= &klass
->events
[i
];
3018 if (strcmp (event
->name
, event_name
))
3021 method
= event
->add
;
3023 method
= event
->remove
;
3025 method
= event
->raise
;
3027 if ((method
->flags
& METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK
) == METHOD_ATTRIBUTE_PUBLIC
) {
3028 if (!(bflags
& BFLAGS_Public
))
3031 if (!(bflags
& BFLAGS_NonPublic
))
3036 if (!(bflags
& BFLAGS_NonPublic
))
3039 g_free (event_name
);
3040 return mono_event_get_object (domain
, startklass
, event
);
3043 if (!(bflags
& BFLAGS_DeclaredOnly
) && (klass
= klass
->parent
))
3046 g_free (event_name
);
3051 ves_icall_Type_GetEvents_internal (MonoReflectionType
*type
, guint32 bflags
, MonoReflectionType
*reftype
)
3054 GSList
*l
= NULL
, *tmp
;
3055 static MonoClass
*System_Reflection_EventInfo
;
3056 MonoClass
*startklass
, *klass
;
3062 MONO_ARCH_SAVE_REGS
;
3064 domain
= ((MonoObject
*)type
)->vtable
->domain
;
3065 klass
= startklass
= mono_class_from_mono_type (type
->type
);
3068 for (i
= 0; i
< klass
->event
.count
; ++i
) {
3069 event
= &klass
->events
[i
];
3071 method
= event
->add
;
3073 method
= event
->remove
;
3075 method
= event
->raise
;
3077 if ((method
->flags
& METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK
) == METHOD_ATTRIBUTE_PUBLIC
) {
3078 if (bflags
& BFLAGS_Public
)
3081 if (bflags
& BFLAGS_NonPublic
)
3086 if (bflags
& BFLAGS_NonPublic
)
3092 if (method
->flags
& METHOD_ATTRIBUTE_STATIC
) {
3093 if (bflags
& BFLAGS_Static
)
3094 if ((bflags
& BFLAGS_FlattenHierarchy
) || (klass
== startklass
))
3097 if (bflags
& BFLAGS_Instance
)
3102 if (bflags
& BFLAGS_Instance
)
3107 l
= g_slist_prepend (l
, mono_event_get_object (domain
, klass
, event
));
3109 if (!(bflags
& BFLAGS_DeclaredOnly
) && (klass
= klass
->parent
))
3111 len
= g_slist_length (l
);
3112 if (!System_Reflection_EventInfo
)
3113 System_Reflection_EventInfo
= mono_class_from_name (
3114 mono_defaults
.corlib
, "System.Reflection", "EventInfo");
3115 res
= mono_array_new (domain
, System_Reflection_EventInfo
, len
);
3118 tmp
= l
= g_slist_reverse (l
);
3120 for (; tmp
; tmp
= tmp
->next
, ++i
)
3121 mono_array_set (res
, gpointer
, i
, tmp
->data
);
3126 static MonoReflectionType
*
3127 ves_icall_Type_GetNestedType (MonoReflectionType
*type
, MonoString
*name
, guint32 bflags
)
3130 MonoClass
*startklass
, *klass
;
3135 MONO_ARCH_SAVE_REGS
;
3137 domain
= ((MonoObject
*)type
)->vtable
->domain
;
3138 klass
= startklass
= mono_class_from_mono_type (type
->type
);
3139 str
= mono_string_to_utf8 (name
);
3142 for (tmpn
= klass
->nested_classes
; tmpn
; tmpn
= tmpn
->next
) {
3144 nested
= tmpn
->data
;
3145 if ((nested
->flags
& TYPE_ATTRIBUTE_VISIBILITY_MASK
) == TYPE_ATTRIBUTE_NESTED_PUBLIC
) {
3146 if (bflags
& BFLAGS_Public
)
3149 if (bflags
& BFLAGS_NonPublic
)
3154 if (strcmp (nested
->name
, str
) == 0){
3156 return mono_type_get_object (domain
, &nested
->byval_arg
);
3159 if (!(bflags
& BFLAGS_DeclaredOnly
) && (klass
= klass
->parent
))
3166 ves_icall_Type_GetNestedTypes (MonoReflectionType
*type
, guint32 bflags
)
3169 GSList
*l
= NULL
, *tmp
;
3171 MonoClass
*startklass
, *klass
;
3177 MONO_ARCH_SAVE_REGS
;
3179 domain
= ((MonoObject
*)type
)->vtable
->domain
;
3180 klass
= startklass
= mono_class_from_mono_type (type
->type
);
3182 for (tmpn
= klass
->nested_classes
; tmpn
; tmpn
= tmpn
->next
) {
3184 nested
= tmpn
->data
;
3185 if ((nested
->flags
& TYPE_ATTRIBUTE_VISIBILITY_MASK
) == TYPE_ATTRIBUTE_NESTED_PUBLIC
) {
3186 if (bflags
& BFLAGS_Public
)
3189 if (bflags
& BFLAGS_NonPublic
)
3194 member
= (MonoObject
*)mono_type_get_object (domain
, &nested
->byval_arg
);
3195 l
= g_slist_prepend (l
, member
);
3197 len
= g_slist_length (l
);
3198 res
= mono_array_new (domain
, mono_defaults
.monotype_class
, len
);
3200 tmp
= l
= g_slist_reverse (l
);
3201 for (; tmp
; tmp
= tmp
->next
, ++i
)
3202 mono_array_set (res
, gpointer
, i
, tmp
->data
);
3207 static MonoReflectionType
*
3208 ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly
*assembly
, MonoReflectionModule
*module
, MonoString
*name
, MonoBoolean throwOnError
, MonoBoolean ignoreCase
)
3211 MonoType
*type
= NULL
;
3212 MonoTypeNameParse info
;
3213 gboolean type_resolve
= FALSE
;
3215 MONO_ARCH_SAVE_REGS
;
3217 str
= mono_string_to_utf8 (name
);
3218 /*g_print ("requested type %s in %s\n", str, assembly->assembly->aname.name);*/
3219 if (!mono_reflection_parse_type (str
, &info
)) {
3221 g_list_free (info
.modifiers
);
3222 g_list_free (info
.nested
);
3223 if (throwOnError
) /* uhm: this is a parse error, though... */
3224 mono_raise_exception (mono_get_exception_type_load (name
));
3225 /*g_print ("failed parse\n");*/
3229 if (module
!= NULL
) {
3231 type
= mono_reflection_get_type (module
->image
, &info
, ignoreCase
, &type_resolve
);
3236 if (assembly
->assembly
->dynamic
) {
3237 /* Enumerate all modules */
3238 MonoReflectionAssemblyBuilder
*abuilder
= (MonoReflectionAssemblyBuilder
*)assembly
;
3242 if (abuilder
->modules
) {
3243 for (i
= 0; i
< mono_array_length (abuilder
->modules
); ++i
) {
3244 MonoReflectionModuleBuilder
*mb
= mono_array_get (abuilder
->modules
, MonoReflectionModuleBuilder
*, i
);
3245 type
= mono_reflection_get_type (&mb
->dynamic_image
->image
, &info
, ignoreCase
, &type_resolve
);
3251 if (!type
&& abuilder
->loaded_modules
) {
3252 for (i
= 0; i
< mono_array_length (abuilder
->loaded_modules
); ++i
) {
3253 MonoReflectionModule
*mod
= mono_array_get (abuilder
->loaded_modules
, MonoReflectionModule
*, i
);
3254 type
= mono_reflection_get_type (mod
->image
, &info
, ignoreCase
, &type_resolve
);
3261 type
= mono_reflection_get_type (assembly
->assembly
->image
, &info
, ignoreCase
, &type_resolve
);
3263 g_list_free (info
.modifiers
);
3264 g_list_free (info
.nested
);
3267 mono_raise_exception (mono_get_exception_type_load (name
));
3268 /* g_print ("failed find\n"); */
3271 /* g_print ("got it\n"); */
3272 return mono_type_get_object (mono_object_domain (assembly
), type
);
3277 ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly
*assembly
)
3279 MonoDomain
*domain
= mono_object_domain (assembly
);
3280 MonoAssembly
*mass
= assembly
->assembly
;
3285 MONO_ARCH_SAVE_REGS
;
3287 absolute
= g_build_filename (mass
->basedir
, mass
->image
->module_name
, NULL
);
3288 uri
= g_filename_to_uri (absolute
, NULL
, NULL
);
3289 res
= mono_string_new (domain
, uri
);
3296 ves_icall_System_Reflection_Assembly_get_global_assembly_cache (MonoReflectionAssembly
*assembly
)
3298 MonoAssembly
*mass
= assembly
->assembly
;
3300 MONO_ARCH_SAVE_REGS
;
3302 return mass
->in_gac
;
3305 static MonoReflectionAssembly
*
3306 ves_icall_System_Reflection_Assembly_load_with_partial_name (MonoString
*mname
, MonoObject
*evidence
)
3310 MonoImageOpenStatus status
;
3312 MONO_ARCH_SAVE_REGS
;
3314 name
= mono_string_to_utf8 (mname
);
3315 res
= mono_assembly_load_with_partial_name (name
, &status
);
3321 return mono_assembly_get_object (mono_domain_get (), res
);
3325 ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssembly
*assembly
)
3327 MonoDomain
*domain
= mono_object_domain (assembly
);
3330 MONO_ARCH_SAVE_REGS
;
3332 res
= mono_string_new (domain
, mono_image_get_filename (assembly
->assembly
->image
));
3338 ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion (MonoReflectionAssembly
*assembly
)
3340 MonoDomain
*domain
= mono_object_domain (assembly
);
3342 MONO_ARCH_SAVE_REGS
;
3344 return mono_string_new (domain
, assembly
->assembly
->image
->version
);
3347 static MonoReflectionMethod
*
3348 ves_icall_System_Reflection_Assembly_get_EntryPoint (MonoReflectionAssembly
*assembly
)
3350 guint32 token
= mono_image_get_entry_point (assembly
->assembly
->image
);
3352 MONO_ARCH_SAVE_REGS
;
3356 return mono_method_get_object (mono_object_domain (assembly
), mono_get_method (assembly
->assembly
->image
, token
, NULL
), NULL
);
3359 static MonoReflectionModule
*
3360 ves_icall_System_Reflection_Assembly_get_ManifestModule (MonoReflectionAssembly
*assembly
)
3362 return mono_module_get_object (mono_object_domain (assembly
), assembly
->assembly
->image
);
3366 ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAssembly
*assembly
)
3368 MonoTableInfo
*table
= &assembly
->assembly
->image
->tables
[MONO_TABLE_MANIFESTRESOURCE
];
3369 MonoArray
*result
= mono_array_new (mono_object_domain (assembly
), mono_defaults
.string_class
, table
->rows
);
3373 MONO_ARCH_SAVE_REGS
;
3375 for (i
= 0; i
< table
->rows
; ++i
) {
3376 val
= mono_metadata_string_heap (assembly
->assembly
->image
, mono_metadata_decode_row_col (table
, i
, MONO_MANIFEST_NAME
));
3377 mono_array_set (result
, gpointer
, i
, mono_string_new (mono_object_domain (assembly
), val
));
3383 ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAssembly
*assembly
)
3385 static MonoClass
*System_Reflection_AssemblyName
;
3387 MonoDomain
*domain
= mono_object_domain (assembly
);
3389 static MonoMethod
*create_culture
= NULL
;
3392 MONO_ARCH_SAVE_REGS
;
3394 if (!System_Reflection_AssemblyName
)
3395 System_Reflection_AssemblyName
= mono_class_from_name (
3396 mono_defaults
.corlib
, "System.Reflection", "AssemblyName");
3398 t
= &assembly
->assembly
->image
->tables
[MONO_TABLE_ASSEMBLYREF
];
3401 result
= mono_array_new (domain
, System_Reflection_AssemblyName
, count
);
3404 MonoMethodDesc
*desc
= mono_method_desc_new (
3405 "System.Globalization.CultureInfo:CreateSpecificCulture(string)", TRUE
);
3406 create_culture
= mono_method_desc_search_in_image (desc
, mono_defaults
.corlib
);
3407 g_assert (create_culture
);
3408 mono_method_desc_free (desc
);
3411 for (i
= 0; i
< count
; i
++) {
3412 MonoAssembly
*assem
;
3413 MonoReflectionAssemblyName
*aname
;
3414 char *codebase
, *absolute
;
3416 /* FIXME: There is no need to load the assemblies themselves */
3417 mono_assembly_load_reference (assembly
->assembly
->image
, i
);
3419 assem
= assembly
->assembly
->image
->references
[i
];
3420 if (assem
== (gpointer
)-1) {
3421 char *msg
= g_strdup_printf ("Assembly %d referenced from assembly %s not found ", i
, assembly
->assembly
->image
->name
);
3422 MonoException
*ex
= mono_get_exception_file_not_found2 (msg
, NULL
);
3424 mono_raise_exception (ex
);
3427 aname
= (MonoReflectionAssemblyName
*) mono_object_new (
3428 domain
, System_Reflection_AssemblyName
);
3430 aname
->name
= mono_string_new (domain
, assem
->aname
.name
);
3432 aname
->major
= assem
->aname
.major
;
3433 aname
->minor
= assem
->aname
.minor
;
3434 aname
->build
= assem
->aname
.build
;
3435 aname
->revision
= assem
->aname
.revision
;
3436 aname
->revision
= assem
->aname
.revision
;
3437 aname
->hashalg
= assem
->aname
.hash_alg
;
3438 aname
->flags
= assem
->aname
.flags
;
3440 if (create_culture
) {
3442 args
[0] = mono_string_new (domain
, assem
->aname
.culture
);
3443 aname
->cultureInfo
= mono_runtime_invoke (create_culture
, NULL
, args
, NULL
);
3446 if (assem
->aname
.public_key
) {
3448 const char *pkey_ptr
= assem
->aname
.public_key
;
3449 pkey_len
= mono_metadata_decode_blob_size (pkey_ptr
, &pkey_ptr
);
3451 aname
->publicKey
= mono_array_new (domain
, mono_defaults
.byte_class
, pkey_len
);
3452 memcpy (mono_array_addr (aname
->publicKey
, guint8
, 0), pkey_ptr
, pkey_len
);
3455 /* public key token isn't copied - the class library will
3456 automatically generate it from the public key if required */
3458 absolute
= g_build_filename (assem
->basedir
, assem
->image
->module_name
, NULL
);
3459 codebase
= g_filename_to_uri (absolute
, NULL
, NULL
);
3460 aname
->codebase
= mono_string_new (domain
, codebase
);
3463 mono_array_set (result
, gpointer
, i
, aname
);
3474 foreach_namespace (const char* key
, gconstpointer val
, NameSpaceInfo
*info
)
3476 MonoString
*name
= mono_string_new (mono_object_domain (info
->res
), key
);
3478 mono_array_set (info
->res
, gpointer
, info
->idx
, name
);
3483 ves_icall_System_Reflection_Assembly_GetNamespaces (MonoReflectionAssembly
*assembly
)
3485 MonoImage
*img
= assembly
->assembly
->image
;
3489 MONO_ARCH_SAVE_REGS
;
3491 res
= mono_array_new (mono_object_domain (assembly
), mono_defaults
.string_class
, g_hash_table_size (img
->name_cache
));
3494 g_hash_table_foreach (img
->name_cache
, (GHFunc
)foreach_namespace
, &info
);
3499 /* move this in some file in mono/util/ */
3501 g_concat_dir_and_file (const char *dir
, const char *file
)
3503 g_return_val_if_fail (dir
!= NULL
, NULL
);
3504 g_return_val_if_fail (file
!= NULL
, NULL
);
3507 * If the directory name doesn't have a / on the end, we need
3508 * to add one so we get a proper path to the file
3510 if (dir
[strlen(dir
) - 1] != G_DIR_SEPARATOR
)
3511 return g_strconcat (dir
, G_DIR_SEPARATOR_S
, file
, NULL
);
3513 return g_strconcat (dir
, file
, NULL
);
3517 ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflectionAssembly
*assembly
, MonoString
*name
, gint32
*size
, MonoReflectionModule
**ref_module
)
3519 char *n
= mono_string_to_utf8 (name
);
3520 MonoTableInfo
*table
= &assembly
->assembly
->image
->tables
[MONO_TABLE_MANIFESTRESOURCE
];
3522 guint32 cols
[MONO_MANIFEST_SIZE
];
3523 guint32 impl
, file_idx
;
3527 MONO_ARCH_SAVE_REGS
;
3529 for (i
= 0; i
< table
->rows
; ++i
) {
3530 mono_metadata_decode_row (table
, i
, cols
, MONO_MANIFEST_SIZE
);
3531 val
= mono_metadata_string_heap (assembly
->assembly
->image
, cols
[MONO_MANIFEST_NAME
]);
3532 if (strcmp (val
, n
) == 0)
3536 if (i
== table
->rows
)
3539 impl
= cols
[MONO_MANIFEST_IMPLEMENTATION
];
3542 * this code should only be called after obtaining the
3543 * ResourceInfo and handling the other cases.
3545 g_assert ((impl
& MONO_IMPLEMENTATION_MASK
) == MONO_IMPLEMENTATION_FILE
);
3546 file_idx
= impl
>> MONO_IMPLEMENTATION_BITS
;
3548 module
= mono_image_load_file_for_image (assembly
->assembly
->image
, file_idx
);
3553 module
= assembly
->assembly
->image
;
3555 *ref_module
= mono_module_get_object (mono_domain_get (), module
);
3557 return (void*)mono_image_get_resource (module
, cols
[MONO_MANIFEST_OFFSET
], size
);
3561 ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (MonoReflectionAssembly
*assembly
, MonoString
*name
, MonoManifestResourceInfo
*info
)
3563 MonoTableInfo
*table
= &assembly
->assembly
->image
->tables
[MONO_TABLE_MANIFESTRESOURCE
];
3565 guint32 cols
[MONO_MANIFEST_SIZE
];
3566 guint32 file_cols
[MONO_FILE_SIZE
];
3570 MONO_ARCH_SAVE_REGS
;
3572 n
= mono_string_to_utf8 (name
);
3573 for (i
= 0; i
< table
->rows
; ++i
) {
3574 mono_metadata_decode_row (table
, i
, cols
, MONO_MANIFEST_SIZE
);
3575 val
= mono_metadata_string_heap (assembly
->assembly
->image
, cols
[MONO_MANIFEST_NAME
]);
3576 if (strcmp (val
, n
) == 0)
3580 if (i
== table
->rows
)
3583 if (!cols
[MONO_MANIFEST_IMPLEMENTATION
]) {
3584 info
->location
= RESOURCE_LOCATION_EMBEDDED
| RESOURCE_LOCATION_IN_MANIFEST
;
3587 switch (cols
[MONO_MANIFEST_IMPLEMENTATION
] & MONO_IMPLEMENTATION_MASK
) {
3588 case MONO_IMPLEMENTATION_FILE
:
3589 i
= cols
[MONO_MANIFEST_IMPLEMENTATION
] >> MONO_IMPLEMENTATION_BITS
;
3590 table
= &assembly
->assembly
->image
->tables
[MONO_TABLE_FILE
];
3591 mono_metadata_decode_row (table
, i
- 1, file_cols
, MONO_FILE_SIZE
);
3592 val
= mono_metadata_string_heap (assembly
->assembly
->image
, file_cols
[MONO_FILE_NAME
]);
3593 info
->filename
= mono_string_new (mono_object_domain (assembly
), val
);
3594 if (file_cols
[MONO_FILE_FLAGS
] && FILE_CONTAINS_NO_METADATA
)
3597 info
->location
= RESOURCE_LOCATION_EMBEDDED
;
3600 case MONO_IMPLEMENTATION_ASSEMBLYREF
:
3601 i
= cols
[MONO_MANIFEST_IMPLEMENTATION
] >> MONO_IMPLEMENTATION_BITS
;
3602 mono_assembly_load_reference (assembly
->assembly
->image
, i
- 1);
3603 if (assembly
->assembly
->image
->references
[i
- 1] == (gpointer
)-1) {
3604 char *msg
= g_strdup_printf ("Assembly %d referenced from assembly %s not found ", i
- 1, assembly
->assembly
->image
->name
);
3605 MonoException
*ex
= mono_get_exception_file_not_found2 (msg
, NULL
);
3607 mono_raise_exception (ex
);
3609 info
->assembly
= mono_assembly_get_object (mono_domain_get (), assembly
->assembly
->image
->references
[i
- 1]);
3611 /* Obtain info recursively */
3612 ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (info
->assembly
, name
, info
);
3613 info
->location
|= RESOURCE_LOCATION_ANOTHER_ASSEMBLY
;
3616 case MONO_IMPLEMENTATION_EXP_TYPE
:
3617 g_assert_not_reached ();
3626 ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssembly
*assembly
, MonoString
*name
, MonoBoolean resource_modules
)
3628 MonoTableInfo
*table
= &assembly
->assembly
->image
->tables
[MONO_TABLE_FILE
];
3629 MonoArray
*result
= NULL
;
3634 MONO_ARCH_SAVE_REGS
;
3636 /* check hash if needed */
3638 n
= mono_string_to_utf8 (name
);
3639 for (i
= 0; i
< table
->rows
; ++i
) {
3640 val
= mono_metadata_string_heap (assembly
->assembly
->image
, mono_metadata_decode_row_col (table
, i
, MONO_FILE_NAME
));
3641 if (strcmp (val
, n
) == 0) {
3644 n
= g_concat_dir_and_file (assembly
->assembly
->basedir
, val
);
3645 fn
= mono_string_new (mono_object_domain (assembly
), n
);
3647 return (MonoObject
*)fn
;
3655 for (i
= 0; i
< table
->rows
; ++i
) {
3656 if (resource_modules
|| !(mono_metadata_decode_row_col (table
, i
, MONO_FILE_FLAGS
) & FILE_CONTAINS_NO_METADATA
))
3660 result
= mono_array_new (mono_object_domain (assembly
), mono_defaults
.string_class
, count
);
3663 for (i
= 0; i
< table
->rows
; ++i
) {
3664 if (resource_modules
|| !(mono_metadata_decode_row_col (table
, i
, MONO_FILE_FLAGS
) & FILE_CONTAINS_NO_METADATA
)) {
3665 val
= mono_metadata_string_heap (assembly
->assembly
->image
, mono_metadata_decode_row_col (table
, i
, MONO_FILE_NAME
));
3666 n
= g_concat_dir_and_file (assembly
->assembly
->basedir
, val
);
3667 mono_array_set (result
, gpointer
, count
, mono_string_new (mono_object_domain (assembly
), n
));
3672 return (MonoObject
*)result
;
3676 ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly
*assembly
)
3678 MonoDomain
*domain
= mono_domain_get();
3681 int i
, j
, file_count
= 0;
3682 MonoImage
**modules
;
3683 guint32 module_count
, real_module_count
;
3684 MonoTableInfo
*table
;
3686 g_assert (assembly
->assembly
->image
!= NULL
);
3688 if (assembly
->assembly
->dynamic
) {
3689 MonoReflectionAssemblyBuilder
*assemblyb
= (MonoReflectionAssemblyBuilder
*)assembly
;
3691 if (assemblyb
->modules
)
3692 module_count
= mono_array_length (assemblyb
->modules
);
3695 real_module_count
= module_count
;
3697 modules
= g_new0 (MonoImage
*, module_count
);
3698 for (i
= 0; i
< mono_array_length (assemblyb
->modules
); ++i
) {
3700 mono_array_get (assemblyb
->modules
, MonoReflectionModuleBuilder
*, i
)->module
.image
;
3704 table
= &assembly
->assembly
->image
->tables
[MONO_TABLE_FILE
];
3705 file_count
= table
->rows
;
3707 modules
= assembly
->assembly
->image
->modules
;
3708 module_count
= assembly
->assembly
->image
->module_count
;
3710 real_module_count
= 0;
3711 for (i
= 0; i
< module_count
; ++i
)
3713 real_module_count
++;
3716 klass
= mono_class_from_name (mono_defaults
.corlib
, "System.Reflection", "Module");
3717 res
= mono_array_new (domain
, klass
, 1 + real_module_count
+ file_count
);
3719 mono_array_set (res
, gpointer
, 0, mono_module_get_object (domain
, assembly
->assembly
->image
));
3721 for (i
= 0; i
< module_count
; ++i
)
3723 mono_array_set (res
, gpointer
, j
, mono_module_get_object (domain
, modules
[i
]));
3727 for (i
= 0; i
< file_count
; ++i
, ++j
)
3728 mono_array_set (res
, gpointer
, j
, mono_module_file_get_object (domain
, assembly
->assembly
->image
, i
));
3730 if (assembly
->assembly
->dynamic
)
3736 static MonoReflectionMethod
*
3737 ves_icall_GetCurrentMethod (void)
3739 MonoMethod
*m
= mono_method_get_last_managed ();
3741 MONO_ARCH_SAVE_REGS
;
3743 return mono_method_get_object (mono_domain_get (), m
, NULL
);
3746 static MonoReflectionMethod
*
3747 ves_icall_System_Reflection_MethodBase_GetMethodFromHandleInternal (MonoMethod
*method
)
3749 return mono_method_get_object (mono_domain_get (), method
, NULL
);
3752 static MonoReflectionMethodBody
*
3753 ves_icall_System_Reflection_MethodBase_GetMethodBodyInternal (MonoMethod
*method
)
3755 return mono_method_body_get_object (mono_domain_get (), method
);
3758 static MonoReflectionAssembly
*
3759 ves_icall_System_Reflection_Assembly_GetExecutingAssembly (void)
3761 MonoMethod
*m
= mono_method_get_last_managed ();
3763 MONO_ARCH_SAVE_REGS
;
3765 return mono_assembly_get_object (mono_domain_get (), m
->klass
->image
->assembly
);
3770 get_caller (MonoMethod
*m
, gint32 no
, gint32 ilo
, gboolean managed
, gpointer data
)
3772 MonoMethod
**dest
= data
;
3774 /* skip unmanaged frames */
3789 static MonoReflectionAssembly
*
3790 ves_icall_System_Reflection_Assembly_GetEntryAssembly (void)
3792 MonoDomain
* domain
= mono_domain_get ();
3794 MONO_ARCH_SAVE_REGS
;
3796 if (!domain
->entry_assembly
)
3799 return mono_assembly_get_object (domain
, domain
->entry_assembly
);
3803 static MonoReflectionAssembly
*
3804 ves_icall_System_Reflection_Assembly_GetCallingAssembly (void)
3806 MonoMethod
*m
= mono_method_get_last_managed ();
3807 MonoMethod
*dest
= m
;
3809 MONO_ARCH_SAVE_REGS
;
3811 mono_stack_walk_no_il (get_caller
, &dest
);
3814 return mono_assembly_get_object (mono_domain_get (), dest
->klass
->image
->assembly
);
3818 ves_icall_System_MonoType_getFullName (MonoReflectionType
*object
, gboolean full_name
)
3820 MonoDomain
*domain
= mono_object_domain (object
);
3824 MONO_ARCH_SAVE_REGS
;
3827 name
= mono_type_get_full_name (object
->type
);
3829 name
= mono_type_get_name (object
->type
);
3830 res
= mono_string_new (domain
, name
);
3837 fill_reflection_assembly_name (MonoDomain
*domain
, MonoReflectionAssemblyName
*aname
, MonoAssemblyName
*name
, const char *absolute
)
3839 static MonoMethod
*create_culture
= NULL
;
3842 const char *pkey_ptr
;
3845 MONO_ARCH_SAVE_REGS
;
3847 aname
->name
= mono_string_new (domain
, name
->name
);
3848 aname
->major
= name
->major
;
3849 aname
->minor
= name
->minor
;
3850 aname
->build
= name
->build
;
3851 aname
->revision
= name
->revision
;
3852 aname
->hashalg
= name
->hash_alg
;
3854 codebase
= g_filename_to_uri (absolute
, NULL
, NULL
);
3856 aname
->codebase
= mono_string_new (domain
, codebase
);
3860 if (!create_culture
) {
3861 MonoMethodDesc
*desc
= mono_method_desc_new ("System.Globalization.CultureInfo:CreateSpecificCulture(string)", TRUE
);
3862 create_culture
= mono_method_desc_search_in_image (desc
, mono_defaults
.corlib
);
3863 g_assert (create_culture
);
3864 mono_method_desc_free (desc
);
3867 args
[0] = mono_string_new (domain
, name
->culture
);
3868 aname
->cultureInfo
=
3869 mono_runtime_invoke (create_culture
, NULL
, args
, NULL
);
3871 if (name
->public_key
) {
3872 pkey_ptr
= name
->public_key
;
3873 pkey_len
= mono_metadata_decode_blob_size (pkey_ptr
, &pkey_ptr
);
3875 aname
->publicKey
= mono_array_new (domain
, mono_defaults
.byte_class
, pkey_len
);
3876 memcpy (mono_array_addr (aname
->publicKey
, guint8
, 0), pkey_ptr
, pkey_len
);
3879 /* MonoAssemblyName keeps the public key token as an hexadecimal string */
3880 if (name
->public_key_token
[0]) {
3884 aname
->keyToken
= mono_array_new (domain
, mono_defaults
.byte_class
, 8);
3885 p
= mono_array_addr (aname
->keyToken
, char, 0);
3887 for (i
= 0, j
= 0; i
< 8; i
++) {
3888 *p
= g_ascii_xdigit_value (name
->public_key_token
[j
++]) << 4;
3889 *p
|= g_ascii_xdigit_value (name
->public_key_token
[j
++]);
3896 ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly
*assembly
, MonoReflectionAssemblyName
*aname
)
3900 MONO_ARCH_SAVE_REGS
;
3902 absolute
= g_build_filename (assembly
->assembly
->basedir
, assembly
->assembly
->image
->module_name
, NULL
);
3904 fill_reflection_assembly_name (mono_object_domain (assembly
), aname
,
3905 &assembly
->assembly
->aname
, absolute
);
3911 ves_icall_System_Reflection_Assembly_InternalGetAssemblyName (MonoString
*fname
, MonoReflectionAssemblyName
*aname
)
3914 MonoImageOpenStatus status
= MONO_IMAGE_OK
;
3917 MonoAssemblyName name
;
3919 MONO_ARCH_SAVE_REGS
;
3921 filename
= mono_string_to_utf8 (fname
);
3923 image
= mono_image_open (filename
, &status
);
3929 exc
= mono_get_exception_file_not_found (fname
);
3930 mono_raise_exception (exc
);
3933 res
= mono_assembly_fill_assembly_name (image
, &name
);
3935 mono_image_close (image
);
3937 mono_raise_exception (mono_get_exception_argument ("assemblyFile", "The file does not contain a manifest"));
3940 fill_reflection_assembly_name (mono_domain_get (), aname
, &name
, filename
);
3943 mono_image_close (image
);
3947 mono_module_get_types (MonoDomain
*domain
, MonoImage
*image
,
3948 MonoBoolean exportedOnly
)
3952 MonoTableInfo
*tdef
= &image
->tables
[MONO_TABLE_TYPEDEF
];
3954 guint32 attrs
, visibility
;
3956 /* we start the count from 1 because we skip the special type <Module> */
3959 for (i
= 1; i
< tdef
->rows
; ++i
) {
3960 attrs
= mono_metadata_decode_row_col (tdef
, i
, MONO_TYPEDEF_FLAGS
);
3961 visibility
= attrs
& TYPE_ATTRIBUTE_VISIBILITY_MASK
;
3962 if (visibility
== TYPE_ATTRIBUTE_PUBLIC
|| visibility
== TYPE_ATTRIBUTE_NESTED_PUBLIC
)
3966 count
= tdef
->rows
- 1;
3968 res
= mono_array_new (domain
, mono_defaults
.monotype_class
, count
);
3970 for (i
= 1; i
< tdef
->rows
; ++i
) {
3971 attrs
= mono_metadata_decode_row_col (tdef
, i
, MONO_TYPEDEF_FLAGS
);
3972 visibility
= attrs
& TYPE_ATTRIBUTE_VISIBILITY_MASK
;
3973 if (!exportedOnly
|| (visibility
== TYPE_ATTRIBUTE_PUBLIC
|| visibility
== TYPE_ATTRIBUTE_NESTED_PUBLIC
)) {
3974 klass
= mono_class_get (image
, (i
+ 1) | MONO_TOKEN_TYPE_DEF
);
3975 mono_array_set (res
, gpointer
, count
, mono_type_get_object (domain
, &klass
->byval_arg
));
3984 ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly
*assembly
, MonoBoolean exportedOnly
)
3986 MonoArray
*res
= NULL
;
3987 MonoImage
*image
= NULL
;
3988 MonoTableInfo
*table
= NULL
;
3992 MONO_ARCH_SAVE_REGS
;
3994 domain
= mono_object_domain (assembly
);
3996 if (assembly
->assembly
->dynamic
) {
3997 MonoReflectionAssemblyBuilder
*abuilder
= (MonoReflectionAssemblyBuilder
*)assembly
;
3998 if (abuilder
->modules
) {
3999 for (i
= 0; i
< mono_array_length(abuilder
->modules
); i
++) {
4000 MonoReflectionModuleBuilder
*mb
= mono_array_get (abuilder
->modules
, MonoReflectionModuleBuilder
*, i
);
4004 MonoArray
*append
= mb
->types
;
4005 if (mono_array_length (append
) > 0) {
4008 len1
= mono_array_length (res
);
4009 len2
= mono_array_length (append
);
4010 new = mono_array_new (domain
, mono_defaults
.monotype_class
, len1
+ len2
);
4011 memcpy (mono_array_addr (new, MonoReflectionType
*, 0),
4012 mono_array_addr (res
, MonoReflectionType
*, 0),
4013 len1
* sizeof (MonoReflectionType
*));
4014 memcpy (mono_array_addr (new, MonoReflectionType
*, len1
),
4015 mono_array_addr (append
, MonoReflectionType
*, 0),
4016 len2
* sizeof (MonoReflectionType
*));
4023 * Replace TypeBuilders with the created types to be compatible
4027 for (i
= 0; i
< mono_array_length (res
); ++i
) {
4028 MonoReflectionTypeBuilder
*tb
= mono_array_get (res
, MonoReflectionTypeBuilder
*, i
);
4030 mono_array_set (res
, MonoReflectionType
*, i
, tb
->created
);
4035 if (abuilder
->loaded_modules
)
4036 for (i
= 0; i
< mono_array_length(abuilder
->loaded_modules
); i
++) {
4037 MonoReflectionModule
*rm
= mono_array_get (abuilder
->loaded_modules
, MonoReflectionModule
*, i
);
4039 res
= mono_module_get_types (domain
, rm
->image
, exportedOnly
);
4041 MonoArray
*append
= mono_module_get_types (domain
, rm
->image
, exportedOnly
);
4042 if (mono_array_length (append
) > 0) {
4045 len1
= mono_array_length (res
);
4046 len2
= mono_array_length (append
);
4047 new = mono_array_new (domain
, mono_defaults
.monotype_class
, len1
+ len2
);
4048 memcpy (mono_array_addr (new, MonoReflectionType
*, 0),
4049 mono_array_addr (res
, MonoReflectionType
*, 0),
4050 len1
* sizeof (MonoReflectionType
*));
4051 memcpy (mono_array_addr (new, MonoReflectionType
*, len1
),
4052 mono_array_addr (append
, MonoReflectionType
*, 0),
4053 len2
* sizeof (MonoReflectionType
*));
4060 image
= assembly
->assembly
->image
;
4061 table
= &image
->tables
[MONO_TABLE_FILE
];
4062 res
= mono_module_get_types (domain
, image
, exportedOnly
);
4064 /* Append data from all modules in the assembly */
4065 for (i
= 0; i
< table
->rows
; ++i
) {
4066 if (!(mono_metadata_decode_row_col (table
, i
, MONO_FILE_FLAGS
) & FILE_CONTAINS_NO_METADATA
)) {
4067 MonoImage
*loaded_image
= mono_assembly_load_module (image
->assembly
, i
+ 1);
4069 MonoArray
*res2
= mono_module_get_types (domain
, loaded_image
, exportedOnly
);
4070 /* Append the new types to the end of the array */
4071 if (mono_array_length (res2
) > 0) {
4075 len1
= mono_array_length (res
);
4076 len2
= mono_array_length (res2
);
4077 res3
= mono_array_new (domain
, mono_defaults
.monotype_class
, len1
+ len2
);
4078 memcpy (mono_array_addr (res3
, MonoReflectionType
*, 0),
4079 mono_array_addr (res
, MonoReflectionType
*, 0),
4080 len1
* sizeof (MonoReflectionType
*));
4081 memcpy (mono_array_addr (res3
, MonoReflectionType
*, len1
),
4082 mono_array_addr (res2
, MonoReflectionType
*, 0),
4083 len2
* sizeof (MonoReflectionType
*));
4092 static MonoReflectionType
*
4093 ves_icall_System_Reflection_Module_GetGlobalType (MonoReflectionModule
*module
)
4095 MonoDomain
*domain
= mono_object_domain (module
);
4098 MONO_ARCH_SAVE_REGS
;
4100 g_assert (module
->image
);
4102 if (module
->image
->dynamic
&& ((MonoDynamicImage
*)(module
->image
))->initial_image
)
4103 /* These images do not have a global type */
4106 klass
= mono_class_get (module
->image
, 1 | MONO_TOKEN_TYPE_DEF
);
4107 return mono_type_get_object (domain
, &klass
->byval_arg
);
4111 ves_icall_System_Reflection_Module_Close (MonoReflectionModule
*module
)
4114 mono_image_close (module
->image
);
4118 ves_icall_System_Reflection_Module_GetGuidInternal (MonoReflectionModule
*module
)
4120 MonoDomain
*domain
= mono_object_domain (module
);
4122 MONO_ARCH_SAVE_REGS
;
4124 g_assert (module
->image
);
4125 return mono_string_new (domain
, module
->image
->guid
);
4129 ves_icall_System_Reflection_Module_GetPEKind (MonoImage
*image
, gint32
*pe_kind
, gint32
*machine
)
4131 if (image
->dynamic
) {
4132 MonoDynamicImage
*dyn
= (MonoDynamicImage
*)image
;
4133 *pe_kind
= dyn
->pe_kind
;
4134 *machine
= dyn
->machine
;
4137 *pe_kind
= ((MonoCLIImageInfo
*)(image
->image_info
))->cli_cli_header
.ch_flags
& 0x3;
4138 *machine
= ((MonoCLIImageInfo
*)(image
->image_info
))->cli_header
.coff
.coff_machine
;
4143 ves_icall_System_Reflection_Module_InternalGetTypes (MonoReflectionModule
*module
)
4145 MONO_ARCH_SAVE_REGS
;
4148 return mono_array_new (mono_object_domain (module
), mono_defaults
.monotype_class
, 0);
4150 return mono_module_get_types (mono_object_domain (module
), module
->image
, FALSE
);
4154 mono_metadata_memberref_is_method (MonoImage
*image
, guint32 token
)
4156 guint32 cols
[MONO_MEMBERREF_SIZE
];
4158 mono_metadata_decode_row (&image
->tables
[MONO_TABLE_MEMBERREF
], mono_metadata_token_index (token
) - 1, cols
, MONO_MEMBERREF_SIZE
);
4159 sig
= mono_metadata_blob_heap (image
, cols
[MONO_MEMBERREF_SIGNATURE
]);
4160 mono_metadata_decode_blob_size (sig
, &sig
);
4161 return (*sig
!= 0x6);
4165 ves_icall_System_Reflection_Module_ResolveTypeToken (MonoImage
*image
, guint32 token
, MonoResolveTokenError
*error
)
4168 int table
= mono_metadata_token_table (token
);
4169 int index
= mono_metadata_token_index (token
);
4171 *error
= ResolveTokenError_Other
;
4173 /* Validate token */
4174 if ((table
!= MONO_TABLE_TYPEDEF
) && (table
!= MONO_TABLE_TYPEREF
) &&
4175 (table
!= MONO_TABLE_TYPESPEC
)) {
4176 *error
= ResolveTokenError_BadTable
;
4181 return mono_lookup_dynamic_token (image
, token
);
4183 if ((index
<= 0) || (index
> image
->tables
[table
].rows
)) {
4184 *error
= ResolveTokenError_OutOfRange
;
4188 klass
= mono_class_get (image
, token
);
4190 return &klass
->byval_arg
;
4196 ves_icall_System_Reflection_Module_ResolveMethodToken (MonoImage
*image
, guint32 token
, MonoResolveTokenError
*error
)
4198 int table
= mono_metadata_token_table (token
);
4199 int index
= mono_metadata_token_index (token
);
4201 *error
= ResolveTokenError_Other
;
4203 /* Validate token */
4204 if ((table
!= MONO_TABLE_METHOD
) && (table
!= MONO_TABLE_METHODSPEC
) &&
4205 (table
!= MONO_TABLE_MEMBERREF
)) {
4206 *error
= ResolveTokenError_BadTable
;
4211 /* FIXME: validate memberref token type */
4212 return mono_lookup_dynamic_token (image
, token
);
4214 if ((index
<= 0) || (index
> image
->tables
[table
].rows
)) {
4215 *error
= ResolveTokenError_OutOfRange
;
4218 if ((table
== MONO_TABLE_MEMBERREF
) && (!mono_metadata_memberref_is_method (image
, token
))) {
4219 *error
= ResolveTokenError_BadTable
;
4223 return mono_get_method (image
, token
, NULL
);
4227 ves_icall_System_Reflection_Module_ResolveStringToken (MonoImage
*image
, guint32 token
, MonoResolveTokenError
*error
)
4229 int index
= mono_metadata_token_index (token
);
4231 *error
= ResolveTokenError_Other
;
4233 /* Validate token */
4234 if (mono_metadata_token_code (token
) != MONO_TOKEN_STRING
) {
4235 *error
= ResolveTokenError_BadTable
;
4240 return mono_lookup_dynamic_token (image
, token
);
4242 if ((index
<= 0) || (index
>= image
->heap_us
.size
)) {
4243 *error
= ResolveTokenError_OutOfRange
;
4247 /* FIXME: What to do if the index points into the middle of a string ? */
4249 return mono_ldstr (mono_domain_get (), image
, index
);
4252 static MonoClassField
*
4253 ves_icall_System_Reflection_Module_ResolveFieldToken (MonoImage
*image
, guint32 token
, MonoResolveTokenError
*error
)
4256 int table
= mono_metadata_token_table (token
);
4257 int index
= mono_metadata_token_index (token
);
4259 *error
= ResolveTokenError_Other
;
4261 /* Validate token */
4262 if ((table
!= MONO_TABLE_FIELD
) && (table
!= MONO_TABLE_MEMBERREF
)) {
4263 *error
= ResolveTokenError_BadTable
;
4268 /* FIXME: validate memberref token type */
4269 return mono_lookup_dynamic_token (image
, token
);
4271 if ((index
<= 0) || (index
> image
->tables
[table
].rows
)) {
4272 *error
= ResolveTokenError_OutOfRange
;
4275 if ((table
== MONO_TABLE_MEMBERREF
) && (mono_metadata_memberref_is_method (image
, token
))) {
4276 *error
= ResolveTokenError_BadTable
;
4280 return mono_field_from_token (image
, token
, &klass
, NULL
);
4285 ves_icall_System_Reflection_Module_ResolveMemberToken (MonoImage
*image
, guint32 token
, MonoResolveTokenError
*error
)
4287 int table
= mono_metadata_token_table (token
);
4289 *error
= ResolveTokenError_Other
;
4292 case MONO_TABLE_TYPEDEF
:
4293 case MONO_TABLE_TYPEREF
:
4294 case MONO_TABLE_TYPESPEC
: {
4295 MonoType
*t
= ves_icall_System_Reflection_Module_ResolveTypeToken (image
, token
, error
);
4297 return (MonoObject
*)mono_type_get_object (mono_domain_get (), t
);
4301 case MONO_TABLE_METHOD
:
4302 case MONO_TABLE_METHODSPEC
: {
4303 MonoMethod
*m
= ves_icall_System_Reflection_Module_ResolveMethodToken (image
, token
, error
);
4305 return (MonoObject
*)mono_method_get_object (mono_domain_get (), m
, m
->klass
);
4309 case MONO_TABLE_FIELD
: {
4310 MonoClassField
*f
= ves_icall_System_Reflection_Module_ResolveFieldToken (image
, token
, error
);
4312 return (MonoObject
*)mono_field_get_object (mono_domain_get (), f
->parent
, f
);
4316 case MONO_TABLE_MEMBERREF
:
4317 if (mono_metadata_memberref_is_method (image
, token
)) {
4318 MonoMethod
*m
= ves_icall_System_Reflection_Module_ResolveMethodToken (image
, token
, error
);
4320 return (MonoObject
*)mono_method_get_object (mono_domain_get (), m
, m
->klass
);
4325 MonoClassField
*f
= ves_icall_System_Reflection_Module_ResolveFieldToken (image
, token
, error
);
4327 return (MonoObject
*)mono_field_get_object (mono_domain_get (), f
->parent
, f
);
4334 *error
= ResolveTokenError_BadTable
;
4340 static MonoReflectionType
*
4341 ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder
*tb
, MonoString
*smodifiers
)
4344 int isbyref
= 0, rank
;
4345 char *str
= mono_string_to_utf8 (smodifiers
);
4348 MONO_ARCH_SAVE_REGS
;
4350 klass
= mono_class_from_mono_type (tb
->type
.type
);
4352 /* logic taken from mono_reflection_parse_type(): keep in sync */
4356 if (isbyref
) { /* only one level allowed by the spec */
4363 return mono_type_get_object (mono_object_domain (tb
), &klass
->this_arg
);
4366 klass
= mono_ptr_class_get (&klass
->byval_arg
);
4367 mono_class_init (klass
);
4378 else if (*p
!= '*') { /* '*' means unknown lower bound */
4389 klass
= mono_array_class_get (klass
, rank
);
4390 mono_class_init (klass
);
4397 return mono_type_get_object (mono_object_domain (tb
), &klass
->byval_arg
);
4401 ves_icall_Type_IsArrayImpl (MonoReflectionType
*t
)
4406 MONO_ARCH_SAVE_REGS
;
4409 res
= !type
->byref
&& (type
->type
== MONO_TYPE_ARRAY
|| type
->type
== MONO_TYPE_SZARRAY
);
4414 static MonoReflectionType
*
4415 ves_icall_Type_make_array_type (MonoReflectionType
*type
, int rank
)
4417 MonoClass
*klass
, *aklass
;
4419 MONO_ARCH_SAVE_REGS
;
4421 klass
= mono_class_from_mono_type (type
->type
);
4422 aklass
= mono_array_class_get (klass
, rank
);
4424 return mono_type_get_object (mono_object_domain (type
), &aklass
->byval_arg
);
4427 static MonoReflectionType
*
4428 ves_icall_Type_make_byref_type (MonoReflectionType
*type
)
4432 MONO_ARCH_SAVE_REGS
;
4434 klass
= mono_class_from_mono_type (type
->type
);
4436 return mono_type_get_object (mono_object_domain (type
), &klass
->this_arg
);
4439 static MonoReflectionType
*
4440 ves_icall_Type_MakePointerType (MonoReflectionType
*type
)
4444 MONO_ARCH_SAVE_REGS
;
4446 pklass
= mono_ptr_class_get (type
->type
);
4448 return mono_type_get_object (mono_object_domain (type
), &pklass
->byval_arg
);
4452 ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType
*type
, MonoObject
*target
,
4453 MonoReflectionMethod
*info
)
4455 MonoClass
*delegate_class
= mono_class_from_mono_type (type
->type
);
4456 MonoObject
*delegate
;
4459 MONO_ARCH_SAVE_REGS
;
4461 mono_assert (delegate_class
->parent
== mono_defaults
.multicastdelegate_class
);
4463 delegate
= mono_object_new (mono_object_domain (type
), delegate_class
);
4465 func
= mono_compile_method (info
->method
);
4467 mono_delegate_ctor (delegate
, target
, func
);
4473 ves_icall_System_Delegate_FreeTrampoline (MonoDelegate
*this)
4475 mono_delegate_free_ftnptr (this);
4479 * Magic number to convert a time which is relative to
4480 * Jan 1, 1970 into a value which is relative to Jan 1, 0001.
4482 #define EPOCH_ADJUST ((guint64)62135596800LL)
4485 * Magic number to convert FILETIME base Jan 1, 1601 to DateTime - base Jan, 1, 0001
4487 #define FILETIME_ADJUST ((guint64)504911232000000000LL)
4490 * This returns Now in UTC
4493 ves_icall_System_DateTime_GetNow (void)
4495 #ifdef PLATFORM_WIN32
4499 GetSystemTime (&st
);
4500 SystemTimeToFileTime (&st
, &ft
);
4501 return (gint64
) FILETIME_ADJUST
+ ((((gint64
)ft
.dwHighDateTime
)<<32) | ft
.dwLowDateTime
);
4503 /* FIXME: put this in io-layer and call it GetLocalTime */
4507 MONO_ARCH_SAVE_REGS
;
4509 if (gettimeofday (&tv
, NULL
) == 0) {
4510 res
= (((gint64
)tv
.tv_sec
+ EPOCH_ADJUST
)* 1000000 + tv
.tv_usec
)*10;
4513 /* fixme: raise exception */
4518 #ifdef PLATFORM_WIN32
4519 /* convert a SYSTEMTIME which is of the form "last thursday in october" to a real date */
4521 convert_to_absolute_date(SYSTEMTIME
*date
)
4523 #define IS_LEAP(y) ((y % 4) == 0 && ((y % 100) != 0 || (y % 400) == 0))
4524 static int days_in_month
[] = { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
4525 static int leap_days_in_month
[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
4526 /* from the calendar FAQ */
4527 int a
= (14 - date
->wMonth
) / 12;
4528 int y
= date
->wYear
- a
;
4529 int m
= date
->wMonth
+ 12 * a
- 2;
4530 int d
= (1 + y
+ y
/4 - y
/100 + y
/400 + (31*m
)/12) % 7;
4532 /* d is now the day of the week for the first of the month (0 == Sunday) */
4534 int day_of_week
= date
->wDayOfWeek
;
4536 /* set day_in_month to the first day in the month which falls on day_of_week */
4537 int day_in_month
= 1 + (day_of_week
- d
);
4538 if (day_in_month
<= 0)
4541 /* wDay is 1 for first weekday in month, 2 for 2nd ... 5 means last - so work that out allowing for days in the month */
4542 date
->wDay
= day_in_month
+ (date
->wDay
- 1) * 7;
4543 if (date
->wDay
> (IS_LEAP(date
->wYear
) ? leap_days_in_month
[date
->wMonth
- 1] : days_in_month
[date
->wMonth
- 1]))
4548 #ifndef PLATFORM_WIN32
4550 * Return's the offset from GMT of a local time.
4552 * tm is a local time
4553 * t is the same local time as seconds.
4556 gmt_offset(struct tm
*tm
, time_t t
)
4558 #if defined (HAVE_TM_GMTOFF)
4559 return tm
->tm_gmtoff
;
4564 g
.tm_isdst
= tm
->tm_isdst
;
4566 return (int)difftime(t
, t2
);
4571 * This is heavily based on zdump.c from glibc 2.2.
4573 * * data[0]: start of daylight saving time (in DateTime ticks).
4574 * * data[1]: end of daylight saving time (in DateTime ticks).
4575 * * data[2]: utcoffset (in TimeSpan ticks).
4576 * * data[3]: additional offset when daylight saving (in TimeSpan ticks).
4577 * * name[0]: name of this timezone when not daylight saving.
4578 * * name[1]: name of this timezone when daylight saving.
4580 * FIXME: This only works with "standard" Unix dates (years between 1900 and 2100) while
4581 * the class library allows years between 1 and 9999.
4583 * Returns true on success and zero on failure.
4586 ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year
, MonoArray
**data
, MonoArray
**names
)
4588 #ifndef PLATFORM_WIN32
4589 MonoDomain
*domain
= mono_domain_get ();
4590 struct tm start
, tt
;
4594 int is_daylight
= 0, day
;
4597 MONO_ARCH_SAVE_REGS
;
4599 MONO_CHECK_ARG_NULL (data
);
4600 MONO_CHECK_ARG_NULL (names
);
4602 (*data
) = mono_array_new (domain
, mono_defaults
.int64_class
, 4);
4603 (*names
) = mono_array_new (domain
, mono_defaults
.string_class
, 2);
4606 * no info is better than crashing: we'll need our own tz data to make
4607 * this work properly, anyway. The range is reduced to 1970 .. 2037 because
4608 * that is what mktime is guaranteed to support (we get into an infinite loop
4611 if ((year
< 1970) || (year
> 2037)) {
4613 tt
= *localtime (&t
);
4614 strftime (tzone
, sizeof (tzone
), "%Z", &tt
);
4615 mono_array_set ((*names
), gpointer
, 0, mono_string_new (domain
, tzone
));
4616 mono_array_set ((*names
), gpointer
, 1, mono_string_new (domain
, tzone
));
4620 memset (&start
, 0, sizeof (start
));
4623 start
.tm_year
= year
-1900;
4625 t
= mktime (&start
);
4626 gmtoff
= gmt_offset (&start
, t
);
4628 /* For each day of the year, calculate the tm_gmtoff. */
4629 for (day
= 0; day
< 365; day
++) {
4632 tt
= *localtime (&t
);
4634 /* Daylight saving starts or ends here. */
4635 if (gmt_offset (&tt
, t
) != gmtoff
) {
4639 /* Try to find the exact hour when daylight saving starts/ends. */
4643 tt1
= *localtime (&t1
);
4644 } while (gmt_offset (&tt1
, t1
) != gmtoff
);
4646 /* Try to find the exact minute when daylight saving starts/ends. */
4649 tt1
= *localtime (&t1
);
4650 } while (gmt_offset (&tt1
, t1
) == gmtoff
);
4652 strftime (tzone
, sizeof (tzone
), "%Z", &tt
);
4654 /* Write data, if we're already in daylight saving, we're done. */
4656 mono_array_set ((*names
), gpointer
, 0, mono_string_new (domain
, tzone
));
4657 mono_array_set ((*data
), gint64
, 1, ((gint64
)t1
+ EPOCH_ADJUST
) * 10000000L);
4660 mono_array_set ((*names
), gpointer
, 1, mono_string_new (domain
, tzone
));
4661 mono_array_set ((*data
), gint64
, 0, ((gint64
)t1
+ EPOCH_ADJUST
) * 10000000L);
4665 /* This is only set once when we enter daylight saving. */
4666 mono_array_set ((*data
), gint64
, 2, (gint64
)gmtoff
* 10000000L);
4667 mono_array_set ((*data
), gint64
, 3, (gint64
)(gmt_offset (&tt
, t
) - gmtoff
) * 10000000L);
4669 gmtoff
= gmt_offset (&tt
, t
);
4674 strftime (tzone
, sizeof (tzone
), "%Z", &tt
);
4675 mono_array_set ((*names
), gpointer
, 0, mono_string_new (domain
, tzone
));
4676 mono_array_set ((*names
), gpointer
, 1, mono_string_new (domain
, tzone
));
4677 mono_array_set ((*data
), gint64
, 0, 0);
4678 mono_array_set ((*data
), gint64
, 1, 0);
4679 mono_array_set ((*data
), gint64
, 2, (gint64
) gmtoff
* 10000000L);
4680 mono_array_set ((*data
), gint64
, 3, 0);
4685 MonoDomain
*domain
= mono_domain_get ();
4686 TIME_ZONE_INFORMATION tz_info
;
4691 tz_id
= GetTimeZoneInformation (&tz_info
);
4692 if (tz_id
== TIME_ZONE_ID_INVALID
)
4695 MONO_CHECK_ARG_NULL (data
);
4696 MONO_CHECK_ARG_NULL (names
);
4698 (*data
) = mono_array_new (domain
, mono_defaults
.int64_class
, 4);
4699 (*names
) = mono_array_new (domain
, mono_defaults
.string_class
, 2);
4701 for (i
= 0; i
< 32; ++i
)
4702 if (!tz_info
.DaylightName
[i
])
4704 mono_array_set ((*names
), gpointer
, 1, mono_string_new_utf16 (domain
, tz_info
.DaylightName
, i
));
4705 for (i
= 0; i
< 32; ++i
)
4706 if (!tz_info
.StandardName
[i
])
4708 mono_array_set ((*names
), gpointer
, 0, mono_string_new_utf16 (domain
, tz_info
.StandardName
, i
));
4710 if ((year
<= 1601) || (year
> 30827)) {
4712 * According to MSDN, the MS time functions can't handle dates outside
4718 /* even if the timezone has no daylight savings it may have Bias (e.g. GMT+13 it seems) */
4719 if (tz_id
!= TIME_ZONE_ID_UNKNOWN
) {
4720 tz_info
.StandardDate
.wYear
= year
;
4721 convert_to_absolute_date(&tz_info
.StandardDate
);
4722 err
= SystemTimeToFileTime (&tz_info
.StandardDate
, &ft
);
4724 mono_array_set ((*data
), gint64
, 1, FILETIME_ADJUST
+ (((guint64
)ft
.dwHighDateTime
<<32) | ft
.dwLowDateTime
));
4725 tz_info
.DaylightDate
.wYear
= year
;
4726 convert_to_absolute_date(&tz_info
.DaylightDate
);
4727 err
= SystemTimeToFileTime (&tz_info
.DaylightDate
, &ft
);
4729 mono_array_set ((*data
), gint64
, 0, FILETIME_ADJUST
+ (((guint64
)ft
.dwHighDateTime
<<32) | ft
.dwLowDateTime
));
4731 mono_array_set ((*data
), gint64
, 2, (tz_info
.Bias
+ tz_info
.StandardBias
) * -600000000LL);
4732 mono_array_set ((*data
), gint64
, 3, (tz_info
.DaylightBias
- tz_info
.StandardBias
) * -600000000LL);
4739 ves_icall_System_Object_obj_address (MonoObject
*this)
4741 MONO_ARCH_SAVE_REGS
;
4748 static inline gint32
4749 mono_array_get_byte_length (MonoArray
*array
)
4755 klass
= array
->obj
.vtable
->klass
;
4757 if (array
->bounds
== NULL
)
4758 length
= array
->max_length
;
4761 for (i
= 0; i
< klass
->rank
; ++ i
)
4762 length
*= array
->bounds
[i
].length
;
4765 switch (klass
->element_class
->byval_arg
.type
) {
4768 case MONO_TYPE_BOOLEAN
:
4772 case MONO_TYPE_CHAR
:
4780 return length
* sizeof (gpointer
);
4791 ves_icall_System_Buffer_ByteLengthInternal (MonoArray
*array
)
4793 MONO_ARCH_SAVE_REGS
;
4795 return mono_array_get_byte_length (array
);
4799 ves_icall_System_Buffer_GetByteInternal (MonoArray
*array
, gint32 idx
)
4801 MONO_ARCH_SAVE_REGS
;
4803 return mono_array_get (array
, gint8
, idx
);
4807 ves_icall_System_Buffer_SetByteInternal (MonoArray
*array
, gint32 idx
, gint8 value
)
4809 MONO_ARCH_SAVE_REGS
;
4811 mono_array_set (array
, gint8
, idx
, value
);
4815 ves_icall_System_Buffer_BlockCopyInternal (MonoArray
*src
, gint32 src_offset
, MonoArray
*dest
, gint32 dest_offset
, gint32 count
)
4817 char *src_buf
, *dest_buf
;
4819 MONO_ARCH_SAVE_REGS
;
4821 /* watch out for integer overflow */
4822 if ((src_offset
> mono_array_get_byte_length (src
) - count
) || (dest_offset
> mono_array_get_byte_length (dest
) - count
))
4825 src_buf
= (gint8
*)src
->vector
+ src_offset
;
4826 dest_buf
= (gint8
*)dest
->vector
+ dest_offset
;
4829 memcpy (dest_buf
, src_buf
, count
);
4831 memmove (dest_buf
, src_buf
, count
); /* Source and dest are the same array */
4837 ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject
*this, MonoString
*class_name
)
4839 MonoDomain
*domain
= mono_object_domain (this);
4841 MonoRealProxy
*rp
= ((MonoRealProxy
*)this);
4842 MonoTransparentProxy
*tp
;
4846 MONO_ARCH_SAVE_REGS
;
4848 res
= mono_object_new (domain
, mono_defaults
.transparent_proxy_class
);
4849 tp
= (MonoTransparentProxy
*) res
;
4852 type
= ((MonoReflectionType
*)rp
->class_to_proxy
)->type
;
4853 klass
= mono_class_from_mono_type (type
);
4855 tp
->custom_type_info
= (mono_object_isinst (this, mono_defaults
.iremotingtypeinfo_class
) != NULL
);
4856 tp
->remote_class
= mono_remote_class (domain
, class_name
, klass
);
4858 res
->vtable
= mono_remote_class_vtable (domain
, tp
->remote_class
, rp
);
4862 static MonoReflectionType
*
4863 ves_icall_Remoting_RealProxy_InternalGetProxyType (MonoTransparentProxy
*tp
)
4865 return mono_type_get_object (mono_object_domain (tp
), &tp
->remote_class
->proxy_class
->byval_arg
);
4868 /* System.Environment */
4871 ves_icall_System_Environment_get_MachineName (void)
4873 #if defined (PLATFORM_WIN32)
4878 len
= MAX_COMPUTERNAME_LENGTH
+ 1;
4879 buf
= g_new (gunichar2
, len
);
4882 if (GetComputerName (buf
, (PDWORD
) &len
))
4883 result
= mono_string_new_utf16 (mono_domain_get (), buf
, len
);
4892 MONO_ARCH_SAVE_REGS
;
4895 buf
= g_new (gchar
, len
);
4898 if (gethostname (buf
, len
) == 0)
4899 result
= mono_string_new (mono_domain_get (), buf
);
4907 ves_icall_System_Environment_get_Platform (void)
4909 MONO_ARCH_SAVE_REGS
;
4911 #if defined (PLATFORM_WIN32)
4921 ves_icall_System_Environment_get_NewLine (void)
4923 MONO_ARCH_SAVE_REGS
;
4925 #if defined (PLATFORM_WIN32)
4926 return mono_string_new (mono_domain_get (), "\r\n");
4928 return mono_string_new (mono_domain_get (), "\n");
4933 ves_icall_System_Environment_GetEnvironmentVariable (MonoString
*name
)
4938 MONO_ARCH_SAVE_REGS
;
4943 utf8_name
= mono_string_to_utf8 (name
); /* FIXME: this should be ascii */
4944 value
= g_getenv (utf8_name
);
4950 return mono_string_new (mono_domain_get (), value
);
4954 * There is no standard way to get at environ.
4962 ves_icall_System_Environment_GetEnvironmentVariableNames (void)
4970 MONO_ARCH_SAVE_REGS
;
4973 for (e
= environ
; *e
!= 0; ++ e
)
4976 domain
= mono_domain_get ();
4977 names
= mono_array_new (domain
, mono_defaults
.string_class
, n
);
4980 for (e
= environ
; *e
!= 0; ++ e
) {
4981 parts
= g_strsplit (*e
, "=", 2);
4983 str
= mono_string_new (domain
, *parts
);
4984 mono_array_set (names
, MonoString
*, n
, str
);
4996 * Returns: the number of milliseconds elapsed since the system started.
4999 ves_icall_System_Environment_get_TickCount (void)
5001 return GetTickCount ();
5006 ves_icall_System_Environment_Exit (int result
)
5008 MONO_ARCH_SAVE_REGS
;
5010 mono_runtime_quit ();
5012 /* we may need to do some cleanup here... */
5017 ves_icall_System_Environment_GetGacPath (void)
5019 return mono_string_new (mono_domain_get (), mono_assembly_getrootdir ());
5023 ves_icall_System_Environment_GetWindowsFolderPath (int folder
)
5025 #if defined (PLATFORM_WIN32)
5026 #ifndef CSIDL_FLAG_CREATE
5027 #define CSIDL_FLAG_CREATE 0x8000
5030 WCHAR path
[MAX_PATH
];
5031 /* Create directory if no existing */
5032 if (SUCCEEDED (SHGetFolderPathW (NULL
, folder
| CSIDL_FLAG_CREATE
, NULL
, 0, path
))) {
5036 return mono_string_new_utf16 (mono_domain_get (), path
, len
);
5039 g_warning ("ves_icall_System_Environment_GetWindowsFolderPath should only be called on Windows!");
5041 return mono_string_new (mono_domain_get (), "");
5045 ves_icall_System_Environment_GetLogicalDrives (void)
5047 gunichar2 buf
[128], *ptr
, *dname
;
5049 gint initial_size
= 127, size
= 128;
5052 MonoString
*drivestr
;
5053 MonoDomain
*domain
= mono_domain_get ();
5055 MONO_ARCH_SAVE_REGS
;
5060 while (size
> initial_size
) {
5061 size
= GetLogicalDriveStrings (initial_size
, ptr
);
5062 if (size
> initial_size
) {
5065 ptr
= g_malloc0 ((size
+ 1) * sizeof (gunichar2
));
5066 initial_size
= size
;
5080 result
= mono_array_new (domain
, mono_defaults
.string_class
, ndrives
);
5083 u8
= g_utf16_to_utf8 (dname
, -1, NULL
, NULL
, NULL
);
5084 drivestr
= mono_string_new (domain
, u8
);
5086 mono_array_set (result
, gpointer
, ndrives
++, drivestr
);
5097 ves_icall_System_Environment_InternalGetHome (void)
5099 MONO_ARCH_SAVE_REGS
;
5101 return mono_string_new (mono_domain_get (), g_get_home_dir ());
5104 static const char *encodings
[] = {
5106 "ascii", "us_ascii", "us", "ansi_x3.4_1968",
5107 "ansi_x3.4_1986", "cp367", "csascii", "ibm367",
5108 "iso_ir_6", "iso646_us", "iso_646.irv:1991",
5110 "utf_7", "csunicode11utf7", "unicode_1_1_utf_7",
5111 "unicode_2_0_utf_7", "x_unicode_1_1_utf_7",
5112 "x_unicode_2_0_utf_7",
5114 "utf_8", "unicode_1_1_utf_8", "unicode_2_0_utf_8",
5115 "x_unicode_1_1_utf_8", "x_unicode_2_0_utf_8",
5117 "utf_16", "UTF_16LE", "ucs_2", "unicode",
5120 "unicodefffe", "utf_16be",
5127 * Returns the internal codepage, if the value of "int_code_page" is
5128 * 1 at entry, and we can not compute a suitable code page number,
5129 * returns the code page as a string
5132 ves_icall_System_Text_Encoding_InternalCodePage (gint32
*int_code_page
)
5137 char *codepage
= NULL
;
5139 int want_name
= *int_code_page
;
5142 *int_code_page
= -1;
5143 MONO_ARCH_SAVE_REGS
;
5145 g_get_charset (&cset
);
5146 c
= codepage
= strdup (cset
);
5147 for (c
= codepage
; *c
; c
++){
5148 if (isascii (*c
) && isalpha (*c
))
5153 /* g_print ("charset: %s\n", cset); */
5155 /* handle some common aliases */
5158 for (i
= 0; p
!= 0; ){
5159 if ((gssize
) p
< 7){
5161 p
= encodings
[++i
];
5164 if (strcmp (p
, codepage
) == 0){
5165 *int_code_page
= code
;
5168 p
= encodings
[++i
];
5171 if (strstr (codepage
, "utf_8") != NULL
)
5172 *int_code_page
|= 0x10000000;
5175 if (want_name
&& *int_code_page
== -1)
5176 return mono_string_new (mono_domain_get (), cset
);
5182 ves_icall_System_Environment_get_HasShutdownStarted (void)
5184 if (mono_runtime_is_shutting_down ())
5187 if (mono_domain_is_unloading (mono_domain_get ()))
5194 ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage
*this,
5195 MonoReflectionMethod
*method
,
5196 MonoArray
*out_args
)
5198 MONO_ARCH_SAVE_REGS
;
5200 mono_message_init (mono_object_domain (this), this, method
, out_args
);
5204 ves_icall_IsTransparentProxy (MonoObject
*proxy
)
5206 MONO_ARCH_SAVE_REGS
;
5211 if (proxy
->vtable
->klass
== mono_defaults
.transparent_proxy_class
)
5218 ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionType
*type
, MonoBoolean enable
)
5223 MONO_ARCH_SAVE_REGS
;
5225 klass
= mono_class_from_mono_type (type
->type
);
5226 vtable
= mono_class_vtable (mono_domain_get (), klass
);
5228 if (enable
) vtable
->remote
= 1;
5229 else vtable
->remote
= 0;
5233 ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance (MonoReflectionType
*type
)
5238 MONO_ARCH_SAVE_REGS
;
5240 domain
= mono_object_domain (type
);
5241 klass
= mono_class_from_mono_type (type
->type
);
5243 if (klass
->rank
>= 1) {
5244 g_assert (klass
->rank
== 1);
5245 return (MonoObject
*) mono_array_new (domain
, klass
->element_class
, 0);
5247 /* Bypass remoting object creation check */
5248 return mono_object_new_alloc_specific (mono_class_vtable (domain
, klass
));
5253 ves_icall_System_IO_get_temp_path (void)
5255 MONO_ARCH_SAVE_REGS
;
5257 return mono_string_new (mono_domain_get (), g_get_tmp_dir ());
5261 ves_icall_RuntimeMethod_GetFunctionPointer (MonoMethod
*method
)
5263 MONO_ARCH_SAVE_REGS
;
5265 return mono_compile_method (method
);
5269 ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
5274 MONO_ARCH_SAVE_REGS
;
5276 path
= g_build_path (G_DIR_SEPARATOR_S
, mono_get_config_dir (), "mono", mono_get_framework_version (), "machine.config", NULL
);
5278 #if defined (PLATFORM_WIN32)
5279 /* Avoid mixing '/' and '\\' */
5282 for (i
= strlen (path
) - 1; i
>= 0; i
--)
5283 if (path
[i
] == '/')
5287 mcpath
= mono_string_new (mono_domain_get (), path
);
5294 ves_icall_System_Web_Util_ICalls_get_machine_install_dir (void)
5299 MONO_ARCH_SAVE_REGS
;
5301 path
= g_path_get_dirname (mono_get_config_dir ());
5303 #if defined (PLATFORM_WIN32)
5304 /* Avoid mixing '/' and '\\' */
5307 for (i
= strlen (path
) - 1; i
>= 0; i
--)
5308 if (path
[i
] == '/')
5312 ipath
= mono_string_new (mono_domain_get (), path
);
5319 ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString (MonoString
*message
)
5321 #if defined (PLATFORM_WIN32)
5322 static void (*output_debug
) (gchar
*);
5323 static gboolean tried_loading
= FALSE
;
5325 MONO_ARCH_SAVE_REGS
;
5327 if (!tried_loading
&& output_debug
== NULL
) {
5330 tried_loading
= TRUE
;
5331 k32
= g_module_open ("kernel32", G_MODULE_BIND_LAZY
);
5333 gchar
*error
= g_strdup (g_module_error ());
5334 g_warning ("Failed to load kernel32.dll: %s\n", error
);
5339 g_module_symbol (k32
, "OutputDebugStringW", (gpointer
*) &output_debug
);
5340 if (!output_debug
) {
5341 gchar
*error
= g_strdup (g_module_error ());
5342 g_warning ("Failed to load OutputDebugStringW: %s\n", error
);
5348 if (output_debug
== NULL
)
5351 output_debug (mono_string_chars (message
));
5353 g_warning ("WriteWindowsDebugString called and PLATFORM_WIN32 not defined!\n");
5357 /* Only used for value types */
5359 ves_icall_System_Activator_CreateInstanceInternal (MonoReflectionType
*type
)
5364 MONO_ARCH_SAVE_REGS
;
5366 domain
= mono_object_domain (type
);
5367 klass
= mono_class_from_mono_type (type
->type
);
5369 return mono_object_new (domain
, klass
);
5372 static MonoReflectionMethod
*
5373 ves_icall_MonoMethod_get_base_definition (MonoReflectionMethod
*m
)
5376 MonoMethod
*method
= m
->method
;
5377 MonoMethod
*result
= NULL
;
5379 MONO_ARCH_SAVE_REGS
;
5381 if (!(method
->flags
& METHOD_ATTRIBUTE_VIRTUAL
) ||
5382 MONO_CLASS_IS_INTERFACE (method
->klass
) ||
5383 method
->flags
& METHOD_ATTRIBUTE_NEW_SLOT
)
5386 if (method
->klass
== NULL
|| (klass
= method
->klass
->parent
) == NULL
)
5389 if (klass
->generic_class
)
5390 klass
= mono_class_from_mono_type (klass
->generic_class
->generic_type
);
5392 while (result
== NULL
&& klass
!= NULL
&& (klass
->vtable_size
> method
->slot
))
5394 result
= klass
->vtable
[method
->slot
];
5395 if (result
== NULL
) {
5396 /* It is an abstract method */
5398 for (i
=0; i
<klass
->method
.count
; i
++) {
5399 if (klass
->methods
[i
]->slot
== method
->slot
) {
5400 result
= klass
->methods
[i
];
5405 klass
= klass
->parent
;
5411 return mono_method_get_object (mono_domain_get (), result
, NULL
);
5415 mono_ArgIterator_Setup (MonoArgIterator
*iter
, char* argsp
, char* start
)
5417 MONO_ARCH_SAVE_REGS
;
5419 iter
->sig
= *(MonoMethodSignature
**)argsp
;
5421 g_assert (iter
->sig
->sentinelpos
<= iter
->sig
->param_count
);
5422 g_assert (iter
->sig
->call_convention
== MONO_CALL_VARARG
);
5425 /* FIXME: it's not documented what start is exactly... */
5429 int i
, align
, arg_size
;
5430 iter
->args
= argsp
+ sizeof (gpointer
);
5431 #ifndef MONO_ARCH_REGPARMS
5432 for (i
= 0; i
< iter
->sig
->sentinelpos
; ++i
) {
5433 arg_size
= mono_type_stack_size (iter
->sig
->params
[i
], &align
);
5434 iter
->args
= (char*)iter
->args
+ arg_size
;
5438 iter
->num_args
= iter
->sig
->param_count
- iter
->sig
->sentinelpos
;
5440 /* g_print ("sig %p, param_count: %d, sent: %d\n", iter->sig, iter->sig->param_count, iter->sig->sentinelpos); */
5444 mono_ArgIterator_IntGetNextArg (MonoArgIterator
*iter
)
5446 gint i
, align
, arg_size
;
5448 MONO_ARCH_SAVE_REGS
;
5450 i
= iter
->sig
->sentinelpos
+ iter
->next_arg
;
5452 g_assert (i
< iter
->sig
->param_count
);
5454 res
.type
= iter
->sig
->params
[i
];
5455 res
.klass
= mono_class_from_mono_type (res
.type
);
5456 /* FIXME: endianess issue... */
5457 res
.value
= iter
->args
;
5458 arg_size
= mono_type_stack_size (res
.type
, &align
);
5459 iter
->args
= (char*)iter
->args
+ arg_size
;
5462 /* g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value); */
5468 mono_ArgIterator_IntGetNextArgT (MonoArgIterator
*iter
, MonoType
*type
)
5470 gint i
, align
, arg_size
;
5472 MONO_ARCH_SAVE_REGS
;
5474 i
= iter
->sig
->sentinelpos
+ iter
->next_arg
;
5476 g_assert (i
< iter
->sig
->param_count
);
5478 while (i
< iter
->sig
->param_count
) {
5479 if (!mono_metadata_type_equal (type
, iter
->sig
->params
[i
]))
5481 res
.type
= iter
->sig
->params
[i
];
5482 res
.klass
= mono_class_from_mono_type (res
.type
);
5483 /* FIXME: endianess issue... */
5484 res
.value
= iter
->args
;
5485 arg_size
= mono_type_stack_size (res
.type
, &align
);
5486 iter
->args
= (char*)iter
->args
+ arg_size
;
5488 /* g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value); */
5491 /* g_print ("arg type 0x%02x not found\n", res.type->type); */
5500 mono_ArgIterator_IntGetNextArgType (MonoArgIterator
*iter
)
5503 MONO_ARCH_SAVE_REGS
;
5505 i
= iter
->sig
->sentinelpos
+ iter
->next_arg
;
5507 g_assert (i
< iter
->sig
->param_count
);
5509 return iter
->sig
->params
[i
];
5513 mono_TypedReference_ToObject (MonoTypedRef tref
)
5515 MONO_ARCH_SAVE_REGS
;
5517 if (MONO_TYPE_IS_REFERENCE (tref
.type
)) {
5518 MonoObject
** objp
= tref
.value
;
5522 return mono_value_box (mono_domain_get (), tref
.klass
, tref
.value
);
5526 mono_TypedReference_ToObjectInternal (MonoType
*type
, gpointer value
, MonoClass
*klass
)
5528 MONO_ARCH_SAVE_REGS
;
5530 if (MONO_TYPE_IS_REFERENCE (type
)) {
5531 MonoObject
** objp
= value
;
5535 return mono_value_box (mono_domain_get (), klass
, value
);
5539 prelink_method (MonoMethod
*method
)
5541 const char *exc_class
, *exc_arg
;
5542 if (!(method
->flags
& METHOD_ATTRIBUTE_PINVOKE_IMPL
))
5544 mono_lookup_pinvoke_call (method
, &exc_class
, &exc_arg
);
5546 mono_raise_exception(
5547 mono_exception_from_name_msg (mono_defaults
.corlib
, "System", exc_class
, exc_arg
) );
5549 /* create the wrapper, too? */
5553 ves_icall_System_Runtime_InteropServices_Marshal_Prelink (MonoReflectionMethod
*method
)
5555 MONO_ARCH_SAVE_REGS
;
5556 prelink_method (method
->method
);
5560 ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionType
*type
)
5562 MonoClass
*klass
= mono_class_from_mono_type (type
->type
);
5564 MONO_ARCH_SAVE_REGS
;
5566 mono_class_init (klass
);
5567 for (i
= 0; i
< klass
->method
.count
; ++i
)
5568 prelink_method (klass
->methods
[i
]);
5571 /* These parameters are "readonly" in corlib/System/Char.cs */
5573 ves_icall_System_Char_GetDataTablePointers (guint8
const **category_data
,
5574 guint8
const **numeric_data
,
5575 gdouble
const **numeric_data_values
,
5576 guint16
const **to_lower_data_low
,
5577 guint16
const **to_lower_data_high
,
5578 guint16
const **to_upper_data_low
,
5579 guint16
const **to_upper_data_high
)
5581 *category_data
= CategoryData
;
5582 *numeric_data
= NumericData
;
5583 *numeric_data_values
= NumericDataValues
;
5584 *to_lower_data_low
= ToLowerDataLow
;
5585 *to_lower_data_high
= ToLowerDataHigh
;
5586 *to_upper_data_low
= ToUpperDataLow
;
5587 *to_upper_data_high
= ToUpperDataHigh
;
5591 ves_icall_MonoDebugger_check_runtime_version (MonoString
*fname
)
5593 gchar
*filename
, *error
= NULL
;
5595 MONO_ARCH_SAVE_REGS
;
5597 filename
= mono_string_to_utf8 (fname
);
5598 error
= mono_debugger_check_runtime_version (filename
);
5602 return mono_string_new (mono_domain_get (), error
);
5615 const IcallEntry
*icalls
;
5619 static const IcallEntry activator_icalls
[] = {
5620 {"CreateInstanceInternal", ves_icall_System_Activator_CreateInstanceInternal
}
5622 static const IcallEntry appdomain_icalls
[] = {
5623 {"ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly
},
5624 {"GetAssemblies", ves_icall_System_AppDomain_GetAssemblies
},
5625 {"GetData", ves_icall_System_AppDomain_GetData
},
5626 {"InternalGetContext", ves_icall_System_AppDomain_InternalGetContext
},
5627 {"InternalGetDefaultContext", ves_icall_System_AppDomain_InternalGetDefaultContext
},
5628 {"InternalGetProcessGuid", ves_icall_System_AppDomain_InternalGetProcessGuid
},
5629 {"InternalIsFinalizingForUnload", ves_icall_System_AppDomain_InternalIsFinalizingForUnload
},
5630 {"InternalPopDomainRef", ves_icall_System_AppDomain_InternalPopDomainRef
},
5631 {"InternalPushDomainRef", ves_icall_System_AppDomain_InternalPushDomainRef
},
5632 {"InternalPushDomainRefByID", ves_icall_System_AppDomain_InternalPushDomainRefByID
},
5633 {"InternalSetContext", ves_icall_System_AppDomain_InternalSetContext
},
5634 {"InternalSetDomain", ves_icall_System_AppDomain_InternalSetDomain
},
5635 {"InternalSetDomainByID", ves_icall_System_AppDomain_InternalSetDomainByID
},
5636 {"InternalUnload", ves_icall_System_AppDomain_InternalUnload
},
5637 {"LoadAssembly", ves_icall_System_AppDomain_LoadAssembly
},
5638 {"LoadAssemblyRaw", ves_icall_System_AppDomain_LoadAssemblyRaw
},
5639 {"SetData", ves_icall_System_AppDomain_SetData
},
5640 {"createDomain", ves_icall_System_AppDomain_createDomain
},
5641 {"getCurDomain", ves_icall_System_AppDomain_getCurDomain
},
5642 {"getDomainByID", ves_icall_System_AppDomain_getDomainByID
},
5643 {"getFriendlyName", ves_icall_System_AppDomain_getFriendlyName
},
5644 {"getSetup", ves_icall_System_AppDomain_getSetup
}
5647 static const IcallEntry argiterator_icalls
[] = {
5648 {"IntGetNextArg()", mono_ArgIterator_IntGetNextArg
},
5649 {"IntGetNextArg(intptr)", mono_ArgIterator_IntGetNextArgT
},
5650 {"IntGetNextArgType", mono_ArgIterator_IntGetNextArgType
},
5651 {"Setup", mono_ArgIterator_Setup
}
5654 static const IcallEntry array_icalls
[] = {
5655 {"ClearInternal", ves_icall_System_Array_ClearInternal
},
5656 {"Clone", mono_array_clone
},
5657 {"CreateInstanceImpl", ves_icall_System_Array_CreateInstanceImpl
},
5658 {"FastCopy", ves_icall_System_Array_FastCopy
},
5659 {"GetLength", ves_icall_System_Array_GetLength
},
5660 {"GetLowerBound", ves_icall_System_Array_GetLowerBound
},
5661 {"GetRank", ves_icall_System_Array_GetRank
},
5662 {"GetValue", ves_icall_System_Array_GetValue
},
5663 {"GetValueImpl", ves_icall_System_Array_GetValueImpl
},
5664 {"SetValue", ves_icall_System_Array_SetValue
},
5665 {"SetValueImpl", ves_icall_System_Array_SetValueImpl
}
5668 static const IcallEntry buffer_icalls
[] = {
5669 {"BlockCopyInternal", ves_icall_System_Buffer_BlockCopyInternal
},
5670 {"ByteLengthInternal", ves_icall_System_Buffer_ByteLengthInternal
},
5671 {"GetByteInternal", ves_icall_System_Buffer_GetByteInternal
},
5672 {"SetByteInternal", ves_icall_System_Buffer_SetByteInternal
}
5675 static const IcallEntry char_icalls
[] = {
5676 {"GetDataTablePointers", ves_icall_System_Char_GetDataTablePointers
},
5677 {"InternalToLower(char,System.Globalization.CultureInfo)", ves_icall_System_Char_InternalToLower_Comp
},
5678 {"InternalToUpper(char,System.Globalization.CultureInfo)", ves_icall_System_Char_InternalToUpper_Comp
}
5681 static const IcallEntry defaultconf_icalls
[] = {
5682 {"get_machine_config_path", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path
}
5685 static const IcallEntry timezone_icalls
[] = {
5686 {"GetTimeZoneData", ves_icall_System_CurrentTimeZone_GetTimeZoneData
}
5689 static const IcallEntry datetime_icalls
[] = {
5690 {"GetNow", ves_icall_System_DateTime_GetNow
}
5693 #ifndef DISABLE_DECIMAL
5694 static const IcallEntry decimal_icalls
[] = {
5695 {"decimal2Int64", mono_decimal2Int64
},
5696 {"decimal2UInt64", mono_decimal2UInt64
},
5697 {"decimal2double", mono_decimal2double
},
5698 {"decimal2string", mono_decimal2string
},
5699 {"decimalCompare", mono_decimalCompare
},
5700 {"decimalDiv", mono_decimalDiv
},
5701 {"decimalFloorAndTrunc", mono_decimalFloorAndTrunc
},
5702 {"decimalIncr", mono_decimalIncr
},
5703 {"decimalIntDiv", mono_decimalIntDiv
},
5704 {"decimalMult", mono_decimalMult
},
5705 {"decimalRound", mono_decimalRound
},
5706 {"decimalSetExponent", mono_decimalSetExponent
},
5707 {"double2decimal", mono_double2decimal
}, /* FIXME: wrong signature. */
5708 {"string2decimal", mono_string2decimal
}
5712 static const IcallEntry delegate_icalls
[] = {
5713 {"CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal
},
5714 {"FreeTrampoline", ves_icall_System_Delegate_FreeTrampoline
}
5717 static const IcallEntry tracelist_icalls
[] = {
5718 {"WriteWindowsDebugString", ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString
}
5721 static const IcallEntry fileversion_icalls
[] = {
5722 {"GetVersionInfo_internal(string)", ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal
}
5725 static const IcallEntry process_icalls
[] = {
5726 {"ExitCode_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitCode_internal
},
5727 {"ExitTime_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitTime_internal
},
5728 {"GetModules_internal()", ves_icall_System_Diagnostics_Process_GetModules_internal
},
5729 {"GetPid_internal()", ves_icall_System_Diagnostics_Process_GetPid_internal
},
5730 {"GetProcess_internal(int)", ves_icall_System_Diagnostics_Process_GetProcess_internal
},
5731 {"GetProcesses_internal()", ves_icall_System_Diagnostics_Process_GetProcesses_internal
},
5732 {"GetWorkingSet_internal(intptr,int&,int&)", ves_icall_System_Diagnostics_Process_GetWorkingSet_internal
},
5733 {"Kill_internal", ves_icall_System_Diagnostics_Process_Kill_internal
},
5734 {"ProcessName_internal(intptr)", ves_icall_System_Diagnostics_Process_ProcessName_internal
},
5735 {"Process_free_internal(intptr)", ves_icall_System_Diagnostics_Process_Process_free_internal
},
5736 {"SetWorkingSet_internal(intptr,int,int,bool)", ves_icall_System_Diagnostics_Process_SetWorkingSet_internal
},
5737 {"StartTime_internal(intptr)", ves_icall_System_Diagnostics_Process_StartTime_internal
},
5738 {"Start_internal(string,string,string,intptr,intptr,intptr,System.Diagnostics.Process/ProcInfo&)", ves_icall_System_Diagnostics_Process_Start_internal
},
5739 {"WaitForExit_internal(intptr,int)", ves_icall_System_Diagnostics_Process_WaitForExit_internal
}
5742 static const IcallEntry double_icalls
[] = {
5743 {"AssertEndianity", ves_icall_System_Double_AssertEndianity
},
5744 {"ParseImpl", mono_double_ParseImpl
}
5747 static const IcallEntry enum_icalls
[] = {
5748 {"ToObject", ves_icall_System_Enum_ToObject
},
5749 {"get_value", ves_icall_System_Enum_get_value
}
5752 static const IcallEntry environment_icalls
[] = {
5753 {"Exit", ves_icall_System_Environment_Exit
},
5754 {"GetCommandLineArgs", mono_runtime_get_main_args
},
5755 {"GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable
},
5756 {"GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames
},
5757 {"GetLogicalDrivesInternal", ves_icall_System_Environment_GetLogicalDrives
},
5758 {"GetMachineConfigPath", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path
},
5759 {"GetOSVersionString", ves_icall_System_Environment_GetOSVersionString
},
5760 {"GetWindowsFolderPath", ves_icall_System_Environment_GetWindowsFolderPath
},
5761 {"get_ExitCode", mono_environment_exitcode_get
},
5762 {"get_HasShutdownStarted", ves_icall_System_Environment_get_HasShutdownStarted
},
5763 {"get_MachineName", ves_icall_System_Environment_get_MachineName
},
5764 {"get_NewLine", ves_icall_System_Environment_get_NewLine
},
5765 {"get_Platform", ves_icall_System_Environment_get_Platform
},
5766 {"get_TickCount", ves_icall_System_Environment_get_TickCount
},
5767 {"get_UserName", ves_icall_System_Environment_get_UserName
},
5768 {"internalGetGacPath", ves_icall_System_Environment_GetGacPath
},
5769 {"internalGetHome", ves_icall_System_Environment_InternalGetHome
},
5770 {"set_ExitCode", mono_environment_exitcode_set
}
5773 static const IcallEntry cultureinfo_icalls
[] = {
5774 {"construct_compareinfo(object,string)", ves_icall_System_Globalization_CompareInfo_construct_compareinfo
},
5775 {"construct_datetime_format", ves_icall_System_Globalization_CultureInfo_construct_datetime_format
},
5776 {"construct_internal_locale(string)", ves_icall_System_Globalization_CultureInfo_construct_internal_locale
},
5777 {"construct_internal_locale_from_current_locale", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_current_locale
},
5778 {"construct_internal_locale_from_lcid", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_lcid
},
5779 {"construct_internal_locale_from_name", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_name
},
5780 {"construct_internal_locale_from_specific_name", ves_icall_System_Globalization_CultureInfo_construct_internal_locale_from_specific_name
},
5781 {"construct_number_format", ves_icall_System_Globalization_CultureInfo_construct_number_format
},
5782 {"internal_get_cultures", ves_icall_System_Globalization_CultureInfo_internal_get_cultures
},
5783 {"internal_is_lcid_neutral", ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral
}
5786 static const IcallEntry compareinfo_icalls
[] = {
5787 {"assign_sortkey(object,string,System.Globalization.CompareOptions)", ves_icall_System_Globalization_CompareInfo_assign_sortkey
},
5788 {"construct_compareinfo(string)", ves_icall_System_Globalization_CompareInfo_construct_compareinfo
},
5789 {"free_internal_collator()", ves_icall_System_Globalization_CompareInfo_free_internal_collator
},
5790 {"internal_compare(string,int,int,string,int,int,System.Globalization.CompareOptions)", ves_icall_System_Globalization_CompareInfo_internal_compare
},
5791 {"internal_index(string,int,int,char,System.Globalization.CompareOptions,bool)", ves_icall_System_Globalization_CompareInfo_internal_index_char
},
5792 {"internal_index(string,int,int,string,System.Globalization.CompareOptions,bool)", ves_icall_System_Globalization_CompareInfo_internal_index
}
5795 static const IcallEntry gc_icalls
[] = {
5796 {"GetTotalMemory", ves_icall_System_GC_GetTotalMemory
},
5797 {"InternalCollect", ves_icall_System_GC_InternalCollect
},
5798 {"KeepAlive", ves_icall_System_GC_KeepAlive
},
5799 {"ReRegisterForFinalize", ves_icall_System_GC_ReRegisterForFinalize
},
5800 {"SuppressFinalize", ves_icall_System_GC_SuppressFinalize
},
5801 {"WaitForPendingFinalizers", ves_icall_System_GC_WaitForPendingFinalizers
}
5804 static const IcallEntry famwatcher_icalls
[] = {
5805 {"InternalFAMNextEvent", ves_icall_System_IO_FAMW_InternalFAMNextEvent
}
5808 static const IcallEntry filewatcher_icalls
[] = {
5809 {"InternalCloseDirectory", ves_icall_System_IO_FSW_CloseDirectory
},
5810 {"InternalOpenDirectory", ves_icall_System_IO_FSW_OpenDirectory
},
5811 {"InternalReadDirectoryChanges", ves_icall_System_IO_FSW_ReadDirectoryChanges
},
5812 {"InternalSupportsFSW", ves_icall_System_IO_FSW_SupportsFSW
}
5815 static const IcallEntry path_icalls
[] = {
5816 {"get_temp_path", ves_icall_System_IO_get_temp_path
}
5819 static const IcallEntry monoio_icalls
[] = {
5820 {"BeginRead", ves_icall_System_IO_MonoIO_BeginRead
},
5821 {"BeginWrite", ves_icall_System_IO_MonoIO_BeginWrite
},
5822 {"Close(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Close
},
5823 {"CopyFile(string,string,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CopyFile
},
5824 {"CreateDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CreateDirectory
},
5825 {"CreatePipe(intptr&,intptr&)", ves_icall_System_IO_MonoIO_CreatePipe
},
5826 {"DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile
},
5827 {"FindClose(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindClose
},
5828 {"FindFirstFile(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindFirstFile
},
5829 {"FindNextFile(intptr,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindNextFile
},
5830 {"Flush(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Flush
},
5831 {"GetCurrentDirectory(System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetCurrentDirectory
},
5832 {"GetFileAttributes(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileAttributes
},
5833 {"GetFileStat(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileStat
},
5834 {"GetFileType(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileType
},
5835 {"GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength
},
5836 {"GetSupportsAsync", ves_icall_System_IO_MonoIO_GetSupportsAsync
},
5837 {"GetTempPath(string&)", ves_icall_System_IO_MonoIO_GetTempPath
},
5838 {"Lock(intptr,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Lock
},
5839 {"MoveFile(string,string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_MoveFile
},
5840 {"Open(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Open
},
5841 {"Read(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Read
},
5842 {"RemoveDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_RemoveDirectory
},
5843 {"Seek(intptr,long,System.IO.SeekOrigin,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Seek
},
5844 {"SetCurrentDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetCurrentDirectory
},
5845 {"SetFileAttributes(string,System.IO.FileAttributes,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileAttributes
},
5846 {"SetFileTime(intptr,long,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileTime
},
5847 {"SetLength(intptr,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetLength
},
5848 {"Unlock(intptr,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Unlock
},
5849 {"Write(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Write
},
5850 {"get_AltDirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar
},
5851 {"get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError
},
5852 {"get_ConsoleInput", ves_icall_System_IO_MonoIO_get_ConsoleInput
},
5853 {"get_ConsoleOutput", ves_icall_System_IO_MonoIO_get_ConsoleOutput
},
5854 {"get_DirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar
},
5855 {"get_InvalidPathChars", ves_icall_System_IO_MonoIO_get_InvalidPathChars
},
5856 {"get_PathSeparator", ves_icall_System_IO_MonoIO_get_PathSeparator
},
5857 {"get_VolumeSeparatorChar", ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar
}
5860 static const IcallEntry math_icalls
[] = {
5861 {"Acos", ves_icall_System_Math_Acos
},
5862 {"Asin", ves_icall_System_Math_Asin
},
5863 {"Atan", ves_icall_System_Math_Atan
},
5864 {"Atan2", ves_icall_System_Math_Atan2
},
5865 {"Cos", ves_icall_System_Math_Cos
},
5866 {"Cosh", ves_icall_System_Math_Cosh
},
5867 {"Exp", ves_icall_System_Math_Exp
},
5868 {"Floor", ves_icall_System_Math_Floor
},
5869 {"Log", ves_icall_System_Math_Log
},
5870 {"Log10", ves_icall_System_Math_Log10
},
5871 {"Pow", ves_icall_System_Math_Pow
},
5872 {"Round", ves_icall_System_Math_Round
},
5873 {"Round2", ves_icall_System_Math_Round2
},
5874 {"Sin", ves_icall_System_Math_Sin
},
5875 {"Sinh", ves_icall_System_Math_Sinh
},
5876 {"Sqrt", ves_icall_System_Math_Sqrt
},
5877 {"Tan", ves_icall_System_Math_Tan
},
5878 {"Tanh", ves_icall_System_Math_Tanh
}
5881 static const IcallEntry customattrs_icalls
[] = {
5882 {"GetCustomAttributesInternal", mono_reflection_get_custom_attrs
}
5885 static const IcallEntry enuminfo_icalls
[] = {
5886 {"get_enum_info", ves_icall_get_enum_info
}
5889 static const IcallEntry fieldinfo_icalls
[] = {
5890 {"GetUnmanagedMarshal", ves_icall_System_Reflection_FieldInfo_GetUnmanagedMarshal
},
5891 {"internal_from_handle", ves_icall_System_Reflection_FieldInfo_internal_from_handle
}
5894 static const IcallEntry memberinfo_icalls
[] = {
5895 {"get_MetadataToken", mono_reflection_get_token
}
5898 static const IcallEntry monotype_icalls
[] = {
5899 {"GetArrayRank", ves_icall_MonoType_GetArrayRank
},
5900 {"GetConstructors", ves_icall_Type_GetConstructors_internal
},
5901 {"GetConstructors_internal", ves_icall_Type_GetConstructors_internal
},
5902 {"GetElementType", ves_icall_MonoType_GetElementType
},
5903 {"GetEvents_internal", ves_icall_Type_GetEvents_internal
},
5904 {"GetField", ves_icall_Type_GetField
},
5905 {"GetFields_internal", ves_icall_Type_GetFields_internal
},
5906 {"GetGenericArguments", ves_icall_MonoType_GetGenericArguments
},
5907 {"GetInterfaces", ves_icall_Type_GetInterfaces
},
5908 {"GetMethodsByName", ves_icall_Type_GetMethodsByName
},
5909 {"GetNestedType", ves_icall_Type_GetNestedType
},
5910 {"GetNestedTypes", ves_icall_Type_GetNestedTypes
},
5911 {"GetPropertiesByName", ves_icall_Type_GetPropertiesByName
},
5912 {"InternalGetEvent", ves_icall_MonoType_GetEvent
},
5913 {"IsByRefImpl", ves_icall_type_isbyref
},
5914 {"IsPointerImpl", ves_icall_type_ispointer
},
5915 {"IsPrimitiveImpl", ves_icall_type_isprimitive
},
5916 {"getFullName", ves_icall_System_MonoType_getFullName
},
5917 {"get_Assembly", ves_icall_MonoType_get_Assembly
},
5918 {"get_BaseType", ves_icall_get_type_parent
},
5919 {"get_DeclaringMethod", ves_icall_MonoType_get_DeclaringMethod
},
5920 {"get_DeclaringType", ves_icall_MonoType_get_DeclaringType
},
5921 {"get_HasGenericArguments", ves_icall_MonoType_get_HasGenericArguments
},
5922 {"get_IsGenericParameter", ves_icall_MonoType_get_IsGenericParameter
},
5923 {"get_Module", ves_icall_MonoType_get_Module
},
5924 {"get_Name", ves_icall_MonoType_get_Name
},
5925 {"get_Namespace", ves_icall_MonoType_get_Namespace
},
5926 {"get_UnderlyingSystemType", ves_icall_MonoType_get_UnderlyingSystemType
},
5927 {"get_attributes", ves_icall_get_attributes
},
5928 {"type_from_obj", mono_type_type_from_obj
}
5931 static const IcallEntry assembly_icalls
[] = {
5932 {"FillName", ves_icall_System_Reflection_Assembly_FillName
},
5933 {"GetCallingAssembly", ves_icall_System_Reflection_Assembly_GetCallingAssembly
},
5934 {"GetEntryAssembly", ves_icall_System_Reflection_Assembly_GetEntryAssembly
},
5935 {"GetExecutingAssembly", ves_icall_System_Reflection_Assembly_GetExecutingAssembly
},
5936 {"GetFilesInternal", ves_icall_System_Reflection_Assembly_GetFilesInternal
},
5937 {"GetManifestResourceInfoInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal
},
5938 {"GetManifestResourceInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInternal
},
5939 {"GetManifestResourceNames", ves_icall_System_Reflection_Assembly_GetManifestResourceNames
},
5940 {"GetModulesInternal", ves_icall_System_Reflection_Assembly_GetModulesInternal
},
5941 {"GetNamespaces", ves_icall_System_Reflection_Assembly_GetNamespaces
},
5942 {"GetReferencedAssemblies", ves_icall_System_Reflection_Assembly_GetReferencedAssemblies
},
5943 {"GetTypes", ves_icall_System_Reflection_Assembly_GetTypes
},
5944 {"InternalGetAssemblyName", ves_icall_System_Reflection_Assembly_InternalGetAssemblyName
},
5945 {"InternalGetType", ves_icall_System_Reflection_Assembly_InternalGetType
},
5946 {"InternalImageRuntimeVersion", ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion
},
5947 {"LoadFrom", ves_icall_System_Reflection_Assembly_LoadFrom
},
5949 * Private icalls for the Mono Debugger
5951 {"MonoDebugger_CheckRuntimeVersion", ves_icall_MonoDebugger_check_runtime_version
},
5952 {"MonoDebugger_GetLocalTypeFromSignature", ves_icall_MonoDebugger_GetLocalTypeFromSignature
},
5953 {"MonoDebugger_GetMethod", ves_icall_MonoDebugger_GetMethod
},
5954 {"MonoDebugger_GetMethodToken", ves_icall_MonoDebugger_GetMethodToken
},
5955 {"MonoDebugger_GetType", ves_icall_MonoDebugger_GetType
},
5957 /* normal icalls again */
5958 {"get_EntryPoint", ves_icall_System_Reflection_Assembly_get_EntryPoint
},
5959 {"get_ManifestModule", ves_icall_System_Reflection_Assembly_get_ManifestModule
},
5960 {"get_MetadataToken", mono_reflection_get_token
},
5961 {"get_code_base", ves_icall_System_Reflection_Assembly_get_code_base
},
5962 {"get_global_assembly_cache", ves_icall_System_Reflection_Assembly_get_global_assembly_cache
},
5963 {"get_location", ves_icall_System_Reflection_Assembly_get_location
},
5964 {"load_with_partial_name", ves_icall_System_Reflection_Assembly_load_with_partial_name
}
5967 static const IcallEntry methodbase_icalls
[] = {
5968 {"GetCurrentMethod", ves_icall_GetCurrentMethod
},
5969 {"GetMethodBodyInternal", ves_icall_System_Reflection_MethodBase_GetMethodBodyInternal
},
5970 {"GetMethodFromHandleInternal", ves_icall_System_Reflection_MethodBase_GetMethodFromHandleInternal
}
5973 static const IcallEntry module_icalls
[] = {
5974 {"Close", ves_icall_System_Reflection_Module_Close
},
5975 {"GetGlobalType", ves_icall_System_Reflection_Module_GetGlobalType
},
5976 {"GetGuidInternal", ves_icall_System_Reflection_Module_GetGuidInternal
},
5977 {"GetPEKind", ves_icall_System_Reflection_Module_GetPEKind
},
5978 {"InternalGetTypes", ves_icall_System_Reflection_Module_InternalGetTypes
},
5979 {"ResolveFieldToken", ves_icall_System_Reflection_Module_ResolveFieldToken
},
5980 {"ResolveMemberToken", ves_icall_System_Reflection_Module_ResolveMemberToken
},
5981 {"ResolveMethodToken", ves_icall_System_Reflection_Module_ResolveMethodToken
},
5982 {"ResolveStringToken", ves_icall_System_Reflection_Module_ResolveStringToken
},
5983 {"ResolveTypeToken", ves_icall_System_Reflection_Module_ResolveTypeToken
},
5984 {"get_MetadataToken", mono_reflection_get_token
}
5987 static const IcallEntry monocmethod_icalls
[] = {
5988 {"GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition
},
5989 {"InternalInvoke", ves_icall_InternalInvoke
},
5990 {"get_Mono_IsInflatedMethod", ves_icall_MonoMethod_get_Mono_IsInflatedMethod
}
5993 static const IcallEntry monoeventinfo_icalls
[] = {
5994 {"get_event_info", ves_icall_get_event_info
}
5997 static const IcallEntry monofield_icalls
[] = {
5998 {"GetFieldOffset", ves_icall_MonoField_GetFieldOffset
},
5999 {"GetParentType", ves_icall_MonoField_GetParentType
},
6000 {"GetValueInternal", ves_icall_MonoField_GetValueInternal
},
6001 {"Mono_GetGenericFieldDefinition", ves_icall_MonoField_Mono_GetGenericFieldDefinition
},
6002 {"SetValueInternal", ves_icall_FieldInfo_SetValueInternal
}
6005 static const IcallEntry monogenericclass_icalls
[] = {
6006 {"GetConstructors_internal", ves_icall_MonoGenericClass_GetConstructors
},
6007 {"GetEvents_internal", ves_icall_MonoGenericClass_GetEvents
},
6008 {"GetFields_internal", ves_icall_MonoGenericClass_GetFields
},
6009 {"GetInterfaces_internal", ves_icall_MonoGenericClass_GetInterfaces
},
6010 {"GetMethods_internal", ves_icall_MonoGenericClass_GetMethods
},
6011 {"GetParentType", ves_icall_MonoGenericClass_GetParentType
},
6012 {"GetProperties_internal", ves_icall_MonoGenericClass_GetProperties
},
6013 {"initialize", mono_reflection_generic_class_initialize
}
6016 static const IcallEntry generictypeparambuilder_icalls
[] = {
6017 {"initialize", mono_reflection_initialize_generic_parameter
}
6020 static const IcallEntry monomethod_icalls
[] = {
6021 {"BindGenericParameters", mono_reflection_bind_generic_method_parameters
},
6022 {"GetDllImportAttribute", ves_icall_MonoMethod_GetDllImportAttribute
},
6023 {"GetGenericArguments", ves_icall_MonoMethod_GetGenericArguments
},
6024 {"GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition
},
6025 {"InternalInvoke", ves_icall_InternalInvoke
},
6026 {"get_HasGenericParameters", ves_icall_MonoMethod_get_HasGenericParameters
},
6027 {"get_IsGenericMethodDefinition", ves_icall_MonoMethod_get_IsGenericMethodDefinition
},
6028 {"get_Mono_IsInflatedMethod", ves_icall_MonoMethod_get_Mono_IsInflatedMethod
},
6029 {"get_base_definition", ves_icall_MonoMethod_get_base_definition
}
6032 static const IcallEntry monomethodinfo_icalls
[] = {
6033 {"get_method_info", ves_icall_get_method_info
},
6034 {"get_parameter_info", ves_icall_get_parameter_info
}
6037 static const IcallEntry monopropertyinfo_icalls
[] = {
6038 {"get_property_info", ves_icall_get_property_info
}
6041 static const IcallEntry parameterinfo_icalls
[] = {
6042 {"get_MetadataToken", mono_reflection_get_token
}
6045 static const IcallEntry dns_icalls
[] = {
6046 {"GetHostByAddr_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByAddr_internal
},
6047 {"GetHostByName_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByName_internal
},
6048 {"GetHostName_internal(string&)", ves_icall_System_Net_Dns_GetHostName_internal
}
6051 static const IcallEntry socket_icalls
[] = {
6052 {"Accept_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Accept_internal
},
6053 {"AsyncReceiveInternal", ves_icall_System_Net_Sockets_Socket_AsyncReceive
},
6054 {"AsyncSendInternal", ves_icall_System_Net_Sockets_Socket_AsyncSend
},
6055 {"Available_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Available_internal
},
6056 {"Bind_internal(intptr,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_Bind_internal
},
6057 {"Blocking_internal(intptr,bool,int&)", ves_icall_System_Net_Sockets_Socket_Blocking_internal
},
6058 {"Close_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_Close_internal
},
6059 {"Connect_internal(intptr,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_Connect_internal
},
6060 {"GetSocketOption_arr_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,byte[]&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal
},
6061 {"GetSocketOption_obj_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object&,int&)", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal
},
6062 {"GetSupportsAsync", ves_icall_System_IO_MonoIO_GetSupportsAsync
},
6063 {"Listen_internal(intptr,int,int&)", ves_icall_System_Net_Sockets_Socket_Listen_internal
},
6064 {"LocalEndPoint_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal
},
6065 {"Poll_internal", ves_icall_System_Net_Sockets_Socket_Poll_internal
},
6066 {"Receive_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&)", ves_icall_System_Net_Sockets_Socket_Receive_internal
},
6067 {"RecvFrom_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&)", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal
},
6068 {"RemoteEndPoint_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal
},
6069 {"Select_internal(System.Net.Sockets.Socket[]&,System.Net.Sockets.Socket[]&,System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal
},
6070 {"SendTo_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_SendTo_internal
},
6071 {"Send_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&)", ves_icall_System_Net_Sockets_Socket_Send_internal
},
6072 {"SetSocketOption_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object,byte[],int,int&)", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal
},
6073 {"Shutdown_internal(intptr,System.Net.Sockets.SocketShutdown,int&)", ves_icall_System_Net_Sockets_Socket_Shutdown_internal
},
6074 {"Socket_internal(System.Net.Sockets.AddressFamily,System.Net.Sockets.SocketType,System.Net.Sockets.ProtocolType,int&)", ves_icall_System_Net_Sockets_Socket_Socket_internal
},
6075 {"WSAIoctl(intptr,int,byte[],byte[],int&)", ves_icall_System_Net_Sockets_Socket_WSAIoctl
}
6078 static const IcallEntry socketex_icalls
[] = {
6079 {"WSAGetLastError_internal", ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal
}
6082 static const IcallEntry object_icalls
[] = {
6083 {"GetType", ves_icall_System_Object_GetType
},
6084 {"InternalGetHashCode", ves_icall_System_Object_GetHashCode
},
6085 {"MemberwiseClone", ves_icall_System_Object_MemberwiseClone
},
6086 {"obj_address", ves_icall_System_Object_obj_address
}
6089 static const IcallEntry assemblybuilder_icalls
[] = {
6090 {"InternalAddModule", mono_image_load_module
},
6091 {"basic_init", mono_image_basic_init
}
6094 static const IcallEntry customattrbuilder_icalls
[] = {
6095 {"GetBlob", mono_reflection_get_custom_attrs_blob
}
6098 static const IcallEntry dynamicmethod_icalls
[] = {
6099 {"create_dynamic_method", mono_reflection_create_dynamic_method
}
6102 static const IcallEntry methodbuilder_icalls
[] = {
6103 {"BindGenericParameters", mono_reflection_bind_generic_method_parameters
}
6106 static const IcallEntry modulebuilder_icalls
[] = {
6107 {"WriteToFile", ves_icall_ModuleBuilder_WriteToFile
},
6108 {"basic_init", mono_image_module_basic_init
},
6109 {"build_metadata", ves_icall_ModuleBuilder_build_metadata
},
6110 {"create_modified_type", ves_icall_ModuleBuilder_create_modified_type
},
6111 {"getMethodToken", ves_icall_ModuleBuilder_getMethodToken
},
6112 {"getToken", ves_icall_ModuleBuilder_getToken
},
6113 {"getUSIndex", mono_image_insert_string
}
6116 static const IcallEntry signaturehelper_icalls
[] = {
6117 {"get_signature_field", mono_reflection_sighelper_get_signature_field
},
6118 {"get_signature_local", mono_reflection_sighelper_get_signature_local
}
6121 static const IcallEntry typebuilder_icalls
[] = {
6122 {"create_generic_class", mono_reflection_create_generic_class
},
6123 {"create_internal_class", mono_reflection_create_internal_class
},
6124 {"create_runtime_class", mono_reflection_create_runtime_class
},
6125 {"get_IsGenericParameter", ves_icall_TypeBuilder_get_IsGenericParameter
},
6126 {"get_event_info", mono_reflection_event_builder_get_event_info
},
6127 {"setup_generic_class", mono_reflection_setup_generic_class
},
6128 {"setup_internal_class", mono_reflection_setup_internal_class
}
6131 static const IcallEntry enumbuilder_icalls
[] = {
6132 {"setup_enum_type", ves_icall_EnumBuilder_setup_enum_type
}
6135 static const IcallEntry runtimehelpers_icalls
[] = {
6136 {"GetObjectValue", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue
},
6137 /* REMOVEME: no longer needed, just so we dont break things when not needed */
6138 {"GetOffsetToStringData", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData
},
6139 {"InitializeArray", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray
},
6140 {"RunClassConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor
},
6141 {"get_OffsetToStringData", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData
}
6144 static const IcallEntry gchandle_icalls
[] = {
6145 {"FreeHandle", ves_icall_System_GCHandle_FreeHandle
},
6146 {"GetAddrOfPinnedObject", ves_icall_System_GCHandle_GetAddrOfPinnedObject
},
6147 {"GetTarget", ves_icall_System_GCHandle_GetTarget
},
6148 {"GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle
}
6151 static const IcallEntry marshal_icalls
[] = {
6152 {"AllocCoTaskMem", ves_icall_System_Runtime_InteropServices_Marshal_AllocCoTaskMem
},
6153 {"AllocHGlobal", ves_icall_System_Runtime_InteropServices_Marshal_AllocHGlobal
},
6154 {"DestroyStructure", ves_icall_System_Runtime_InteropServices_Marshal_DestroyStructure
},
6155 {"FreeCoTaskMem", ves_icall_System_Runtime_InteropServices_Marshal_FreeCoTaskMem
},
6156 {"FreeHGlobal", ves_icall_System_Runtime_InteropServices_Marshal_FreeHGlobal
},
6157 {"GetDelegateForFunctionPointerInternal", ves_icall_System_Runtime_InteropServices_Marshal_GetDelegateForFunctionPointerInternal
},
6158 {"GetFunctionPointerForDelegateInternal", mono_delegate_to_ftnptr
},
6159 {"GetLastWin32Error", ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error
},
6160 {"OffsetOf", ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf
},
6161 {"Prelink", ves_icall_System_Runtime_InteropServices_Marshal_Prelink
},
6162 {"PrelinkAll", ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll
},
6163 {"PtrToStringAnsi(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi
},
6164 {"PtrToStringAnsi(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len
},
6165 {"PtrToStringAuto(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi
},
6166 {"PtrToStringAuto(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len
},
6167 {"PtrToStringBSTR", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR
},
6168 {"PtrToStringUni(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni
},
6169 {"PtrToStringUni(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni_len
},
6170 {"PtrToStructure(intptr,System.Type)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type
},
6171 {"PtrToStructure(intptr,object)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure
},
6172 {"ReAllocHGlobal", mono_marshal_realloc
},
6173 {"ReadByte", ves_icall_System_Runtime_InteropServices_Marshal_ReadByte
},
6174 {"ReadInt16", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt16
},
6175 {"ReadInt32", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt32
},
6176 {"ReadInt64", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt64
},
6177 {"ReadIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr
},
6178 {"SizeOf", ves_icall_System_Runtime_InteropServices_Marshal_SizeOf
},
6179 {"StringToHGlobalAnsi", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi
},
6180 {"StringToHGlobalAuto", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi
},
6181 {"StringToHGlobalUni", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni
},
6182 {"StructureToPtr", ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr
},
6183 {"UnsafeAddrOfPinnedArrayElement", ves_icall_System_Runtime_InteropServices_Marshal_UnsafeAddrOfPinnedArrayElement
},
6184 {"WriteByte", ves_icall_System_Runtime_InteropServices_Marshal_WriteByte
},
6185 {"WriteInt16", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt16
},
6186 {"WriteInt32", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt32
},
6187 {"WriteInt64", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt64
},
6188 {"WriteIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_WriteIntPtr
},
6189 {"copy_from_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_from_unmanaged
},
6190 {"copy_to_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_to_unmanaged
}
6193 static const IcallEntry activationservices_icalls
[] = {
6194 {"AllocateUninitializedClassInstance", ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance
},
6195 {"EnableProxyActivation", ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation
}
6198 static const IcallEntry monomethodmessage_icalls
[] = {
6199 {"InitMessage", ves_icall_MonoMethodMessage_InitMessage
}
6202 static const IcallEntry realproxy_icalls
[] = {
6203 {"InternalGetProxyType", ves_icall_Remoting_RealProxy_InternalGetProxyType
},
6204 {"InternalGetTransparentProxy", ves_icall_Remoting_RealProxy_GetTransparentProxy
}
6207 static const IcallEntry remotingservices_icalls
[] = {
6208 {"InternalExecute", ves_icall_InternalExecute
},
6209 {"IsTransparentProxy", ves_icall_IsTransparentProxy
}
6212 static const IcallEntry rng_icalls
[] = {
6213 {"RngClose", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngClose
},
6214 {"RngGetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngGetBytes
},
6215 {"RngInitialize", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_RngInitialize
}
6218 static const IcallEntry methodhandle_icalls
[] = {
6219 {"GetFunctionPointer", ves_icall_RuntimeMethod_GetFunctionPointer
}
6222 static const IcallEntry string_icalls
[] = {
6223 {".ctor(char*)", ves_icall_System_String_ctor_charp
},
6224 {".ctor(char*,int,int)", ves_icall_System_String_ctor_charp_int_int
},
6225 {".ctor(char,int)", ves_icall_System_String_ctor_char_int
},
6226 {".ctor(char[])", ves_icall_System_String_ctor_chara
},
6227 {".ctor(char[],int,int)", ves_icall_System_String_ctor_chara_int_int
},
6228 {".ctor(sbyte*)", ves_icall_System_String_ctor_sbytep
},
6229 {".ctor(sbyte*,int,int)", ves_icall_System_String_ctor_sbytep_int_int
},
6230 {".ctor(sbyte*,int,int,System.Text.Encoding)", ves_icall_System_String_ctor_encoding
},
6231 {"GetHashCode", ves_icall_System_String_GetHashCode
},
6232 {"InternalAllocateStr", ves_icall_System_String_InternalAllocateStr
},
6233 {"InternalCharCopy", ves_icall_System_String_InternalCharCopy
},
6234 {"InternalCopyTo", ves_icall_System_String_InternalCopyTo
},
6235 {"InternalIndexOfAny", ves_icall_System_String_InternalIndexOfAny
},
6236 {"InternalInsert", ves_icall_System_String_InternalInsert
},
6237 {"InternalIntern", ves_icall_System_String_InternalIntern
},
6238 {"InternalIsInterned", ves_icall_System_String_InternalIsInterned
},
6239 {"InternalJoin", ves_icall_System_String_InternalJoin
},
6240 {"InternalLastIndexOfAny", ves_icall_System_String_InternalLastIndexOfAny
},
6241 {"InternalPad", ves_icall_System_String_InternalPad
},
6242 {"InternalRemove", ves_icall_System_String_InternalRemove
},
6243 {"InternalReplace(char,char)", ves_icall_System_String_InternalReplace_Char
},
6244 {"InternalReplace(string,string,System.Globalization.CompareInfo)", ves_icall_System_String_InternalReplace_Str_Comp
},
6245 {"InternalSplit", ves_icall_System_String_InternalSplit
},
6246 {"InternalStrcpy(string,int,char[])", ves_icall_System_String_InternalStrcpy_Chars
},
6247 {"InternalStrcpy(string,int,char[],int,int)", ves_icall_System_String_InternalStrcpy_CharsN
},
6248 {"InternalStrcpy(string,int,string)", ves_icall_System_String_InternalStrcpy_Str
},
6249 {"InternalStrcpy(string,int,string,int,int)", ves_icall_System_String_InternalStrcpy_StrN
},
6250 {"InternalToLower(System.Globalization.CultureInfo)", ves_icall_System_String_InternalToLower_Comp
},
6251 {"InternalToUpper(System.Globalization.CultureInfo)", ves_icall_System_String_InternalToUpper_Comp
},
6252 {"InternalTrim", ves_icall_System_String_InternalTrim
},
6253 {"get_Chars", ves_icall_System_String_get_Chars
}
6256 static const IcallEntry encoding_icalls
[] = {
6257 {"InternalCodePage", ves_icall_System_Text_Encoding_InternalCodePage
}
6260 static const IcallEntry monitor_icalls
[] = {
6261 {"Monitor_exit", ves_icall_System_Threading_Monitor_Monitor_exit
},
6262 {"Monitor_pulse", ves_icall_System_Threading_Monitor_Monitor_pulse
},
6263 {"Monitor_pulse_all", ves_icall_System_Threading_Monitor_Monitor_pulse_all
},
6264 {"Monitor_test_owner", ves_icall_System_Threading_Monitor_Monitor_test_owner
},
6265 {"Monitor_test_synchronised", ves_icall_System_Threading_Monitor_Monitor_test_synchronised
},
6266 {"Monitor_try_enter", ves_icall_System_Threading_Monitor_Monitor_try_enter
},
6267 {"Monitor_wait", ves_icall_System_Threading_Monitor_Monitor_wait
}
6270 static const IcallEntry interlocked_icalls
[] = {
6271 {"CompareExchange(int&,int,int)", ves_icall_System_Threading_Interlocked_CompareExchange_Int
},
6272 {"CompareExchange(object&,object,object)", ves_icall_System_Threading_Interlocked_CompareExchange_Object
},
6273 {"CompareExchange(single&,single,single)", ves_icall_System_Threading_Interlocked_CompareExchange_Single
},
6274 {"Decrement(int&)", ves_icall_System_Threading_Interlocked_Decrement_Int
},
6275 {"Decrement(long&)", ves_icall_System_Threading_Interlocked_Decrement_Long
},
6276 {"Exchange(int&,int)", ves_icall_System_Threading_Interlocked_Exchange_Int
},
6277 {"Exchange(object&,object)", ves_icall_System_Threading_Interlocked_Exchange_Object
},
6278 {"Exchange(single&,single)", ves_icall_System_Threading_Interlocked_Exchange_Single
},
6279 {"Increment(int&)", ves_icall_System_Threading_Interlocked_Increment_Int
},
6280 {"Increment(long&)", ves_icall_System_Threading_Interlocked_Increment_Long
}
6283 static const IcallEntry mutex_icalls
[] = {
6284 {"CreateMutex_internal(bool,string,bool&)", ves_icall_System_Threading_Mutex_CreateMutex_internal
},
6285 {"ReleaseMutex_internal(intptr)", ves_icall_System_Threading_Mutex_ReleaseMutex_internal
}
6288 static const IcallEntry nativeevents_icalls
[] = {
6289 {"CloseEvent_internal", ves_icall_System_Threading_Events_CloseEvent_internal
},
6290 {"CreateEvent_internal", ves_icall_System_Threading_Events_CreateEvent_internal
},
6291 {"ResetEvent_internal", ves_icall_System_Threading_Events_ResetEvent_internal
},
6292 {"SetEvent_internal", ves_icall_System_Threading_Events_SetEvent_internal
}
6295 static const IcallEntry thread_icalls
[] = {
6296 {"Abort_internal(object)", ves_icall_System_Threading_Thread_Abort
},
6297 {"CurrentThread_internal", mono_thread_current
},
6298 {"GetCachedCurrentCulture", ves_icall_System_Threading_Thread_GetCachedCurrentCulture
},
6299 {"GetDomainID", ves_icall_System_Threading_Thread_GetDomainID
},
6300 {"GetName_internal", ves_icall_System_Threading_Thread_GetName_internal
},
6301 {"GetSerializedCurrentCulture", ves_icall_System_Threading_Thread_GetSerializedCurrentCulture
},
6302 {"Join_internal", ves_icall_System_Threading_Thread_Join_internal
},
6303 {"ResetAbort_internal()", ves_icall_System_Threading_Thread_ResetAbort
},
6304 {"Resume_internal()", ves_icall_System_Threading_Thread_Resume
},
6305 {"SetCachedCurrentCulture", ves_icall_System_Threading_Thread_SetCachedCurrentCulture
},
6306 {"SetName_internal", ves_icall_System_Threading_Thread_SetName_internal
},
6307 {"SetSerializedCurrentCulture", ves_icall_System_Threading_Thread_SetSerializedCurrentCulture
},
6308 {"Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal
},
6309 {"SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup
},
6310 {"SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store
},
6311 {"Start_internal", ves_icall_System_Threading_Thread_Start_internal
},
6312 {"Suspend_internal", ves_icall_System_Threading_Thread_Suspend
},
6313 {"Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal
},
6314 {"Thread_internal", ves_icall_System_Threading_Thread_Thread_internal
},
6315 {"VolatileRead(byte&)", ves_icall_System_Threading_Thread_VolatileRead1
},
6316 {"VolatileRead(double&)", ves_icall_System_Threading_Thread_VolatileRead8
},
6317 {"VolatileRead(int&)", ves_icall_System_Threading_Thread_VolatileRead4
},
6318 {"VolatileRead(int16&)", ves_icall_System_Threading_Thread_VolatileRead2
},
6319 {"VolatileRead(intptr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr
},
6320 {"VolatileRead(long&)", ves_icall_System_Threading_Thread_VolatileRead8
},
6321 {"VolatileRead(object&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr
},
6322 {"VolatileRead(sbyte&)", ves_icall_System_Threading_Thread_VolatileRead1
},
6323 {"VolatileRead(single&)", ves_icall_System_Threading_Thread_VolatileRead4
},
6324 {"VolatileRead(uint&)", ves_icall_System_Threading_Thread_VolatileRead2
},
6325 {"VolatileRead(uint16&)", ves_icall_System_Threading_Thread_VolatileRead2
},
6326 {"VolatileRead(uintptr&)", ves_icall_System_Threading_Thread_VolatileReadIntPtr
},
6327 {"VolatileRead(ulong&)", ves_icall_System_Threading_Thread_VolatileRead8
},
6328 {"VolatileWrite(byte&,byte)", ves_icall_System_Threading_Thread_VolatileWrite1
},
6329 {"VolatileWrite(double&,double)", ves_icall_System_Threading_Thread_VolatileWrite8
},
6330 {"VolatileWrite(int&,int)", ves_icall_System_Threading_Thread_VolatileWrite4
},
6331 {"VolatileWrite(int16&,int16)", ves_icall_System_Threading_Thread_VolatileWrite2
},
6332 {"VolatileWrite(intptr&,intptr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr
},
6333 {"VolatileWrite(long&,long)", ves_icall_System_Threading_Thread_VolatileWrite8
},
6334 {"VolatileWrite(object&,object)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr
},
6335 {"VolatileWrite(sbyte&,sbyte)", ves_icall_System_Threading_Thread_VolatileWrite1
},
6336 {"VolatileWrite(single&,single)", ves_icall_System_Threading_Thread_VolatileWrite4
},
6337 {"VolatileWrite(uint&,uint)", ves_icall_System_Threading_Thread_VolatileWrite2
},
6338 {"VolatileWrite(uint16&,uint16)", ves_icall_System_Threading_Thread_VolatileWrite2
},
6339 {"VolatileWrite(uintptr&,uintptr)", ves_icall_System_Threading_Thread_VolatileWriteIntPtr
},
6340 {"VolatileWrite(ulong&,ulong)", ves_icall_System_Threading_Thread_VolatileWrite8
},
6341 {"current_lcid()", ves_icall_System_Threading_Thread_current_lcid
}
6344 static const IcallEntry threadpool_icalls
[] = {
6345 {"BindHandleInternal", ves_icall_System_Threading_ThreadPool_BindHandle
},
6346 {"GetAvailableThreads", ves_icall_System_Threading_ThreadPool_GetAvailableThreads
},
6347 {"GetMaxThreads", ves_icall_System_Threading_ThreadPool_GetMaxThreads
},
6348 {"GetMinThreads", ves_icall_System_Threading_ThreadPool_GetMinThreads
},
6349 {"SetMinThreads", ves_icall_System_Threading_ThreadPool_SetMinThreads
}
6352 static const IcallEntry waithandle_icalls
[] = {
6353 {"WaitAll_internal", ves_icall_System_Threading_WaitHandle_WaitAll_internal
},
6354 {"WaitAny_internal", ves_icall_System_Threading_WaitHandle_WaitAny_internal
},
6355 {"WaitOne_internal", ves_icall_System_Threading_WaitHandle_WaitOne_internal
}
6358 static const IcallEntry type_icalls
[] = {
6359 {"BindGenericParameters", ves_icall_Type_BindGenericParameters
},
6360 {"Equals", ves_icall_type_Equals
},
6361 {"GetGenericParameterAttributes", ves_icall_Type_GetGenericParameterAttributes
},
6362 {"GetGenericParameterConstraints_impl", ves_icall_Type_GetGenericParameterConstraints
},
6363 {"GetGenericParameterPosition", ves_icall_Type_GetGenericParameterPosition
},
6364 {"GetGenericTypeDefinition_impl", ves_icall_Type_GetGenericTypeDefinition_impl
},
6365 {"GetInterfaceMapData", ves_icall_Type_GetInterfaceMapData
},
6366 {"GetPacking", ves_icall_Type_GetPacking
},
6367 {"GetTypeCode", ves_icall_type_GetTypeCode
},
6368 {"IsArrayImpl", ves_icall_Type_IsArrayImpl
},
6369 {"IsInstanceOfType", ves_icall_type_IsInstanceOfType
},
6370 {"MakePointerType", ves_icall_Type_MakePointerType
},
6371 {"get_IsGenericInstance", ves_icall_Type_get_IsGenericInstance
},
6372 {"get_IsGenericTypeDefinition", ves_icall_Type_get_IsGenericTypeDefinition
},
6373 {"internal_from_handle", ves_icall_type_from_handle
},
6374 {"internal_from_name", ves_icall_type_from_name
},
6375 {"make_array_type", ves_icall_Type_make_array_type
},
6376 {"make_byref_type", ves_icall_Type_make_byref_type
},
6377 {"type_is_assignable_from", ves_icall_type_is_assignable_from
},
6378 {"type_is_subtype_of", ves_icall_type_is_subtype_of
}
6381 static const IcallEntry typedref_icalls
[] = {
6382 {"ToObject", mono_TypedReference_ToObject
},
6383 {"ToObjectInternal", mono_TypedReference_ToObjectInternal
}
6386 static const IcallEntry valuetype_icalls
[] = {
6387 {"InternalEquals", ves_icall_System_ValueType_Equals
},
6388 {"InternalGetHashCode", ves_icall_System_ValueType_InternalGetHashCode
}
6391 static const IcallEntry web_icalls
[] = {
6392 {"GetMachineConfigPath", ves_icall_System_Configuration_DefaultConfig_get_machine_config_path
},
6393 {"GetMachineInstallDirectory", ves_icall_System_Web_Util_ICalls_get_machine_install_dir
}
6396 static const IcallEntry identity_icalls
[] = {
6397 {"GetCurrentToken", ves_icall_System_Security_Principal_WindowsIdentity_GetCurrentToken
},
6398 {"GetTokenName", ves_icall_System_Security_Principal_WindowsIdentity_GetTokenName
},
6399 {"GetUserToken", ves_icall_System_Security_Principal_WindowsIdentity_GetUserToken
},
6400 {"_GetRoles", ves_icall_System_Security_Principal_WindowsIdentity_GetRoles
}
6403 static const IcallEntry impersonation_icalls
[] = {
6404 {"CloseToken", ves_icall_System_Security_Principal_WindowsImpersonationContext_CloseToken
},
6405 {"DuplicateToken", ves_icall_System_Security_Principal_WindowsImpersonationContext_DuplicateToken
},
6406 {"RevertToSelf", ves_icall_System_Security_Principal_WindowsImpersonationContext_RevertToSelf
},
6407 {"SetCurrentToken", ves_icall_System_Security_Principal_WindowsImpersonationContext_SetCurrentToken
}
6410 static const IcallEntry principal_icalls
[] = {
6411 {"IsMemberOfGroupId", ves_icall_System_Security_Principal_WindowsPrincipal_IsMemberOfGroupId
},
6412 {"IsMemberOfGroupName", ves_icall_System_Security_Principal_WindowsPrincipal_IsMemberOfGroupName
}
6415 static const IcallEntry keypair_icalls
[] = {
6416 {"_CanSecure", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_CanSecure
},
6417 {"_IsMachineProtected", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_IsMachineProtected
},
6418 {"_IsUserProtected", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_IsUserProtected
},
6419 {"_ProtectMachine", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_ProtectMachine
},
6420 {"_ProtectUser", ves_icall_Mono_Security_Cryptography_KeyPairPersistence_ProtectUser
}
6423 static const IcallEntry evidence_icalls
[] = {
6424 {"IsAuthenticodePresent", ves_icall_System_Security_Policy_Evidence_IsAuthenticodePresent
}
6428 static const IcallEntry array_icalls [] = {
6433 /* keep the entries all sorted */
6434 static const IcallMap icall_entries
[] = {
6435 {"Mono.Security.Cryptography.KeyPairPersistence", keypair_icalls
, G_N_ELEMENTS (keypair_icalls
)},
6436 {"System.Activator", activator_icalls
, G_N_ELEMENTS (activator_icalls
)},
6437 {"System.AppDomain", appdomain_icalls
, G_N_ELEMENTS (appdomain_icalls
)},
6438 {"System.ArgIterator", argiterator_icalls
, G_N_ELEMENTS (argiterator_icalls
)},
6439 {"System.Array", array_icalls
, G_N_ELEMENTS (array_icalls
)},
6440 {"System.Buffer", buffer_icalls
, G_N_ELEMENTS (buffer_icalls
)},
6441 {"System.Char", char_icalls
, G_N_ELEMENTS (char_icalls
)},
6442 {"System.Configuration.DefaultConfig", defaultconf_icalls
, G_N_ELEMENTS (defaultconf_icalls
)},
6443 {"System.CurrentTimeZone", timezone_icalls
, G_N_ELEMENTS (timezone_icalls
)},
6444 {"System.DateTime", datetime_icalls
, G_N_ELEMENTS (datetime_icalls
)},
6445 #ifndef DISABLE_DECIMAL
6446 {"System.Decimal", decimal_icalls
, G_N_ELEMENTS (decimal_icalls
)},
6448 {"System.Delegate", delegate_icalls
, G_N_ELEMENTS (delegate_icalls
)},
6449 {"System.Diagnostics.DefaultTraceListener", tracelist_icalls
, G_N_ELEMENTS (tracelist_icalls
)},
6450 {"System.Diagnostics.FileVersionInfo", fileversion_icalls
, G_N_ELEMENTS (fileversion_icalls
)},
6451 {"System.Diagnostics.Process", process_icalls
, G_N_ELEMENTS (process_icalls
)},
6452 {"System.Double", double_icalls
, G_N_ELEMENTS (double_icalls
)},
6453 {"System.Enum", enum_icalls
, G_N_ELEMENTS (enum_icalls
)},
6454 {"System.Environment", environment_icalls
, G_N_ELEMENTS (environment_icalls
)},
6455 {"System.GC", gc_icalls
, G_N_ELEMENTS (gc_icalls
)},
6456 {"System.Globalization.CompareInfo", compareinfo_icalls
, G_N_ELEMENTS (compareinfo_icalls
)},
6457 {"System.Globalization.CultureInfo", cultureinfo_icalls
, G_N_ELEMENTS (cultureinfo_icalls
)},
6458 {"System.IO.FAMWatcher", famwatcher_icalls
, G_N_ELEMENTS (famwatcher_icalls
)},
6459 {"System.IO.FileSystemWatcher", filewatcher_icalls
, G_N_ELEMENTS (filewatcher_icalls
)},
6460 {"System.IO.MonoIO", monoio_icalls
, G_N_ELEMENTS (monoio_icalls
)},
6461 {"System.IO.Path", path_icalls
, G_N_ELEMENTS (path_icalls
)},
6462 {"System.Math", math_icalls
, G_N_ELEMENTS (math_icalls
)},
6463 {"System.MonoCustomAttrs", customattrs_icalls
, G_N_ELEMENTS (customattrs_icalls
)},
6464 {"System.MonoEnumInfo", enuminfo_icalls
, G_N_ELEMENTS (enuminfo_icalls
)},
6465 {"System.MonoType", monotype_icalls
, G_N_ELEMENTS (monotype_icalls
)},
6466 {"System.Net.Dns", dns_icalls
, G_N_ELEMENTS (dns_icalls
)},
6467 {"System.Net.Sockets.Socket", socket_icalls
, G_N_ELEMENTS (socket_icalls
)},
6468 {"System.Net.Sockets.SocketException", socketex_icalls
, G_N_ELEMENTS (socketex_icalls
)},
6469 {"System.Object", object_icalls
, G_N_ELEMENTS (object_icalls
)},
6470 {"System.Reflection.Assembly", assembly_icalls
, G_N_ELEMENTS (assembly_icalls
)},
6471 {"System.Reflection.Emit.AssemblyBuilder", assemblybuilder_icalls
, G_N_ELEMENTS (assemblybuilder_icalls
)},
6472 {"System.Reflection.Emit.CustomAttributeBuilder", customattrbuilder_icalls
, G_N_ELEMENTS (customattrbuilder_icalls
)},
6473 {"System.Reflection.Emit.DynamicMethod", dynamicmethod_icalls
, G_N_ELEMENTS (dynamicmethod_icalls
)},
6474 {"System.Reflection.Emit.EnumBuilder", enumbuilder_icalls
, G_N_ELEMENTS (enumbuilder_icalls
)},
6475 {"System.Reflection.Emit.GenericTypeParameterBuilder", generictypeparambuilder_icalls
, G_N_ELEMENTS (generictypeparambuilder_icalls
)},
6476 {"System.Reflection.Emit.MethodBuilder", methodbuilder_icalls
, G_N_ELEMENTS (methodbuilder_icalls
)},
6477 {"System.Reflection.Emit.ModuleBuilder", modulebuilder_icalls
, G_N_ELEMENTS (modulebuilder_icalls
)},
6478 {"System.Reflection.Emit.SignatureHelper", signaturehelper_icalls
, G_N_ELEMENTS (signaturehelper_icalls
)},
6479 {"System.Reflection.Emit.TypeBuilder", typebuilder_icalls
, G_N_ELEMENTS (typebuilder_icalls
)},
6480 {"System.Reflection.FieldInfo", fieldinfo_icalls
, G_N_ELEMENTS (fieldinfo_icalls
)},
6481 {"System.Reflection.MemberInfo", memberinfo_icalls
, G_N_ELEMENTS (memberinfo_icalls
)},
6482 {"System.Reflection.MethodBase", methodbase_icalls
, G_N_ELEMENTS (methodbase_icalls
)},
6483 {"System.Reflection.Module", module_icalls
, G_N_ELEMENTS (module_icalls
)},
6484 {"System.Reflection.MonoCMethod", monocmethod_icalls
, G_N_ELEMENTS (monocmethod_icalls
)},
6485 {"System.Reflection.MonoEventInfo", monoeventinfo_icalls
, G_N_ELEMENTS (monoeventinfo_icalls
)},
6486 {"System.Reflection.MonoField", monofield_icalls
, G_N_ELEMENTS (monofield_icalls
)},
6487 {"System.Reflection.MonoGenericClass", monogenericclass_icalls
, G_N_ELEMENTS (monogenericclass_icalls
)},
6488 {"System.Reflection.MonoMethod", monomethod_icalls
, G_N_ELEMENTS (monomethod_icalls
)},
6489 {"System.Reflection.MonoMethodInfo", monomethodinfo_icalls
, G_N_ELEMENTS (monomethodinfo_icalls
)},
6490 {"System.Reflection.MonoPropertyInfo", monopropertyinfo_icalls
, G_N_ELEMENTS (monopropertyinfo_icalls
)},
6491 {"System.Reflection.ParameterInfo", parameterinfo_icalls
, G_N_ELEMENTS (parameterinfo_icalls
)},
6492 {"System.Runtime.CompilerServices.RuntimeHelpers", runtimehelpers_icalls
, G_N_ELEMENTS (runtimehelpers_icalls
)},
6493 {"System.Runtime.InteropServices.GCHandle", gchandle_icalls
, G_N_ELEMENTS (gchandle_icalls
)},
6494 {"System.Runtime.InteropServices.Marshal", marshal_icalls
, G_N_ELEMENTS (marshal_icalls
)},
6495 {"System.Runtime.Remoting.Activation.ActivationServices", activationservices_icalls
, G_N_ELEMENTS (activationservices_icalls
)},
6496 {"System.Runtime.Remoting.Messaging.MonoMethodMessage", monomethodmessage_icalls
, G_N_ELEMENTS (monomethodmessage_icalls
)},
6497 {"System.Runtime.Remoting.Proxies.RealProxy", realproxy_icalls
, G_N_ELEMENTS (realproxy_icalls
)},
6498 {"System.Runtime.Remoting.RemotingServices", remotingservices_icalls
, G_N_ELEMENTS (remotingservices_icalls
)},
6499 {"System.RuntimeMethodHandle", methodhandle_icalls
, G_N_ELEMENTS (methodhandle_icalls
)},
6500 {"System.Security.Cryptography.RNGCryptoServiceProvider", rng_icalls
, G_N_ELEMENTS (rng_icalls
)},
6501 {"System.Security.Policy.Evidence", evidence_icalls
, G_N_ELEMENTS (evidence_icalls
)},
6502 {"System.Security.Principal.WindowsIdentity", identity_icalls
, G_N_ELEMENTS (identity_icalls
)},
6503 {"System.Security.Principal.WindowsImpersonationContext", impersonation_icalls
, G_N_ELEMENTS (impersonation_icalls
)},
6504 {"System.Security.Principal.WindowsPrincipal", principal_icalls
, G_N_ELEMENTS (principal_icalls
)},
6505 {"System.String", string_icalls
, G_N_ELEMENTS (string_icalls
)},
6506 {"System.Text.Encoding", encoding_icalls
, G_N_ELEMENTS (encoding_icalls
)},
6507 {"System.Threading.Interlocked", interlocked_icalls
, G_N_ELEMENTS (interlocked_icalls
)},
6508 {"System.Threading.Monitor", monitor_icalls
, G_N_ELEMENTS (monitor_icalls
)},
6509 {"System.Threading.Mutex", mutex_icalls
, G_N_ELEMENTS (mutex_icalls
)},
6510 {"System.Threading.NativeEventCalls", nativeevents_icalls
, G_N_ELEMENTS (nativeevents_icalls
)},
6511 {"System.Threading.Thread", thread_icalls
, G_N_ELEMENTS (thread_icalls
)},
6512 {"System.Threading.ThreadPool", threadpool_icalls
, G_N_ELEMENTS (threadpool_icalls
)},
6513 {"System.Threading.WaitHandle", waithandle_icalls
, G_N_ELEMENTS (waithandle_icalls
)},
6514 {"System.Type", type_icalls
, G_N_ELEMENTS (type_icalls
)},
6515 {"System.TypedReference", typedref_icalls
, G_N_ELEMENTS (typedref_icalls
)},
6516 {"System.ValueType", valuetype_icalls
, G_N_ELEMENTS (valuetype_icalls
)},
6517 {"System.Web.Util.ICalls", web_icalls
, G_N_ELEMENTS (web_icalls
)}
6520 static GHashTable
*icall_hash
= NULL
;
6521 static GHashTable
*jit_icall_hash_name
= NULL
;
6522 static GHashTable
*jit_icall_hash_addr
= NULL
;
6525 mono_init_icall (void)
6529 /* check that tables are sorted: disable in release */
6532 const IcallMap
*imap
;
6533 const IcallEntry
*ientry
;
6534 const char *prev_class
= NULL
;
6535 const char *prev_method
;
6537 for (i
= 0; i
< G_N_ELEMENTS (icall_entries
); ++i
) {
6538 imap
= &icall_entries
[i
];
6540 if (prev_class
&& strcmp (prev_class
, imap
->klass
) >= 0)
6541 g_print ("class %s should come before class %s\n", imap
->klass
, prev_class
);
6542 prev_class
= imap
->klass
;
6543 for (j
= 0; j
< imap
->size
; ++j
) {
6544 ientry
= &imap
->icalls
[j
];
6545 if (prev_method
&& strcmp (prev_method
, ientry
->method
) >= 0)
6546 g_print ("method %s should come before method %s\n", ientry
->method
, prev_method
);
6547 prev_method
= ientry
->method
;
6552 icall_hash
= g_hash_table_new (g_str_hash
, g_str_equal
);
6556 mono_add_internal_call (const char *name
, gconstpointer method
)
6558 mono_loader_lock ();
6560 g_hash_table_insert (icall_hash
, g_strdup (name
), (gpointer
) method
);
6562 mono_loader_unlock ();
6566 compare_class_imap (const void *key
, const void *elem
)
6568 const IcallMap
* imap
= (const IcallMap
*)elem
;
6569 return strcmp (key
, imap
->klass
);
6572 static const IcallMap
*
6573 find_class_icalls (const char *name
)
6575 return (const IcallMap
*) bsearch (name
, icall_entries
, G_N_ELEMENTS (icall_entries
), sizeof (IcallMap
), compare_class_imap
);
6579 compare_method_imap (const void *key
, const void *elem
)
6581 const IcallEntry
* ientry
= (const IcallEntry
*)elem
;
6582 return strcmp (key
, ientry
->method
);
6586 find_method_icall (const IcallMap
*imap
, const char *name
)
6588 const IcallEntry
*ientry
= (const IcallEntry
*) bsearch (name
, imap
->icalls
, imap
->size
, sizeof (IcallEntry
), compare_method_imap
);
6590 return (void*)ientry
->func
;
6595 * we should probably export this as an helper (handle nested types).
6596 * Returns the number of chars written in buf.
6599 concat_class_name (char *buf
, int bufsize
, MonoClass
*klass
)
6601 int nspacelen
, cnamelen
;
6602 nspacelen
= strlen (klass
->name_space
);
6603 cnamelen
= strlen (klass
->name
);
6604 if (nspacelen
+ cnamelen
+ 2 > bufsize
)
6607 memcpy (buf
, klass
->name_space
, nspacelen
);
6608 buf
[nspacelen
++] = '.';
6610 memcpy (buf
+ nspacelen
, klass
->name
, cnamelen
);
6611 buf
[nspacelen
+ cnamelen
] = 0;
6612 return nspacelen
+ cnamelen
;
6616 mono_lookup_internal_call (MonoMethod
*method
)
6621 int typelen
= 0, mlen
, siglen
;
6623 const IcallMap
*imap
;
6625 g_assert (method
!= NULL
);
6627 typelen
= concat_class_name (mname
, sizeof (mname
), method
->klass
);
6631 imap
= find_class_icalls (mname
);
6633 mname
[typelen
] = ':';
6634 mname
[typelen
+ 1] = ':';
6636 mlen
= strlen (method
->name
);
6637 memcpy (mname
+ typelen
+ 2, method
->name
, mlen
);
6638 sigstart
= mname
+ typelen
+ 2 + mlen
;
6641 tmpsig
= mono_signature_get_desc (method
->signature
, TRUE
);
6642 siglen
= strlen (tmpsig
);
6643 if (typelen
+ mlen
+ siglen
+ 6 > sizeof (mname
))
6646 memcpy (sigstart
+ 1, tmpsig
, siglen
);
6647 sigstart
[siglen
+ 1] = ')';
6648 sigstart
[siglen
+ 2] = 0;
6651 mono_loader_lock ();
6653 res
= g_hash_table_lookup (icall_hash
, mname
);
6655 mono_loader_unlock ();
6658 /* try without signature */
6660 res
= g_hash_table_lookup (icall_hash
, mname
);
6662 mono_loader_unlock ();
6666 /* it wasn't found in the static call tables */
6668 mono_loader_unlock ();
6671 res
= find_method_icall (imap
, sigstart
- mlen
);
6673 mono_loader_unlock ();
6676 /* try _with_ signature */
6678 res
= find_method_icall (imap
, sigstart
- mlen
);
6680 mono_loader_unlock ();
6684 g_warning ("cant resolve internal call to \"%s\" (tested without signature also)", mname
);
6685 g_print ("\nYour mono runtime and class libraries are out of sync.\n");
6686 g_print ("The out of sync library is: %s\n", method
->klass
->image
->name
);
6687 g_print ("\nWhen you update one from cvs you need to update, compile and install\nthe other too.\n");
6688 g_print ("Do not report this as a bug unless you're sure you have updated correctly:\nyou probably have a broken mono install.\n");
6689 g_print ("If you see other errors or faults after this message they are probably related\n");
6690 g_print ("and you need to fix your mono install first.\n");
6692 mono_loader_unlock ();
6698 type_from_typename (char *typename
)
6700 MonoClass
*klass
= NULL
; /* assignment to shut GCC warning up */
6702 if (!strcmp (typename
, "int"))
6703 klass
= mono_defaults
.int_class
;
6704 else if (!strcmp (typename
, "ptr"))
6705 klass
= mono_defaults
.int_class
;
6706 else if (!strcmp (typename
, "void"))
6707 klass
= mono_defaults
.void_class
;
6708 else if (!strcmp (typename
, "int32"))
6709 klass
= mono_defaults
.int32_class
;
6710 else if (!strcmp (typename
, "uint32"))
6711 klass
= mono_defaults
.uint32_class
;
6712 else if (!strcmp (typename
, "long"))
6713 klass
= mono_defaults
.int64_class
;
6714 else if (!strcmp (typename
, "ulong"))
6715 klass
= mono_defaults
.uint64_class
;
6716 else if (!strcmp (typename
, "float"))
6717 klass
= mono_defaults
.single_class
;
6718 else if (!strcmp (typename
, "double"))
6719 klass
= mono_defaults
.double_class
;
6720 else if (!strcmp (typename
, "object"))
6721 klass
= mono_defaults
.object_class
;
6722 else if (!strcmp (typename
, "obj"))
6723 klass
= mono_defaults
.object_class
;
6726 g_assert_not_reached ();
6728 return &klass
->byval_arg
;
6731 MonoMethodSignature
*
6732 mono_create_icall_signature (const char *sigstr
)
6737 MonoMethodSignature
*res
;
6739 mono_loader_lock ();
6740 res
= g_hash_table_lookup (mono_defaults
.corlib
->helper_signatures
, sigstr
);
6742 mono_loader_unlock ();
6746 parts
= g_strsplit (sigstr
, " ", 256);
6755 res
= mono_metadata_signature_alloc (mono_defaults
.corlib
, len
- 1);
6758 #ifdef PLATFORM_WIN32
6760 * Under windows, the default pinvoke calling convention is STDCALL but
6763 res
->call_convention
= MONO_CALL_C
;
6766 res
->ret
= type_from_typename (parts
[0]);
6767 for (i
= 1; i
< len
; ++i
) {
6768 res
->params
[i
- 1] = type_from_typename (parts
[i
]);
6773 g_hash_table_insert (mono_defaults
.corlib
->helper_signatures
, (gpointer
)sigstr
, res
);
6775 mono_loader_unlock ();
6781 mono_find_jit_icall_by_name (const char *name
)
6783 MonoJitICallInfo
*info
;
6784 g_assert (jit_icall_hash_name
);
6786 mono_loader_lock ();
6787 info
= g_hash_table_lookup (jit_icall_hash_name
, name
);
6788 mono_loader_unlock ();
6793 mono_find_jit_icall_by_addr (gconstpointer addr
)
6795 MonoJitICallInfo
*info
;
6796 g_assert (jit_icall_hash_addr
);
6798 mono_loader_lock ();
6799 info
= g_hash_table_lookup (jit_icall_hash_addr
, (gpointer
)addr
);
6800 mono_loader_unlock ();
6806 mono_register_jit_icall_wrapper (MonoJitICallInfo
*info
, gconstpointer wrapper
)
6808 mono_loader_lock ();
6809 g_hash_table_insert (jit_icall_hash_addr
, (gpointer
)info
->wrapper
, info
);
6810 mono_loader_unlock ();
6814 mono_register_jit_icall (gconstpointer func
, const char *name
, MonoMethodSignature
*sig
, gboolean is_save
)
6816 MonoJitICallInfo
*info
;
6821 mono_loader_lock ();
6823 if (!jit_icall_hash_name
) {
6824 jit_icall_hash_name
= g_hash_table_new (g_str_hash
, g_str_equal
);
6825 jit_icall_hash_addr
= g_hash_table_new (NULL
, NULL
);
6828 if (g_hash_table_lookup (jit_icall_hash_name
, name
)) {
6829 g_warning ("jit icall already defined \"%s\"\n", name
);
6830 g_assert_not_reached ();
6833 info
= g_new (MonoJitICallInfo
, 1);
6840 info
->wrapper
= func
;
6842 info
->wrapper
= NULL
;
6845 g_hash_table_insert (jit_icall_hash_name
, (gpointer
)info
->name
, info
);
6846 g_hash_table_insert (jit_icall_hash_addr
, (gpointer
)func
, info
);
6848 mono_loader_unlock ();