5 * Dietmar Maurer (dietmar@ximian.com)
6 * Paolo Molaro (lupus@ximian.com)
7 * Patrik Torstensson (patrik.torstensson@labs2.com)
9 * (C) 2001 Ximian, Inc.
18 #if defined (PLATFORM_WIN32)
22 #include <mono/metadata/object.h>
23 #include <mono/metadata/threads.h>
24 #include <mono/metadata/monitor.h>
25 #include <mono/metadata/reflection.h>
26 #include <mono/metadata/assembly.h>
27 #include <mono/metadata/tabledefs.h>
28 #include <mono/metadata/exception.h>
29 #include <mono/metadata/file-io.h>
30 #include <mono/metadata/socket-io.h>
31 #include <mono/metadata/mono-endian.h>
32 #include <mono/metadata/tokentype.h>
33 #include <mono/metadata/unicode.h>
34 #include <mono/metadata/appdomain.h>
35 #include <mono/metadata/marshal.h>
36 #include <mono/metadata/gc-internal.h>
37 #include <mono/metadata/rand.h>
38 #include <mono/metadata/sysmath.h>
39 #include <mono/metadata/string-icalls.h>
40 #include <mono/metadata/mono-debug-debugger.h>
41 #include <mono/metadata/process.h>
42 #include <mono/metadata/environment.h>
43 #include <mono/metadata/profiler-private.h>
44 #include <mono/io-layer/io-layer.h>
45 #include <mono/utils/strtod.h>
47 #if defined (PLATFORM_WIN32)
52 static MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_GetCallingAssembly (void);
56 * We expect a pointer to a char, not a string
59 mono_double_ParseImpl (char *ptr)
67 result = bsd_strtod (ptr, &endptr);
69 if (!*ptr || (endptr && *endptr))
70 mono_raise_exception (mono_exception_from_name (mono_defaults.corlib,
78 ves_icall_System_Double_AssertEndianity (double *value)
82 MONO_DOUBLE_ASSERT_ENDIANITY (value);
86 ves_icall_System_Array_GetValueImpl (MonoObject *this, guint32 pos)
95 ao = (MonoArray *)this;
96 ac = (MonoClass *)ao->obj.vtable->klass;
98 esize = mono_array_element_size (ac);
99 ea = (gpointer*)((char*)ao->vector + (pos * esize));
101 if (ac->element_class->valuetype)
102 return mono_value_box (this->vtable->domain, ac->element_class, ea);
108 ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs)
116 MONO_CHECK_ARG_NULL (idxs);
118 io = (MonoArray *)idxs;
119 ic = (MonoClass *)io->obj.vtable->klass;
121 ao = (MonoArray *)this;
122 ac = (MonoClass *)ao->obj.vtable->klass;
124 g_assert (ic->rank == 1);
125 if (io->bounds != NULL || io->max_length != ac->rank)
126 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
128 ind = (guint32 *)io->vector;
130 if (ao->bounds == NULL) {
131 if (*ind < 0 || *ind >= ao->max_length)
132 mono_raise_exception (mono_get_exception_index_out_of_range ());
134 return ves_icall_System_Array_GetValueImpl (this, *ind);
137 for (i = 0; i < ac->rank; i++)
138 if ((ind [i] < ao->bounds [i].lower_bound) ||
139 (ind [i] >= ao->bounds [i].length + ao->bounds [i].lower_bound))
140 mono_raise_exception (mono_get_exception_index_out_of_range ());
142 pos = ind [0] - ao->bounds [0].lower_bound;
143 for (i = 1; i < ac->rank; i++)
144 pos = pos*ao->bounds [i].length + ind [i] -
145 ao->bounds [i].lower_bound;
147 return ves_icall_System_Array_GetValueImpl (this, pos);
151 ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 pos)
153 MonoClass *ac, *vc, *ec;
164 vc = value->vtable->klass;
168 ac = this->obj.vtable->klass;
169 ec = ac->element_class;
171 esize = mono_array_element_size (ac);
172 ea = (gpointer*)((char*)this->vector + (pos * esize));
173 va = (gpointer*)((char*)value + sizeof (MonoObject));
176 memset (ea, 0, esize);
180 #define NO_WIDENING_CONVERSION G_STMT_START{\
181 mono_raise_exception (mono_get_exception_argument ( \
182 "value", "not a widening conversion")); \
185 #define CHECK_WIDENING_CONVERSION(extra) G_STMT_START{\
186 if (esize < vsize + (extra)) \
187 mono_raise_exception (mono_get_exception_argument ( \
188 "value", "not a widening conversion")); \
191 #define INVALID_CAST G_STMT_START{\
192 mono_raise_exception (mono_get_exception_invalid_cast ()); \
195 /* Check element (destination) type. */
196 switch (ec->byval_arg.type) {
197 case MONO_TYPE_STRING:
198 switch (vc->byval_arg.type) {
199 case MONO_TYPE_STRING:
205 case MONO_TYPE_BOOLEAN:
206 switch (vc->byval_arg.type) {
207 case MONO_TYPE_BOOLEAN:
220 NO_WIDENING_CONVERSION;
227 if (!ec->valuetype) {
228 if (!mono_object_isinst (value, ec))
230 *ea = (gpointer)value;
234 if (mono_object_isinst (value, ec)) {
235 memcpy (ea, (char *)value + sizeof (MonoObject), esize);
242 vsize = mono_class_instance_size (vc) - sizeof (MonoObject);
245 g_message (G_STRLOC ": %d (%d) <= %d (%d)",
246 ec->byval_arg.type, esize,
247 vc->byval_arg.type, vsize);
250 #define ASSIGN_UNSIGNED(etype) G_STMT_START{\
251 switch (vc->byval_arg.type) { \
256 case MONO_TYPE_CHAR: \
257 CHECK_WIDENING_CONVERSION(0); \
258 *(etype *) ea = (etype) u64; \
260 /* You can't assign a signed value to an unsigned array. */ \
265 /* You can't assign a floating point number to an integer array. */ \
268 NO_WIDENING_CONVERSION; \
272 #define ASSIGN_SIGNED(etype) G_STMT_START{\
273 switch (vc->byval_arg.type) { \
278 CHECK_WIDENING_CONVERSION(0); \
279 *(etype *) ea = (etype) i64; \
281 /* You can assign an unsigned value to a signed array if the array's */ \
282 /* element size is larger than the value size. */ \
287 case MONO_TYPE_CHAR: \
288 CHECK_WIDENING_CONVERSION(1); \
289 *(etype *) ea = (etype) u64; \
291 /* You can't assign a floating point number to an integer array. */ \
294 NO_WIDENING_CONVERSION; \
298 #define ASSIGN_REAL(etype) G_STMT_START{\
299 switch (vc->byval_arg.type) { \
302 CHECK_WIDENING_CONVERSION(0); \
303 *(etype *) ea = (etype) r64; \
305 /* All integer values fit into a floating point array, so we don't */ \
306 /* need to CHECK_WIDENING_CONVERSION here. */ \
311 *(etype *) ea = (etype) i64; \
317 case MONO_TYPE_CHAR: \
318 *(etype *) ea = (etype) u64; \
323 switch (vc->byval_arg.type) {
325 u64 = *(guint8 *) va;
328 u64 = *(guint16 *) va;
331 u64 = *(guint32 *) va;
334 u64 = *(guint64 *) va;
340 i64 = *(gint16 *) va;
343 i64 = *(gint32 *) va;
346 i64 = *(gint64 *) va;
349 r64 = *(gfloat *) va;
352 r64 = *(gdouble *) va;
355 u64 = *(guint16 *) va;
357 case MONO_TYPE_BOOLEAN:
358 /* Boolean is only compatible with itself. */
359 switch (ec->byval_arg.type) {
371 NO_WIDENING_CONVERSION;
378 /* If we can't do a direct copy, let's try a widening conversion. */
379 switch (ec->byval_arg.type) {
381 ASSIGN_UNSIGNED (guint16);
383 ASSIGN_UNSIGNED (guint8);
385 ASSIGN_UNSIGNED (guint16);
387 ASSIGN_UNSIGNED (guint32);
389 ASSIGN_UNSIGNED (guint64);
391 ASSIGN_SIGNED (gint8);
393 ASSIGN_SIGNED (gint16);
395 ASSIGN_SIGNED (gint32);
397 ASSIGN_SIGNED (gint64);
399 ASSIGN_REAL (gfloat);
401 ASSIGN_REAL (gdouble);
405 /* Not reached, INVALID_CAST does not return. Just to avoid a compiler warning ... */
409 #undef NO_WIDENING_CONVERSION
410 #undef CHECK_WIDENING_CONVERSION
411 #undef ASSIGN_UNSIGNED
417 ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value,
425 MONO_CHECK_ARG_NULL (idxs);
427 ic = idxs->obj.vtable->klass;
428 ac = this->obj.vtable->klass;
430 g_assert (ic->rank == 1);
431 if (idxs->bounds != NULL || idxs->max_length != ac->rank)
432 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
434 ind = (guint32 *)idxs->vector;
436 if (this->bounds == NULL) {
437 if (*ind < 0 || *ind >= this->max_length)
438 mono_raise_exception (mono_get_exception_index_out_of_range ());
440 ves_icall_System_Array_SetValueImpl (this, value, *ind);
444 for (i = 0; i < ac->rank; i++)
445 if ((ind [i] < this->bounds [i].lower_bound) ||
446 (ind [i] >= this->bounds [i].length + this->bounds [i].lower_bound))
447 mono_raise_exception (mono_get_exception_index_out_of_range ());
449 pos = ind [0] - this->bounds [0].lower_bound;
450 for (i = 1; i < ac->rank; i++)
451 pos = pos * this->bounds [i].length + ind [i] -
452 this->bounds [i].lower_bound;
454 ves_icall_System_Array_SetValueImpl (this, value, pos);
458 ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *lengths, MonoArray *bounds)
466 MONO_CHECK_ARG_NULL (type);
467 MONO_CHECK_ARG_NULL (lengths);
469 MONO_CHECK_ARG (lengths, mono_array_length (lengths) > 0);
471 MONO_CHECK_ARG (bounds, mono_array_length (lengths) == mono_array_length (bounds));
473 for (i = 0; i < mono_array_length (lengths); i++)
474 if (mono_array_get (lengths, gint32, i) < 0)
475 mono_raise_exception (mono_get_exception_argument_out_of_range (NULL));
477 aklass = mono_array_class_get (mono_class_from_mono_type (type->type), mono_array_length (lengths));
479 sizes = alloca (aklass->rank * sizeof(guint32) * 2);
480 for (i = 0; i < aklass->rank; ++i) {
481 sizes [i] = mono_array_get (lengths, gint32, i);
483 sizes [i + aklass->rank] = mono_array_get (bounds, gint32, i);
485 sizes [i + aklass->rank] = 0;
488 array = mono_array_new_full (mono_object_domain (type), aklass, sizes, sizes + aklass->rank);
494 ves_icall_System_Array_GetRank (MonoObject *this)
498 return this->vtable->klass->rank;
502 ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension)
504 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
508 if ((dimension < 0) || (dimension >= rank))
509 mono_raise_exception (mono_get_exception_index_out_of_range ());
511 if (this->bounds == NULL)
512 return this->max_length;
514 return this->bounds [dimension].length;
518 ves_icall_System_Array_GetLowerBound (MonoArray *this, gint32 dimension)
520 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
524 if ((dimension < 0) || (dimension >= rank))
525 mono_raise_exception (mono_get_exception_index_out_of_range ());
527 if (this->bounds == NULL)
530 return this->bounds [dimension].lower_bound;
534 ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* dest, int dest_idx, int length)
539 MonoClass *src_class;
540 MonoClass *dest_class;
545 if (source->obj.vtable->klass->rank != dest->obj.vtable->klass->rank)
548 if (source->bounds || dest->bounds)
551 if ((dest_idx + length > mono_array_length (dest)) ||
552 (source_idx + length > mono_array_length (source)))
555 element_size = mono_array_element_size (source->obj.vtable->klass);
556 dest_addr = mono_array_addr_with_size (dest, element_size, dest_idx);
557 source_addr = mono_array_addr_with_size (source, element_size, source_idx);
559 src_class = source->obj.vtable->klass->element_class;
560 dest_class = dest->obj.vtable->klass->element_class;
563 * Handle common cases.
566 /* Case1: object[] -> valuetype[] (ArrayList::ToArray) */
567 if (src_class == mono_defaults.object_class && dest_class->valuetype) {
568 for (i = source_idx; i < source_idx + length; ++i) {
569 MonoObject *elem = mono_array_get (source, MonoObject*, i);
570 if (elem && !mono_object_isinst (elem, dest_class))
574 element_size = mono_array_element_size (dest->obj.vtable->klass);
575 for (i = 0; i < length; ++i) {
576 MonoObject *elem = mono_array_get (source, MonoObject*, source_idx + i);
577 void *addr = mono_array_addr_with_size (dest, element_size, dest_idx + i);
579 memset (addr, 0, element_size);
581 memcpy (addr, (char *)elem + sizeof (MonoObject), element_size);
586 if (src_class != dest_class) {
587 if (dest_class->valuetype || dest_class->enumtype || src_class->valuetype || src_class->enumtype)
590 if (mono_class_is_subclass_of (src_class, dest_class, FALSE))
592 /* Case2: object[] -> reftype[] (ArrayList::ToArray) */
593 else if (mono_class_is_subclass_of (dest_class, src_class, FALSE))
594 for (i = source_idx; i < source_idx + length; ++i) {
595 MonoObject *elem = mono_array_get (source, MonoObject*, i);
596 if (elem && !mono_object_isinst (elem, dest_class))
603 memmove (dest_addr, source_addr, element_size * length);
609 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoArray *array, MonoClassField *field_handle)
611 MonoClass *klass = array->obj.vtable->klass;
612 guint32 size = mono_array_element_size (klass);
617 if (array->bounds == NULL)
618 size *= array->max_length;
620 for (i = 0; i < klass->rank; ++i)
621 size *= array->bounds [i].length;
623 memcpy (mono_array_addr (array, char, 0), field_handle->data, size);
625 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
629 guint ## n *data = (guint ## n *) mono_array_addr (array, char, 0); \
631 for (i = 0; i < size; i += n/8, data++) { \
632 tmp = read ## n (data); \
637 /* printf ("Initialize array with elements of %s type\n", klass->element_class->name); */
639 switch (klass->element_class->byval_arg.type) {
659 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData (void)
663 return offsetof (MonoString, chars);
667 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObject *obj)
671 if ((obj == NULL) || (! (obj->vtable->klass->valuetype)))
674 return mono_object_clone (obj);
678 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (MonoType *handle)
684 MONO_CHECK_ARG_NULL (handle);
686 klass = mono_class_from_mono_type (handle);
687 MONO_CHECK_ARG (handle, klass);
689 /* This will call the type constructor */
690 if (! (klass->flags & TYPE_ATTRIBUTE_INTERFACE))
691 mono_runtime_class_init (mono_class_vtable (mono_domain_get (), klass));
695 ves_icall_System_Object_MemberwiseClone (MonoObject *this)
699 return mono_object_clone (this);
703 #define MONO_OBJECT_ALIGNMENT_SHIFT 3
705 #define MONO_OBJECT_ALIGNMENT_SHIFT 2
709 * Return hashcode based on object address. This function will need to be
710 * smarter in the presence of a moving garbage collector, which will cache
711 * the address hash before relocating the object.
713 * Wang's address-based hash function:
714 * http://www.concentric.net/~Ttwang/tech/addrhash.htm
717 ves_icall_System_Object_GetHashCode (MonoObject *this)
719 register guint32 key;
723 key = (GPOINTER_TO_UINT (this) >> MONO_OBJECT_ALIGNMENT_SHIFT) * 2654435761u;
725 return key & 0x7fffffff;
729 * A hash function for value types. I have no idea if this is a good hash
730 * function (its similar to g_str_hash).
733 ves_icall_System_ValueType_GetHashCode (MonoObject *this)
741 MONO_CHECK_ARG_NULL (this);
743 size = this->vtable->klass->instance_size - sizeof (MonoObject);
745 p = (const char *)this + sizeof (MonoObject);
747 for (i = 0; i < size; i++) {
748 h = (h << 5) - h + *p;
756 ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that)
763 MONO_CHECK_ARG_NULL (that);
765 if (this->vtable != that->vtable)
768 size = this->vtable->klass->instance_size - sizeof (MonoObject);
770 p = (const char *)this + sizeof (MonoObject);
771 s = (const char *)that + sizeof (MonoObject);
773 return memcmp (p, s, size)? FALSE: TRUE;
776 static MonoReflectionType *
777 ves_icall_System_Object_GetType (MonoObject *obj)
781 return mono_type_get_object (mono_object_domain (obj), &obj->vtable->klass->byval_arg);
785 mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
789 mtype->type = &obj->vtable->klass->byval_arg;
790 g_assert (mtype->type->type);
794 ves_icall_AssemblyBuilder_getToken (MonoReflectionAssemblyBuilder *assb, MonoObject *obj)
798 return mono_image_create_token (assb->dynamic_assembly, obj);
802 ves_icall_AssemblyBuilder_getDataChunk (MonoReflectionAssemblyBuilder *assb, MonoArray *buf, gint32 offset)
805 MonoDynamicAssembly *ass = assb->dynamic_assembly;
806 char *p = mono_array_addr (buf, char, 0);
810 mono_image_create_pefile (assb);
812 if (offset >= ass->pefile.index)
814 count = mono_array_length (buf);
815 count = MIN (count, ass->pefile.index - offset);
817 memcpy (p, ass->pefile.data + offset, count);
823 ves_icall_AssemblyBuilder_build_metadata (MonoReflectionAssemblyBuilder *assb)
827 mono_image_build_metadata (assb);
830 static MonoReflectionType*
831 ves_icall_type_from_name (MonoString *name,
832 MonoBoolean throwOnError,
833 MonoBoolean ignoreCase)
836 MonoType *type = NULL;
837 MonoAssembly *assembly;
838 MonoTypeNameParse info;
842 str = mono_string_to_utf8 (name);
843 if (!mono_reflection_parse_type (str, &info)) {
845 g_list_free (info.modifiers);
846 g_list_free (info.nested);
847 if (throwOnError) /* uhm: this is a parse error, though... */
848 mono_raise_exception (mono_get_exception_type_load (name));
853 if (info.assembly.name) {
854 assembly = mono_assembly_load (&info.assembly, NULL, NULL);
856 MonoReflectionAssembly *refass;
858 refass = ves_icall_System_Reflection_Assembly_GetCallingAssembly ();
859 assembly = refass->assembly;
863 type = mono_reflection_get_type (assembly->image, &info, ignoreCase);
865 if (!info.assembly.name && !type) /* try mscorlib */
866 type = mono_reflection_get_type (NULL, &info, ignoreCase);
869 g_list_free (info.modifiers);
870 g_list_free (info.nested);
873 mono_raise_exception (mono_get_exception_type_load (name));
878 return mono_type_get_object (mono_domain_get (), type);
881 static MonoReflectionType*
882 ves_icall_type_from_handle (MonoType *handle)
884 MonoDomain *domain = mono_domain_get ();
885 MonoClass *klass = mono_class_from_mono_type (handle);
889 mono_class_init (klass);
890 return mono_type_get_object (domain, handle);
894 ves_icall_type_Equals (MonoReflectionType *type, MonoReflectionType *c)
898 if (type->type && c->type)
899 return mono_metadata_type_equal (type->type, c->type);
900 g_print ("type equals\n");
904 /* System.TypeCode */
927 ves_icall_type_GetTypeCode (MonoReflectionType *type)
929 int t = type->type->type;
936 return TYPECODE_OBJECT;
937 case MONO_TYPE_BOOLEAN:
938 return TYPECODE_BOOLEAN;
940 return TYPECODE_BYTE;
942 return TYPECODE_SBYTE;
944 return TYPECODE_UINT16;
946 return TYPECODE_INT16;
948 return TYPECODE_CHAR;
952 return TYPECODE_OBJECT;
954 return TYPECODE_UINT32;
956 return TYPECODE_INT32;
958 return TYPECODE_UINT64;
960 return TYPECODE_INT64;
962 return TYPECODE_SINGLE;
964 return TYPECODE_DOUBLE;
965 case MONO_TYPE_VALUETYPE:
966 if (type->type->data.klass->enumtype) {
967 t = type->type->data.klass->enum_basetype->type;
970 MonoClass *k = type->type->data.klass;
971 if (strcmp (k->name_space, "System") == 0) {
972 if (strcmp (k->name, "Decimal") == 0)
973 return TYPECODE_DECIMAL;
974 else if (strcmp (k->name, "DateTime") == 0)
975 return TYPECODE_DATETIME;
978 return TYPECODE_OBJECT;
979 case MONO_TYPE_STRING:
980 return TYPECODE_STRING;
981 case MONO_TYPE_SZARRAY:
982 case MONO_TYPE_ARRAY:
983 case MONO_TYPE_OBJECT:
984 return TYPECODE_OBJECT;
985 case MONO_TYPE_CLASS:
987 MonoClass *k = type->type->data.klass;
988 if (strcmp (k->name_space, "System") == 0) {
989 if (strcmp (k->name, "DBNull") == 0)
990 return TYPECODE_DBNULL;
993 return TYPECODE_OBJECT;
995 g_error ("type 0x%02x not handled in GetTypeCode()", t);
1001 ves_icall_type_is_subtype_of (MonoReflectionType *type, MonoReflectionType *c, MonoBoolean check_interfaces)
1007 MONO_ARCH_SAVE_REGS;
1009 g_assert (type != NULL);
1011 domain = ((MonoObject *)type)->vtable->domain;
1013 if (!c) /* FIXME: dont know what do do here */
1016 klass = mono_class_from_mono_type (type->type);
1017 klassc = mono_class_from_mono_type (c->type);
1019 return mono_class_is_subclass_of (klass, klassc, check_interfaces);
1023 ves_icall_type_is_assignable_from (MonoReflectionType *type, MonoReflectionType *c)
1029 MONO_ARCH_SAVE_REGS;
1031 g_assert (type != NULL);
1033 domain = ((MonoObject *)type)->vtable->domain;
1035 klass = mono_class_from_mono_type (type->type);
1036 klassc = mono_class_from_mono_type (c->type);
1038 return mono_class_is_assignable_from (klass, klassc);
1042 ves_icall_get_attributes (MonoReflectionType *type)
1044 MonoClass *klass = mono_class_from_mono_type (type->type);
1046 MONO_ARCH_SAVE_REGS;
1048 return klass->flags;
1051 static MonoReflectionField*
1052 ves_icall_System_Reflection_FieldInfo_internal_from_handle (MonoClassField *handle)
1054 MONO_ARCH_SAVE_REGS;
1058 return mono_field_get_object (mono_domain_get (), handle->parent, handle);
1062 ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info)
1064 MonoDomain *domain = mono_domain_get ();
1066 MONO_ARCH_SAVE_REGS;
1068 info->parent = mono_type_get_object (domain, &method->klass->byval_arg);
1069 info->ret = mono_type_get_object (domain, method->signature->ret);
1070 info->attrs = method->flags;
1071 info->implattrs = method->iflags;
1075 ves_icall_get_parameter_info (MonoMethod *method)
1077 MonoDomain *domain = mono_domain_get ();
1079 MONO_ARCH_SAVE_REGS;
1081 return mono_param_get_objects (domain, method);
1084 static MonoReflectionType*
1085 ves_icall_MonoField_GetParentType (MonoReflectionField *field, MonoBoolean declaring)
1088 MONO_ARCH_SAVE_REGS;
1090 parent = declaring? field->field->parent: field->klass;
1092 return mono_type_get_object (mono_object_domain (field), &parent->byval_arg);
1096 ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *obj)
1099 MonoClassField *cf = field->field;
1102 MonoDomain *domain = mono_object_domain (field);
1104 gboolean is_static = FALSE;
1105 gboolean is_ref = FALSE;
1107 MONO_ARCH_SAVE_REGS;
1109 mono_class_init (field->klass);
1111 switch (cf->type->type) {
1112 case MONO_TYPE_STRING:
1113 case MONO_TYPE_OBJECT:
1114 case MONO_TYPE_CLASS:
1115 case MONO_TYPE_ARRAY:
1116 case MONO_TYPE_SZARRAY:
1121 case MONO_TYPE_BOOLEAN:
1124 case MONO_TYPE_CHAR:
1133 case MONO_TYPE_VALUETYPE:
1134 is_ref = cf->type->byref;
1137 g_error ("type 0x%x not handled in "
1138 "ves_icall_Monofield_GetValue", cf->type->type);
1142 if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1144 vtable = mono_class_vtable (domain, field->klass);
1145 if (!vtable->initialized)
1146 mono_runtime_class_init (vtable);
1151 mono_field_static_get_value (vtable, cf, &o);
1153 mono_field_get_value (obj, cf, &o);
1158 /* boxed value type */
1159 klass = mono_class_from_mono_type (cf->type);
1160 o = mono_object_new (domain, klass);
1161 v = ((gchar *) o) + sizeof (MonoObject);
1163 mono_field_static_get_value (vtable, cf, v);
1165 mono_field_get_value (obj, cf, v);
1172 ves_icall_FieldInfo_SetValueInternal (MonoReflectionField *field, MonoObject *obj, MonoObject *value)
1174 MonoClassField *cf = field->field;
1177 MONO_ARCH_SAVE_REGS;
1179 v = (gchar *) value;
1180 if (!cf->type->byref) {
1181 switch (cf->type->type) {
1184 case MONO_TYPE_BOOLEAN:
1187 case MONO_TYPE_CHAR:
1196 case MONO_TYPE_VALUETYPE:
1197 v += sizeof (MonoObject);
1199 case MONO_TYPE_STRING:
1200 case MONO_TYPE_OBJECT:
1201 case MONO_TYPE_CLASS:
1202 case MONO_TYPE_ARRAY:
1203 case MONO_TYPE_SZARRAY:
1207 g_error ("type 0x%x not handled in "
1208 "ves_icall_FieldInfo_SetValueInternal", cf->type->type);
1213 if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1214 MonoVTable *vtable = mono_class_vtable (mono_object_domain (field), field->klass);
1215 if (!vtable->initialized)
1216 mono_runtime_class_init (vtable);
1217 mono_field_static_set_value (vtable, cf, v);
1219 mono_field_set_value (obj, cf, v);
1224 ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info)
1226 MonoDomain *domain = mono_object_domain (property);
1228 MONO_ARCH_SAVE_REGS;
1230 info->parent = mono_type_get_object (domain, &property->klass->byval_arg);
1231 info->name = mono_string_new (domain, property->property->name);
1232 info->attrs = property->property->attrs;
1233 info->get = property->property->get ? mono_method_get_object (domain, property->property->get, NULL): NULL;
1234 info->set = property->property->set ? mono_method_get_object (domain, property->property->set, NULL): NULL;
1236 * There may be other methods defined for properties, though, it seems they are not exposed
1237 * in the reflection API
1242 ves_icall_get_event_info (MonoReflectionEvent *event, MonoEventInfo *info)
1244 MonoDomain *domain = mono_object_domain (event);
1246 MONO_ARCH_SAVE_REGS;
1248 info->parent = mono_type_get_object (domain, &event->klass->byval_arg);
1249 info->name = mono_string_new (domain, event->event->name);
1250 info->attrs = event->event->attrs;
1251 info->add_method = event->event->add ? mono_method_get_object (domain, event->event->add, NULL): NULL;
1252 info->remove_method = event->event->remove ? mono_method_get_object (domain, event->event->remove, NULL): NULL;
1253 info->raise_method = event->event->raise ? mono_method_get_object (domain, event->event->raise, NULL): NULL;
1257 ves_icall_Type_GetInterfaces (MonoReflectionType* type)
1259 MonoDomain *domain = mono_object_domain (type);
1262 MonoClass *class = mono_class_from_mono_type (type->type);
1265 MONO_ARCH_SAVE_REGS;
1268 /* GetInterfaces() returns an empty array in MS.NET (this may be a bug) */
1269 return mono_array_new (domain, mono_defaults.monotype_class, 0);
1273 for (parent = class; parent; parent = parent->parent) {
1274 ninterf += parent->interface_count;
1276 intf = mono_array_new (domain, mono_defaults.monotype_class, ninterf);
1278 for (parent = class; parent; parent = parent->parent) {
1279 for (i = 0; i < parent->interface_count; ++i) {
1280 mono_array_set (intf, gpointer, ninterf, mono_type_get_object (domain, &parent->interfaces [i]->byval_arg));
1288 ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType *iface, MonoArray **targets, MonoArray **methods)
1290 MonoClass *class = mono_class_from_mono_type (type->type);
1291 MonoClass *iclass = mono_class_from_mono_type (iface->type);
1292 MonoReflectionMethod *member;
1293 int i, len, ioffset;
1296 MONO_ARCH_SAVE_REGS;
1298 /* type doesn't implement iface: the exception is thrown in managed code */
1299 if ((iclass->interface_id > class->max_interface_id) || !class->interface_offsets [iclass->interface_id])
1302 len = iclass->method.count;
1303 ioffset = class->interface_offsets [iclass->interface_id];
1304 domain = mono_object_domain (type);
1305 *targets = mono_array_new (domain, mono_defaults.method_info_class, len);
1306 *methods = mono_array_new (domain, mono_defaults.method_info_class, len);
1307 for (i = 0; i < len; ++i) {
1308 member = mono_method_get_object (domain, iclass->methods [i], iclass);
1309 mono_array_set (*methods, gpointer, i, member);
1310 member = mono_method_get_object (domain, class->vtable [i + ioffset], class);
1311 mono_array_set (*targets, gpointer, i, member);
1315 static MonoReflectionType*
1316 ves_icall_MonoType_GetElementType (MonoReflectionType *type)
1318 MonoClass *class = mono_class_from_mono_type (type->type);
1320 MONO_ARCH_SAVE_REGS;
1322 if (type->type->byref)
1323 return mono_type_get_object (mono_object_domain (type), &class->byval_arg);
1324 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
1325 return mono_type_get_object (mono_object_domain (type), class->enum_basetype);
1326 else if (class->element_class)
1327 return mono_type_get_object (mono_object_domain (type), &class->element_class->byval_arg);
1332 static MonoReflectionType*
1333 ves_icall_get_type_parent (MonoReflectionType *type)
1335 MonoClass *class = mono_class_from_mono_type (type->type);
1337 MONO_ARCH_SAVE_REGS;
1339 return class->parent ? mono_type_get_object (mono_object_domain (type), &class->parent->byval_arg): NULL;
1343 ves_icall_type_ispointer (MonoReflectionType *type)
1345 MONO_ARCH_SAVE_REGS;
1347 return type->type->type == MONO_TYPE_PTR;
1351 ves_icall_type_isprimitive (MonoReflectionType *type)
1353 MONO_ARCH_SAVE_REGS;
1355 return (!type->type->byref && (type->type->type >= MONO_TYPE_BOOLEAN) && (type->type->type <= MONO_TYPE_R8));
1359 ves_icall_type_isbyref (MonoReflectionType *type)
1361 MONO_ARCH_SAVE_REGS;
1363 return type->type->byref;
1366 static MonoReflectionModule*
1367 ves_icall_MonoType_get_Module (MonoReflectionType *type)
1369 MonoClass *class = mono_class_from_mono_type (type->type);
1371 MONO_ARCH_SAVE_REGS;
1373 return mono_module_get_object (mono_object_domain (type), class->image);
1377 ves_icall_get_type_info (MonoType *type, MonoTypeInfo *info)
1379 MonoDomain *domain = mono_domain_get ();
1380 MonoClass *class = mono_class_from_mono_type (type);
1382 MONO_ARCH_SAVE_REGS;
1384 info->nested_in = class->nested_in ? mono_type_get_object (domain, &class->nested_in->byval_arg): NULL;
1385 info->name = mono_string_new (domain, class->name);
1386 info->name_space = mono_string_new (domain, class->name_space);
1387 info->rank = class->rank;
1388 info->assembly = mono_assembly_get_object (domain, class->image->assembly);
1389 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
1390 info->etype = mono_type_get_object (domain, class->enum_basetype);
1391 else if (class->element_class)
1392 info->etype = mono_type_get_object (domain, &class->element_class->byval_arg);
1396 info->isprimitive = (!type->byref && (type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8));
1400 ves_icall_Type_GetGenericParameters (MonoReflectionType *type)
1403 MonoClass *klass, *pklass;
1405 MONO_ARCH_SAVE_REGS;
1407 klass = mono_class_from_mono_type (type->type);
1409 if (type->type->byref) {
1410 res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, 0);
1411 } else if (klass->gen_params) {
1412 res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, klass->num_gen_params);
1413 for (i = 0; i < klass->num_gen_params; ++i) {
1414 pklass = mono_class_from_gen_param (&klass->gen_params [i], FALSE);
1415 mono_array_set (res, gpointer, i, mono_type_get_object (mono_object_domain (type), &pklass->byval_arg));
1417 } else if (klass->generic_inst) {
1418 MonoGenericInst *inst = klass->generic_inst->data.generic_inst;
1419 res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, inst->type_argc);
1420 for (i = 0; i < inst->type_argc; ++i) {
1421 mono_array_set (res, gpointer, i, mono_type_get_object (mono_object_domain (type), inst->type_argv [i]));
1424 res = mono_array_new (mono_object_domain (type), mono_defaults.monotype_class, 0);
1429 static MonoReflectionType*
1430 ves_icall_Type_GetGenericTypeDefinition (MonoReflectionType *type)
1433 MONO_ARCH_SAVE_REGS;
1435 if (type->type->byref)
1437 klass = mono_class_from_mono_type (type->type);
1438 if (klass->gen_params) {
1439 return type; /* check this one */
1441 if (klass->generic_inst)
1442 return mono_type_get_object (mono_object_domain (type), klass->generic_inst->data.generic_inst->generic_type);
1446 static MonoReflectionType*
1447 ves_icall_Type_BindGenericParameters (MonoReflectionType *type, MonoArray *types)
1451 MonoGenericInst *ginst;
1453 MONO_ARCH_SAVE_REGS;
1455 if (type->type->byref)
1457 klass = mono_class_from_mono_type (type->type);
1458 if (klass->num_gen_params != mono_array_length (types))
1461 geninst = g_new0 (MonoType, 1);
1462 geninst->type = MONO_TYPE_GENERICINST;
1463 geninst->data.generic_inst = ginst = g_new0 (MonoGenericInst, 1);
1464 ginst->generic_type = &klass->byval_arg;
1465 ginst->type_argc = klass->num_gen_params;
1466 ginst->type_argv = g_new0 (MonoType *, klass->num_gen_params);
1467 for (i = 0; i < klass->num_gen_params; ++i) {
1468 MonoReflectionType *garg = mono_array_get (types, gpointer, i);
1469 ginst->type_argv [i] = garg->type;
1472 klass = mono_class_from_generic (geninst);
1473 return mono_type_get_object (mono_object_domain (type), klass->generic_inst);
1477 ves_icall_Type_get_IsGenericInstance (MonoReflectionType *type)
1480 MONO_ARCH_SAVE_REGS;
1482 if (type->type->byref)
1484 klass = mono_class_from_mono_type (type->type);
1485 return klass->generic_inst != NULL;
1489 ves_icall_Type_GetGenericParameterPosition (MonoReflectionType *type)
1491 MONO_ARCH_SAVE_REGS;
1493 if (type->type->byref)
1495 if (type->type->type == MONO_TYPE_VAR || type->type->type == MONO_TYPE_MVAR)
1496 return type->type->data.generic_param->num;
1501 ves_icall_MonoType_get_HasGenericParameteres (MonoReflectionType *type)
1504 MONO_ARCH_SAVE_REGS;
1506 if (type->type->byref)
1508 klass = mono_class_from_mono_type (type->type);
1509 if (klass->gen_params || klass->generic_inst)
1515 ves_icall_MonoType_get_IsUnboundGenericParameter (MonoReflectionType *type)
1517 MONO_ARCH_SAVE_REGS;
1519 if (type->type->byref)
1521 if (type->type->type == MONO_TYPE_VAR || type->type->type == MONO_TYPE_MVAR)
1527 ves_icall_MonoType_get_HasUnboundGenericParameters (MonoReflectionType *type)
1530 MONO_ARCH_SAVE_REGS;
1532 if (type->type->byref)
1534 klass = mono_class_from_mono_type (type->type);
1535 if (klass->gen_params)
1541 ves_icall_TypeBuilder_get_IsUnboundGenericParameter (MonoReflectionTypeBuilder *tb)
1543 MONO_ARCH_SAVE_REGS;
1545 if (tb->type.type->byref)
1547 if (tb->type.type->type == MONO_TYPE_VAR || tb->type.type->type == MONO_TYPE_MVAR)
1553 ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params)
1556 * Invoke from reflection is supposed to always be a virtual call (the API
1557 * is stupid), mono_runtime_invoke_*() calls the provided method, allowing
1558 * greater flexibility.
1560 MonoMethod *m = method->method;
1563 MONO_ARCH_SAVE_REGS;
1566 if (!mono_object_isinst (this, m->klass))
1567 mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
1568 m = mono_object_get_virtual_method (this, m);
1569 } else if (!(m->flags & METHOD_ATTRIBUTE_STATIC) && strcmp (m->name, ".ctor") && !m->wrapper_type)
1570 mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
1572 pcount = params? mono_array_length (params): 0;
1573 if (pcount != m->signature->param_count)
1574 mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetParameterCountException"));
1576 if (m->klass->rank && !strcmp (m->name, ".ctor")) {
1579 guint32 *lower_bounds;
1580 pcount = mono_array_length (params);
1581 lengths = alloca (sizeof (guint32) * pcount);
1582 for (i = 0; i < pcount; ++i)
1583 lengths [i] = *(gint32*) ((char*)mono_array_get (params, gpointer, i) + sizeof (MonoObject));
1585 if (m->klass->rank == pcount) {
1586 /* Only lengths provided. */
1587 lower_bounds = NULL;
1589 g_assert (pcount == (m->klass->rank * 2));
1590 /* lower bounds are first. */
1591 lower_bounds = lengths;
1592 lengths += m->klass->rank;
1595 return (MonoObject*)mono_array_new_full (mono_object_domain (params), m->klass, lengths, lower_bounds);
1597 return mono_runtime_invoke_array (m, this, params, NULL);
1601 ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoArray *params, MonoArray **outArgs)
1603 MonoDomain *domain = mono_object_domain (method);
1604 MonoMethod *m = method->method;
1605 MonoMethodSignature *sig = m->signature;
1606 MonoArray *out_args;
1608 int i, j, outarg_count = 0;
1610 MONO_ARCH_SAVE_REGS;
1612 if (m->klass == mono_defaults.object_class) {
1614 if (!strcmp (m->name, "FieldGetter")) {
1615 MonoClass *k = this->vtable->klass;
1616 MonoString *name = mono_array_get (params, MonoString *, 1);
1619 str = mono_string_to_utf8 (name);
1621 for (i = 0; i < k->field.count; i++) {
1622 if (!strcmp (k->fields [i].name, str)) {
1623 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
1624 if (field_klass->valuetype)
1625 result = mono_value_box (domain, field_klass,
1626 (char *)this + k->fields [i].offset);
1628 result = *((gpointer *)((char *)this + k->fields [i].offset));
1631 out_args = mono_array_new (domain, mono_defaults.object_class, 1);
1632 *outArgs = out_args;
1633 mono_array_set (out_args, gpointer, 0, result);
1640 g_assert_not_reached ();
1642 } else if (!strcmp (m->name, "FieldSetter")) {
1643 MonoClass *k = this->vtable->klass;
1644 MonoString *name = mono_array_get (params, MonoString *, 1);
1648 str = mono_string_to_utf8 (name);
1650 for (i = 0; i < k->field.count; i++) {
1651 if (!strcmp (k->fields [i].name, str)) {
1652 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
1653 MonoObject *val = mono_array_get (params, gpointer, 2);
1655 if (field_klass->valuetype) {
1656 size = mono_type_size (k->fields [i].type, &align);
1657 memcpy ((char *)this + k->fields [i].offset,
1658 ((char *)val) + sizeof (MonoObject), size);
1660 *(MonoObject**)((char *)this + k->fields [i].offset) = val;
1662 out_args = mono_array_new (domain, mono_defaults.object_class, 0);
1663 *outArgs = out_args;
1671 g_assert_not_reached ();
1676 for (i = 0; i < mono_array_length (params); i++) {
1677 if (sig->params [i]->byref)
1681 out_args = mono_array_new (domain, mono_defaults.object_class, outarg_count);
1683 /* fixme: handle constructors? */
1684 if (!strcmp (method->method->name, ".ctor"))
1685 g_assert_not_reached ();
1687 result = mono_runtime_invoke_array (method->method, this, params, NULL);
1689 for (i = 0, j = 0; i < mono_array_length (params); i++) {
1690 if (sig->params [i]->byref) {
1692 arg = mono_array_get (params, gpointer, i);
1693 mono_array_set (out_args, gpointer, j, arg);
1698 *outArgs = out_args;
1704 ves_icall_System_Enum_ToObject (MonoReflectionType *type, MonoObject *obj)
1707 MonoClass *enumc, *objc;
1711 MONO_ARCH_SAVE_REGS;
1713 MONO_CHECK_ARG_NULL (type);
1714 MONO_CHECK_ARG_NULL (obj);
1716 domain = mono_object_domain (type);
1717 enumc = mono_class_from_mono_type (type->type);
1718 objc = obj->vtable->klass;
1720 MONO_CHECK_ARG (obj, enumc->enumtype == TRUE);
1721 MONO_CHECK_ARG (obj, (objc->enumtype) || (objc->byval_arg.type >= MONO_TYPE_I1 &&
1722 objc->byval_arg.type <= MONO_TYPE_U8));
1724 s1 = mono_class_value_size (enumc, NULL);
1725 s2 = mono_class_value_size (objc, NULL);
1727 res = mono_object_new (domain, enumc);
1729 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1730 memcpy ((char *)res + sizeof (MonoObject), (char *)obj + sizeof (MonoObject), MIN (s1, s2));
1732 memcpy ((char *)res + sizeof (MonoObject) + (s1 > s2 ? s1 - s2 : 0),
1733 (char *)obj + sizeof (MonoObject) + (s2 > s1 ? s2 - s1 : 0),
1740 ves_icall_System_Enum_get_value (MonoObject *this)
1748 MONO_ARCH_SAVE_REGS;
1753 g_assert (this->vtable->klass->enumtype);
1755 enumc = mono_class_from_mono_type (this->vtable->klass->enum_basetype);
1756 res = mono_object_new (mono_object_domain (this), enumc);
1757 dst = (char *)res + sizeof (MonoObject);
1758 src = (char *)this + sizeof (MonoObject);
1759 size = mono_class_value_size (enumc, NULL);
1761 memcpy (dst, src, size);
1767 ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
1769 MonoDomain *domain = mono_object_domain (type);
1770 MonoClass *enumc = mono_class_from_mono_type (type->type);
1771 guint i, j, nvalues, crow;
1772 MonoClassField *field;
1774 MONO_ARCH_SAVE_REGS;
1776 info->utype = mono_type_get_object (domain, enumc->enum_basetype);
1777 nvalues = enumc->field.count - 1;
1778 info->names = mono_array_new (domain, mono_defaults.string_class, nvalues);
1779 info->values = mono_array_new (domain, enumc, nvalues);
1781 for (i = 0, j = 0; i < enumc->field.count; ++i) {
1782 field = &enumc->fields [i];
1783 if (strcmp ("value__", field->name) == 0)
1785 mono_array_set (info->names, gpointer, j, mono_string_new (domain, field->name));
1787 crow = mono_metadata_get_constant_index (enumc->image, MONO_TOKEN_FIELD_DEF | (i+enumc->field.first+1));
1788 crow = mono_metadata_decode_row_col (&enumc->image->tables [MONO_TABLE_CONSTANT], crow-1, MONO_CONSTANT_VALUE);
1789 /* 1 is the length of the blob */
1790 field->data = 1 + mono_metadata_blob_heap (enumc->image, crow);
1792 switch (enumc->enum_basetype->type) {
1795 mono_array_set (info->values, gchar, j, *field->data);
1797 case MONO_TYPE_CHAR:
1800 mono_array_set (info->values, gint16, j, read16 (field->data));
1804 mono_array_set (info->values, gint32, j, read32 (field->data));
1808 mono_array_set (info->values, gint64, j, read64 (field->data));
1811 g_error ("Implement type 0x%02x in get_enum_info", enumc->enum_basetype->type);
1818 BFLAGS_IgnoreCase = 1,
1819 BFLAGS_DeclaredOnly = 2,
1820 BFLAGS_Instance = 4,
1822 BFLAGS_Public = 0x10,
1823 BFLAGS_NonPublic = 0x20,
1824 BFLAGS_InvokeMethod = 0x100,
1825 BFLAGS_CreateInstance = 0x200,
1826 BFLAGS_GetField = 0x400,
1827 BFLAGS_SetField = 0x800,
1828 BFLAGS_GetProperty = 0x1000,
1829 BFLAGS_SetProperty = 0x2000,
1830 BFLAGS_ExactBinding = 0x10000,
1831 BFLAGS_SuppressChangeType = 0x20000,
1832 BFLAGS_OptionalParamBinding = 0x40000
1835 static MonoReflectionField *
1836 ves_icall_Type_GetField (MonoReflectionType *type, MonoString *name, guint32 bflags)
1839 MonoClass *startklass, *klass;
1841 MonoClassField *field;
1843 domain = ((MonoObject *)type)->vtable->domain;
1844 klass = startklass = mono_class_from_mono_type (type->type);
1846 MONO_ARCH_SAVE_REGS;
1849 mono_raise_exception (mono_get_exception_argument_null ("name"));
1852 for (i = 0; i < klass->field.count; ++i) {
1854 field = &klass->fields [i];
1855 if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
1856 if (bflags & BFLAGS_Public)
1859 if (bflags & BFLAGS_NonPublic)
1865 if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1866 if (bflags & BFLAGS_Static)
1869 if (bflags & BFLAGS_Instance)
1876 utf8_name = mono_string_to_utf8 (name);
1878 if (strcmp (field->name, utf8_name)) {
1884 return mono_field_get_object (domain, klass, field);
1886 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1893 ves_icall_Type_GetFields (MonoReflectionType *type, guint32 bflags)
1896 GSList *l = NULL, *tmp;
1897 MonoClass *startklass, *klass;
1901 MonoClassField *field;
1903 MONO_ARCH_SAVE_REGS;
1905 domain = ((MonoObject *)type)->vtable->domain;
1906 klass = startklass = mono_class_from_mono_type (type->type);
1909 for (i = 0; i < klass->field.count; ++i) {
1911 field = &klass->fields [i];
1912 if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
1913 if (bflags & BFLAGS_Public)
1916 if (bflags & BFLAGS_NonPublic)
1922 if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1923 if (bflags & BFLAGS_Static)
1926 if (bflags & BFLAGS_Instance)
1932 member = (MonoObject*)mono_field_get_object (domain, klass, field);
1933 l = g_slist_prepend (l, member);
1935 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1937 len = g_slist_length (l);
1938 res = mono_array_new (domain, mono_defaults.field_info_class, len);
1940 tmp = l = g_slist_reverse (l);
1941 for (; tmp; tmp = tmp->next, ++i)
1942 mono_array_set (res, gpointer, i, tmp->data);
1948 ves_icall_Type_GetMethods (MonoReflectionType *type, guint32 bflags)
1951 GSList *l = NULL, *tmp;
1952 MonoClass *startklass, *klass;
1957 GHashTable *method_slots = g_hash_table_new (NULL, NULL);
1959 MONO_ARCH_SAVE_REGS;
1961 domain = ((MonoObject *)type)->vtable->domain;
1962 klass = startklass = mono_class_from_mono_type (type->type);
1966 for (i = 0; i < klass->method.count; ++i) {
1968 method = klass->methods [i];
1969 if (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0)
1971 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1972 if (bflags & BFLAGS_Public)
1975 if (bflags & BFLAGS_NonPublic)
1981 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1982 if (bflags & BFLAGS_Static)
1985 if (bflags & BFLAGS_Instance)
1992 if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
1994 g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), method);
1995 member = (MonoObject*)mono_method_get_object (domain, method, startklass);
1997 l = g_slist_prepend (l, member);
2000 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
2002 res = mono_array_new (domain, mono_defaults.method_info_class, len);
2005 tmp = l = g_slist_reverse (l);
2007 for (; tmp; tmp = tmp->next, ++i)
2008 mono_array_set (res, gpointer, i, tmp->data);
2010 g_hash_table_destroy (method_slots);
2015 ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
2018 GSList *l = NULL, *tmp;
2019 static MonoClass *System_Reflection_ConstructorInfo;
2020 MonoClass *startklass, *klass;
2026 MONO_ARCH_SAVE_REGS;
2028 domain = ((MonoObject *)type)->vtable->domain;
2029 klass = startklass = mono_class_from_mono_type (type->type);
2031 for (i = 0; i < klass->method.count; ++i) {
2033 method = klass->methods [i];
2034 if (strcmp (method->name, ".ctor") && strcmp (method->name, ".cctor"))
2036 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
2037 if (bflags & BFLAGS_Public)
2040 if (bflags & BFLAGS_NonPublic)
2046 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
2047 if (bflags & BFLAGS_Static)
2050 if (bflags & BFLAGS_Instance)
2056 member = (MonoObject*)mono_method_get_object (domain, method, startklass);
2058 l = g_slist_prepend (l, member);
2060 len = g_slist_length (l);
2061 if (!System_Reflection_ConstructorInfo)
2062 System_Reflection_ConstructorInfo = mono_class_from_name (
2063 mono_defaults.corlib, "System.Reflection", "ConstructorInfo");
2064 res = mono_array_new (domain, System_Reflection_ConstructorInfo, len);
2066 tmp = l = g_slist_reverse (l);
2067 for (; tmp; tmp = tmp->next, ++i)
2068 mono_array_set (res, gpointer, i, tmp->data);
2074 ves_icall_Type_GetProperties (MonoReflectionType *type, guint32 bflags)
2077 GSList *l = NULL, *tmp;
2078 static MonoClass *System_Reflection_PropertyInfo;
2079 MonoClass *startklass, *klass;
2085 GHashTable *method_slots = g_hash_table_new (NULL, NULL);
2087 MONO_ARCH_SAVE_REGS;
2089 domain = ((MonoObject *)type)->vtable->domain;
2090 klass = startklass = mono_class_from_mono_type (type->type);
2093 for (i = 0; i < klass->property.count; ++i) {
2094 prop = &klass->properties [i];
2099 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
2100 if (bflags & BFLAGS_Public)
2103 if (bflags & BFLAGS_NonPublic)
2109 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
2110 if (bflags & BFLAGS_Static)
2113 if (bflags & BFLAGS_Instance)
2121 if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
2123 g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), prop);
2125 l = g_slist_prepend (l, mono_property_get_object (domain, klass, prop));
2128 if ((!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)))
2130 if (!System_Reflection_PropertyInfo)
2131 System_Reflection_PropertyInfo = mono_class_from_name (
2132 mono_defaults.corlib, "System.Reflection", "PropertyInfo");
2133 res = mono_array_new (domain, System_Reflection_PropertyInfo, len);
2136 tmp = l = g_slist_reverse (l);
2138 for (; tmp; tmp = tmp->next, ++i)
2139 mono_array_set (res, gpointer, i, tmp->data);
2141 g_hash_table_destroy (method_slots);
2145 static MonoReflectionEvent *
2146 ves_icall_MonoType_GetEvent (MonoReflectionType *type, MonoString *name, guint32 bflags)
2155 MONO_ARCH_SAVE_REGS;
2157 event_name = mono_string_to_utf8 (name);
2158 klass = mono_class_from_mono_type (type->type);
2159 domain = mono_object_domain (type);
2162 for (i = 0; i < klass->event.count; i++) {
2163 event = &klass->events [i];
2164 if (strcmp (event->name, event_name))
2167 method = event->add;
2169 method = event->remove;
2171 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
2172 if (!(bflags & BFLAGS_Public))
2175 if (!(bflags & BFLAGS_NonPublic))
2179 g_free (event_name);
2180 return mono_event_get_object (domain, klass, event);
2183 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
2186 g_free (event_name);
2191 ves_icall_Type_GetEvents (MonoReflectionType *type, guint32 bflags)
2194 GSList *l = NULL, *tmp;
2195 static MonoClass *System_Reflection_EventInfo;
2196 MonoClass *startklass, *klass;
2202 MONO_ARCH_SAVE_REGS;
2204 domain = ((MonoObject *)type)->vtable->domain;
2205 klass = startklass = mono_class_from_mono_type (type->type);
2208 for (i = 0; i < klass->event.count; ++i) {
2209 event = &klass->events [i];
2211 method = event->add;
2213 method = event->remove;
2214 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
2215 if (bflags & BFLAGS_Public)
2218 if (bflags & BFLAGS_NonPublic)
2224 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
2225 if (bflags & BFLAGS_Static)
2228 if (bflags & BFLAGS_Instance)
2235 l = g_slist_prepend (l, mono_event_get_object (domain, klass, event));
2237 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
2239 len = g_slist_length (l);
2240 if (!System_Reflection_EventInfo)
2241 System_Reflection_EventInfo = mono_class_from_name (
2242 mono_defaults.corlib, "System.Reflection", "EventInfo");
2243 res = mono_array_new (domain, System_Reflection_EventInfo, len);
2246 tmp = l = g_slist_reverse (l);
2248 for (; tmp; tmp = tmp->next, ++i)
2249 mono_array_set (res, gpointer, i, tmp->data);
2254 static MonoReflectionType *
2255 ves_icall_Type_GetNestedType (MonoReflectionType *type, MonoString *name, guint32 bflags)
2258 MonoClass *startklass, *klass;
2263 MONO_ARCH_SAVE_REGS;
2265 domain = ((MonoObject *)type)->vtable->domain;
2266 klass = startklass = mono_class_from_mono_type (type->type);
2267 str = mono_string_to_utf8 (name);
2270 for (tmpn = klass->nested_classes; tmpn; tmpn = tmpn->next) {
2272 nested = tmpn->data;
2273 if ((nested->flags & TYPE_ATTRIBUTE_VISIBILITY_MASK) == TYPE_ATTRIBUTE_NESTED_PUBLIC) {
2274 if (bflags & BFLAGS_Public)
2277 if (bflags & BFLAGS_NonPublic)
2282 if (strcmp (nested->name, str) == 0){
2284 return mono_type_get_object (domain, &nested->byval_arg);
2287 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
2294 ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags)
2297 GSList *l = NULL, *tmp;
2299 MonoClass *startklass, *klass;
2305 MONO_ARCH_SAVE_REGS;
2307 domain = ((MonoObject *)type)->vtable->domain;
2308 klass = startklass = mono_class_from_mono_type (type->type);
2310 for (tmpn = klass->nested_classes; tmpn; tmpn = tmpn->next) {
2312 nested = tmpn->data;
2313 if ((nested->flags & TYPE_ATTRIBUTE_VISIBILITY_MASK) == TYPE_ATTRIBUTE_NESTED_PUBLIC) {
2314 if (bflags & BFLAGS_Public)
2317 if (bflags & BFLAGS_NonPublic)
2322 member = (MonoObject*)mono_type_get_object (domain, &nested->byval_arg);
2323 l = g_slist_prepend (l, member);
2325 len = g_slist_length (l);
2326 res = mono_array_new (domain, mono_defaults.monotype_class, len);
2328 tmp = l = g_slist_reverse (l);
2329 for (; tmp; tmp = tmp->next, ++i)
2330 mono_array_set (res, gpointer, i, tmp->data);
2335 static MonoReflectionType*
2336 ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly *assembly, MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase)
2340 MonoTypeNameParse info;
2342 MONO_ARCH_SAVE_REGS;
2344 str = mono_string_to_utf8 (name);
2345 /*g_print ("requested type %s in %s\n", str, assembly->assembly->aname.name);*/
2346 if (!mono_reflection_parse_type (str, &info)) {
2348 g_list_free (info.modifiers);
2349 g_list_free (info.nested);
2350 if (throwOnError) /* uhm: this is a parse error, though... */
2351 mono_raise_exception (mono_get_exception_type_load (name));
2352 /*g_print ("failed parse\n");*/
2356 type = mono_reflection_get_type (assembly->assembly->image, &info, ignoreCase);
2358 g_list_free (info.modifiers);
2359 g_list_free (info.nested);
2362 mono_raise_exception (mono_get_exception_type_load (name));
2363 /* g_print ("failed find\n"); */
2366 /* g_print ("got it\n"); */
2367 return mono_type_get_object (mono_object_domain (assembly), type);
2372 ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly *assembly)
2374 MonoDomain *domain = mono_object_domain (assembly);
2375 MonoAssembly *mass = assembly->assembly;
2380 MONO_ARCH_SAVE_REGS;
2382 absolute = g_build_filename (mass->basedir, mass->image->module_name, NULL);
2383 uri = g_filename_to_uri (absolute, NULL, NULL);
2384 res = mono_string_new (domain, uri);
2391 ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssembly *assembly)
2393 MonoDomain *domain = mono_object_domain (assembly);
2395 char *name = g_build_filename (
2396 assembly->assembly->basedir,
2397 assembly->assembly->image->module_name, NULL);
2399 MONO_ARCH_SAVE_REGS;
2401 res = mono_string_new (domain, name);
2407 ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion (MonoReflectionAssembly *assembly)
2409 MonoDomain *domain = mono_object_domain (assembly);
2411 MONO_ARCH_SAVE_REGS;
2413 return mono_string_new (domain, assembly->assembly->image->version);
2416 static MonoReflectionMethod*
2417 ves_icall_System_Reflection_Assembly_get_EntryPoint (MonoReflectionAssembly *assembly)
2419 guint32 token = mono_image_get_entry_point (assembly->assembly->image);
2421 MONO_ARCH_SAVE_REGS;
2425 return mono_method_get_object (mono_object_domain (assembly), mono_get_method (assembly->assembly->image, token, NULL), NULL);
2429 ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAssembly *assembly)
2431 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
2432 MonoArray *result = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, table->rows);
2436 MONO_ARCH_SAVE_REGS;
2438 for (i = 0; i < table->rows; ++i) {
2439 val = mono_metadata_string_heap (assembly->assembly->image, mono_metadata_decode_row_col (table, i, MONO_MANIFEST_NAME));
2440 mono_array_set (result, gpointer, i, mono_string_new (mono_object_domain (assembly), val));
2446 ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAssembly *assembly)
2448 static MonoClass *System_Reflection_AssemblyName;
2451 MonoDomain *domain = mono_object_domain (assembly);
2454 MONO_ARCH_SAVE_REGS;
2456 if (!System_Reflection_AssemblyName)
2457 System_Reflection_AssemblyName = mono_class_from_name (
2458 mono_defaults.corlib, "System.Reflection", "AssemblyName");
2460 for (ptr = assembly->assembly->image->references; ptr && *ptr; ptr++)
2463 result = mono_array_new (mono_object_domain (assembly), System_Reflection_AssemblyName, count);
2465 for (i = 0; i < count; i++) {
2466 MonoAssembly *assem = assembly->assembly->image->references [i];
2467 MonoReflectionAssemblyName *aname;
2468 char *codebase, *absolute;
2470 aname = (MonoReflectionAssemblyName *) mono_object_new (
2471 domain, System_Reflection_AssemblyName);
2473 if (strcmp (assem->aname.name, "corlib") == 0)
2474 aname->name = mono_string_new (domain, "mscorlib");
2476 aname->name = mono_string_new (domain, assem->aname.name);
2477 aname->major = assem->aname.major;
2479 absolute = g_build_filename (assem->basedir, assem->image->module_name, NULL);
2480 codebase = g_filename_to_uri (absolute, NULL, NULL);
2481 aname->codebase = mono_string_new (domain, codebase);
2484 mono_array_set (result, gpointer, i, aname);
2495 foreach_namespace (const char* key, gconstpointer val, NameSpaceInfo *info)
2497 MonoString *name = mono_string_new (mono_object_domain (info->res), key);
2499 mono_array_set (info->res, gpointer, info->idx, name);
2504 ves_icall_System_Reflection_Assembly_GetNamespaces (MonoReflectionAssembly *assembly)
2506 MonoImage *img = assembly->assembly->image;
2511 MONO_ARCH_SAVE_REGS;
2513 n = g_hash_table_size (img->name_cache);
2514 res = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, n);
2517 g_hash_table_foreach (img->name_cache, (GHFunc)foreach_namespace, &info);
2521 /* move this in some file in mono/util/ */
2523 g_concat_dir_and_file (const char *dir, const char *file)
2525 g_return_val_if_fail (dir != NULL, NULL);
2526 g_return_val_if_fail (file != NULL, NULL);
2529 * If the directory name doesn't have a / on the end, we need
2530 * to add one so we get a proper path to the file
2532 if (dir [strlen(dir) - 1] != G_DIR_SEPARATOR)
2533 return g_strconcat (dir, G_DIR_SEPARATOR_S, file, NULL);
2535 return g_strconcat (dir, file, NULL);
2539 ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflectionAssembly *assembly, MonoString *name, gint32 *size)
2541 char *n = mono_string_to_utf8 (name);
2542 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
2544 guint32 cols [MONO_MANIFEST_SIZE];
2547 MONO_ARCH_SAVE_REGS;
2549 for (i = 0; i < table->rows; ++i) {
2550 mono_metadata_decode_row (table, i, cols, MONO_MANIFEST_SIZE);
2551 val = mono_metadata_string_heap (assembly->assembly->image, cols [MONO_MANIFEST_NAME]);
2552 if (strcmp (val, n) == 0)
2556 if (i == table->rows)
2559 if (cols [MONO_MANIFEST_IMPLEMENTATION]) {
2561 * this code should only be called after obtaining the
2562 * ResourceInfo and handling the other cases.
2564 g_assert_not_reached ();
2568 return (void*)mono_image_get_resource (assembly->assembly->image, cols [MONO_MANIFEST_OFFSET], size);
2572 ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (MonoReflectionAssembly *assembly, MonoString *name, MonoManifestResourceInfo *info)
2574 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
2576 guint32 cols [MONO_MANIFEST_SIZE];
2577 guint32 file_cols [MONO_FILE_SIZE];
2581 MONO_ARCH_SAVE_REGS;
2583 n = mono_string_to_utf8 (name);
2584 for (i = 0; i < table->rows; ++i) {
2585 mono_metadata_decode_row (table, i, cols, MONO_MANIFEST_SIZE);
2586 val = mono_metadata_string_heap (assembly->assembly->image, cols [MONO_MANIFEST_NAME]);
2587 if (strcmp (val, n) == 0)
2591 if (i == table->rows)
2594 if (!cols [MONO_MANIFEST_IMPLEMENTATION]) {
2595 info->location = RESOURCE_LOCATION_EMBEDDED | RESOURCE_LOCATION_IN_MANIFEST;
2598 switch (cols [MONO_MANIFEST_IMPLEMENTATION] & IMPLEMENTATION_MASK) {
2599 case IMPLEMENTATION_FILE:
2600 i = cols [MONO_MANIFEST_IMPLEMENTATION] >> IMPLEMENTATION_BITS;
2601 table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
2602 mono_metadata_decode_row (table, i - 1, file_cols, MONO_FILE_SIZE);
2603 val = mono_metadata_string_heap (assembly->assembly->image, file_cols [MONO_FILE_NAME]);
2604 info->filename = mono_string_new (mono_object_domain (assembly), val);
2605 if (file_cols [MONO_FILE_FLAGS] && FILE_CONTAINS_NO_METADATA)
2608 info->location = RESOURCE_LOCATION_EMBEDDED;
2611 case IMPLEMENTATION_ASSEMBLYREF:
2612 i = cols [MONO_MANIFEST_IMPLEMENTATION] >> IMPLEMENTATION_BITS;
2613 info->assembly = mono_assembly_get_object (mono_domain_get (), assembly->assembly->image->references [i - 1]);
2615 // Obtain info recursively
2616 ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (info->assembly, name, info);
2617 info->location |= RESOURCE_LOCATION_ANOTHER_ASSEMBLY;
2620 case IMPLEMENTATION_EXP_TYPE:
2621 g_assert_not_reached ();
2630 ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssembly *assembly, MonoString *name)
2632 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
2633 MonoArray *result = NULL;
2638 MONO_ARCH_SAVE_REGS;
2640 /* check hash if needed */
2642 n = mono_string_to_utf8 (name);
2643 for (i = 0; i < table->rows; ++i) {
2644 val = mono_metadata_string_heap (assembly->assembly->image, mono_metadata_decode_row_col (table, i, MONO_FILE_NAME));
2645 if (strcmp (val, n) == 0) {
2648 n = g_concat_dir_and_file (assembly->assembly->basedir, val);
2649 fn = mono_string_new (mono_object_domain (assembly), n);
2651 return (MonoObject*)fn;
2658 for (i = 0; i < table->rows; ++i) {
2659 result = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, table->rows);
2660 val = mono_metadata_string_heap (assembly->assembly->image, mono_metadata_decode_row_col (table, i, MONO_FILE_NAME));
2661 n = g_concat_dir_and_file (assembly->assembly->basedir, val);
2662 mono_array_set (result, gpointer, i, mono_string_new (mono_object_domain (assembly), n));
2665 return (MonoObject*)result;
2669 ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly *assembly)
2671 MonoDomain *domain = mono_domain_get();
2674 int i, module_count = 0, file_count = 0;
2675 MonoImage **modules = assembly->assembly->image->modules;
2676 MonoTableInfo *table;
2679 while (modules[module_count])
2683 table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
2684 file_count = table->rows;
2686 g_assert( assembly->assembly->image != NULL);
2689 klass = mono_class_from_name ( mono_defaults.corlib, "System.Reflection", "Module");
2690 res = mono_array_new (domain, klass, module_count + file_count);
2692 mono_array_set (res, gpointer, 0, mono_module_get_object (domain, assembly->assembly->image));
2693 for ( i = 1; i < module_count; ++i )
2694 mono_array_set (res, gpointer, i, mono_module_get_object (domain, modules[i]));
2696 for (i = 0; i < table->rows; ++i)
2697 mono_array_set (res, gpointer, module_count + i, mono_module_file_get_object (domain, assembly->assembly->image, i));
2702 static MonoReflectionMethod*
2703 ves_icall_GetCurrentMethod (void)
2705 MonoMethod *m = mono_method_get_last_managed ();
2707 MONO_ARCH_SAVE_REGS;
2709 return mono_method_get_object (mono_domain_get (), m, NULL);
2712 static MonoReflectionAssembly*
2713 ves_icall_System_Reflection_Assembly_GetExecutingAssembly (void)
2715 MonoMethod *m = mono_method_get_last_managed ();
2717 MONO_ARCH_SAVE_REGS;
2719 return mono_assembly_get_object (mono_domain_get (), m->klass->image->assembly);
2724 get_caller (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
2726 MonoMethod **dest = data;
2728 /* skip unmanaged frames */
2743 static MonoReflectionAssembly*
2744 ves_icall_System_Reflection_Assembly_GetEntryAssembly (void)
2746 MonoDomain* domain = mono_domain_get ();
2748 MONO_ARCH_SAVE_REGS;
2750 if (!domain->entry_assembly)
2751 domain = mono_root_domain;
2753 return mono_assembly_get_object (domain, domain->entry_assembly);
2757 static MonoReflectionAssembly*
2758 ves_icall_System_Reflection_Assembly_GetCallingAssembly (void)
2760 MonoMethod *m = mono_method_get_last_managed ();
2761 MonoMethod *dest = m;
2763 MONO_ARCH_SAVE_REGS;
2765 mono_stack_walk (get_caller, &dest);
2768 return mono_assembly_get_object (mono_domain_get (), dest->klass->image->assembly);
2772 ves_icall_System_MonoType_getFullName (MonoReflectionType *object)
2774 MonoDomain *domain = mono_object_domain (object);
2778 MONO_ARCH_SAVE_REGS;
2780 name = mono_type_get_name (object->type);
2781 res = mono_string_new (domain, name);
2788 ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, MonoReflectionAssemblyName *aname)
2790 MonoAssemblyName *name = &assembly->assembly->aname;
2792 MONO_ARCH_SAVE_REGS;
2794 if (strcmp (name->name, "corlib") == 0)
2795 aname->name = mono_string_new (mono_object_domain (assembly), "mscorlib");
2797 aname->name = mono_string_new (mono_object_domain (assembly), name->name);
2799 aname->major = name->major;
2800 aname->minor = name->minor;
2801 aname->build = name->build;
2802 aname->revision = name->revision;
2806 ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly)
2808 MonoDomain *domain = mono_object_domain (assembly);
2811 MonoTableInfo *tdef = &assembly->assembly->image->tables [MONO_TABLE_TYPEDEF];
2813 guint32 attrs, visibility;
2815 MONO_ARCH_SAVE_REGS;
2817 /* we start the count from 1 because we skip the special type <Module> */
2820 for (i = 1; i < tdef->rows; ++i) {
2821 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
2822 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
2823 if (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)
2827 count = tdef->rows - 1;
2829 res = mono_array_new (domain, mono_defaults.monotype_class, count);
2831 for (i = 1; i < tdef->rows; ++i) {
2832 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
2833 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
2834 if (!exportedOnly || (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)) {
2835 klass = mono_class_get (assembly->assembly->image, (i + 1) | MONO_TOKEN_TYPE_DEF);
2836 mono_array_set (res, gpointer, count, mono_type_get_object (domain, &klass->byval_arg));
2844 static MonoReflectionType*
2845 ves_icall_System_Reflection_Module_GetGlobalType (MonoReflectionModule *module)
2847 MonoDomain *domain = mono_object_domain (module);
2850 MONO_ARCH_SAVE_REGS;
2852 g_assert (module->image);
2853 klass = mono_class_get (module->image, 1 | MONO_TOKEN_TYPE_DEF);
2854 return mono_type_get_object (domain, &klass->byval_arg);
2858 ves_icall_System_Reflection_Module_GetGuidInternal (MonoReflectionModule *module)
2860 MonoDomain *domain = mono_object_domain (module);
2862 MONO_ARCH_SAVE_REGS;
2864 g_assert (module->image);
2865 return mono_string_new (domain, module->image->guid);
2868 static MonoReflectionType*
2869 ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, MonoString *smodifiers)
2872 int isbyref = 0, rank;
2873 char *str = mono_string_to_utf8 (smodifiers);
2876 MONO_ARCH_SAVE_REGS;
2878 klass = mono_class_from_mono_type (tb->type.type);
2880 /* logic taken from mono_reflection_parse_type(): keep in sync */
2884 if (isbyref) { /* only one level allowed by the spec */
2891 return mono_type_get_object (mono_object_domain (tb), &klass->this_arg);
2894 klass = mono_ptr_class_get (&klass->byval_arg);
2895 mono_class_init (klass);
2906 else if (*p != '*') { /* '*' means unknown lower bound */
2917 klass = mono_array_class_get (klass, rank);
2918 mono_class_init (klass);
2925 return mono_type_get_object (mono_object_domain (tb), &klass->byval_arg);
2929 ves_icall_Type_IsArrayImpl (MonoReflectionType *t)
2934 MONO_ARCH_SAVE_REGS;
2937 res = !type->byref && (type->type == MONO_TYPE_ARRAY || type->type == MONO_TYPE_SZARRAY);
2943 ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, MonoObject *target,
2944 MonoReflectionMethod *info)
2946 MonoClass *delegate_class = mono_class_from_mono_type (type->type);
2947 MonoObject *delegate;
2950 MONO_ARCH_SAVE_REGS;
2952 mono_assert (delegate_class->parent == mono_defaults.multicastdelegate_class);
2954 delegate = mono_object_new (mono_object_domain (type), delegate_class);
2956 func = mono_compile_method (info->method);
2958 mono_delegate_ctor (delegate, target, func);
2964 * Magic number to convert a time which is relative to
2965 * Jan 1, 1970 into a value which is relative to Jan 1, 0001.
2967 #define EPOCH_ADJUST ((gint64)62135596800L)
2970 ves_icall_System_DateTime_GetNow (void)
2972 #ifdef PLATFORM_WIN32
2977 SystemTimeToFileTime (&st, &ft);
2978 return (gint64)504911232000000000L + ((((gint64)ft.dwHighDateTime)<<32) | ft.dwLowDateTime);
2980 /* FIXME: put this in io-layer and call it GetLocalTime */
2984 MONO_ARCH_SAVE_REGS;
2986 if (gettimeofday (&tv, NULL) == 0) {
2987 res = (((gint64)tv.tv_sec + EPOCH_ADJUST)* 1000000 + tv.tv_usec)*10;
2990 /* fixme: raise exception */
2996 * This is heavily based on zdump.c from glibc 2.2.
2998 * * data[0]: start of daylight saving time (in DateTime ticks).
2999 * * data[1]: end of daylight saving time (in DateTime ticks).
3000 * * data[2]: utcoffset (in TimeSpan ticks).
3001 * * data[3]: additional offset when daylight saving (in TimeSpan ticks).
3002 * * name[0]: name of this timezone when not daylight saving.
3003 * * name[1]: name of this timezone when daylight saving.
3005 * FIXME: This only works with "standard" Unix dates (years between 1900 and 2100) while
3006 * the class library allows years between 1 and 9999.
3008 * Returns true on success and zero on failure.
3011 ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names)
3013 #ifndef PLATFORM_WIN32
3014 MonoDomain *domain = mono_domain_get ();
3015 struct tm start, tt;
3019 int is_daylight = 0, day;
3022 MONO_ARCH_SAVE_REGS;
3024 MONO_CHECK_ARG_NULL (data);
3025 MONO_CHECK_ARG_NULL (names);
3027 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
3028 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
3031 * no info is better than crashing: we'll need our own tz data to make
3032 * this work properly, anyway. The range is reduced to 1970 .. 2037 because
3033 * that is what mktime is guaranteed to support (we get into an infinite loop
3036 if ((year < 1970) || (year > 2037)) {
3038 tt = *localtime (&t);
3039 strftime (tzone, sizeof (tzone), "%Z", &tt);
3040 mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tzone));
3041 mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tzone));
3045 memset (&start, 0, sizeof (start));
3048 start.tm_year = year-1900;
3050 t = mktime (&start);
3051 #if defined (HAVE_TIMEZONE)
3052 #define gmt_offset(x) (-1 * (((timezone / 60 / 60) - daylight) * 100))
3053 #elif defined (HAVE_TM_GMTOFF)
3054 #define gmt_offset(x) x.tm_gmtoff
3056 #error Neither HAVE_TIMEZONE nor HAVE_TM_GMTOFF defined. Rerun autoheader, autoconf, etc.
3059 gmtoff = gmt_offset (start);
3061 /* For each day of the year, calculate the tm_gmtoff. */
3062 for (day = 0; day < 365; day++) {
3065 tt = *localtime (&t);
3067 /* Daylight saving starts or ends here. */
3068 if (gmt_offset (tt) != gmtoff) {
3072 /* Try to find the exact hour when daylight saving starts/ends. */
3076 tt1 = *localtime (&t1);
3077 } while (gmt_offset (tt1) != gmtoff);
3079 /* Try to find the exact minute when daylight saving starts/ends. */
3082 tt1 = *localtime (&t1);
3083 } while (gmt_offset (tt1) == gmtoff);
3085 strftime (tzone, sizeof (tzone), "%Z", &tt);
3087 /* Write data, if we're already in daylight saving, we're done. */
3089 mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tzone));
3090 mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
3093 mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tzone));
3094 mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
3098 /* This is only set once when we enter daylight saving. */
3099 mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L);
3100 mono_array_set ((*data), gint64, 3, (gint64)(gmt_offset (tt) - gmtoff) * 10000000L);
3102 gmtoff = gmt_offset (tt);
3105 gmtoff = gmt_offset (tt);
3109 strftime (tzone, sizeof (tzone), "%Z", &tt);
3110 mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tzone));
3111 mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tzone));
3112 mono_array_set ((*data), gint64, 0, 0);
3113 mono_array_set ((*data), gint64, 1, 0);
3114 mono_array_set ((*data), gint64, 2, (gint64) gmtoff * 10000000L);
3115 mono_array_set ((*data), gint64, 3, 0);
3120 MonoDomain *domain = mono_domain_get ();
3121 TIME_ZONE_INFORMATION tz_info;
3126 tz_id = GetTimeZoneInformation (&tz_info);
3127 if (tz_id == TIME_ZONE_ID_INVALID)
3130 MONO_CHECK_ARG_NULL (data);
3131 MONO_CHECK_ARG_NULL (names);
3133 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
3134 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
3136 for (i = 0; i < 32; ++i)
3137 if (!tz_info.DaylightName [i])
3139 mono_array_set ((*names), gpointer, 1, mono_string_new_utf16 (domain, tz_info.DaylightName, i));
3140 for (i = 0; i < 32; ++i)
3141 if (!tz_info.StandardName [i])
3143 mono_array_set ((*names), gpointer, 0, mono_string_new_utf16 (domain, tz_info.StandardName, i));
3145 if ((year <= 1601) || (year > 30827)) {
3147 * According to MSDN, the MS time functions can't handle dates outside
3153 if (tz_id == TIME_ZONE_ID_UNKNOWN) {
3154 /* No daylight saving in this time zone */
3158 tz_info.StandardDate.wYear = year;
3159 err = SystemTimeToFileTime (&tz_info.StandardDate, &ft);
3161 mono_array_set ((*data), gint64, 1, ((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime);
3162 tz_info.DaylightDate.wYear = year;
3163 err = SystemTimeToFileTime (&tz_info.DaylightDate, &ft);
3165 mono_array_set ((*data), gint64, 0, ((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime);
3166 mono_array_set ((*data), gint64, 3, tz_info.Bias + tz_info.StandardBias);
3167 mono_array_set ((*data), gint64, 2, tz_info.Bias + tz_info.DaylightBias);
3174 ves_icall_System_Object_obj_address (MonoObject *this)
3176 MONO_ARCH_SAVE_REGS;
3184 ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array)
3191 MONO_ARCH_SAVE_REGS;
3193 klass = array->obj.vtable->klass;
3194 etype = klass->element_class->byval_arg.type;
3195 if (etype < MONO_TYPE_BOOLEAN || etype > MONO_TYPE_R8)
3198 if (array->bounds == NULL)
3199 length = array->max_length;
3202 for (i = 0; i < klass->rank; ++ i)
3203 length *= array->bounds [i].length;
3206 esize = mono_array_element_size (klass);
3207 return length * esize;
3211 ves_icall_System_Buffer_GetByteInternal (MonoArray *array, gint32 idx)
3213 MONO_ARCH_SAVE_REGS;
3215 return mono_array_get (array, gint8, idx);
3219 ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 value)
3221 MONO_ARCH_SAVE_REGS;
3223 mono_array_set (array, gint8, idx, value);
3227 ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count)
3229 char *src_buf, *dest_buf;
3231 MONO_ARCH_SAVE_REGS;
3233 src_buf = (gint8 *)src->vector + src_offset;
3234 dest_buf = (gint8 *)dest->vector + dest_offset;
3236 memcpy (dest_buf, src_buf, count);
3240 ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this)
3242 MonoDomain *domain = mono_object_domain (this);
3244 MonoRealProxy *rp = ((MonoRealProxy *)this);
3248 MONO_ARCH_SAVE_REGS;
3250 res = mono_object_new (domain, mono_defaults.transparent_proxy_class);
3252 ((MonoTransparentProxy *)res)->rp = rp;
3253 type = ((MonoReflectionType *)rp->class_to_proxy)->type;
3254 klass = mono_class_from_mono_type (type);
3256 if (klass->flags & TYPE_ATTRIBUTE_INTERFACE)
3257 ((MonoTransparentProxy *)res)->klass = mono_defaults.marshalbyrefobject_class;
3259 ((MonoTransparentProxy *)res)->klass = klass;
3261 res->vtable = mono_class_proxy_vtable (domain, klass);
3266 /* System.Environment */
3269 ves_icall_System_Environment_get_MachineName (void)
3271 #if defined (PLATFORM_WIN32)
3276 len = MAX_COMPUTERNAME_LENGTH + 1;
3277 buf = g_new (gunichar2, len);
3280 if (GetComputerName (buf, (PDWORD) &len))
3281 result = mono_string_new_utf16 (mono_domain_get (), buf, len);
3290 MONO_ARCH_SAVE_REGS;
3293 buf = g_new (gchar, len);
3296 if (gethostname (buf, len) == 0)
3297 result = mono_string_new (mono_domain_get (), buf);
3305 ves_icall_System_Environment_get_Platform (void)
3307 MONO_ARCH_SAVE_REGS;
3309 #if defined (PLATFORM_WIN32)
3319 ves_icall_System_Environment_get_NewLine (void)
3321 MONO_ARCH_SAVE_REGS;
3323 #if defined (PLATFORM_WIN32)
3324 return mono_string_new (mono_domain_get (), "\r\n");
3326 return mono_string_new (mono_domain_get (), "\n");
3331 ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
3336 MONO_ARCH_SAVE_REGS;
3341 utf8_name = mono_string_to_utf8 (name); /* FIXME: this should be ascii */
3342 value = g_getenv (utf8_name);
3348 return mono_string_new (mono_domain_get (), value);
3352 * There is no standard way to get at environ.
3360 ves_icall_System_Environment_GetEnvironmentVariableNames (void)
3368 MONO_ARCH_SAVE_REGS;
3371 for (e = environ; *e != 0; ++ e)
3374 domain = mono_domain_get ();
3375 names = mono_array_new (domain, mono_defaults.string_class, n);
3378 for (e = environ; *e != 0; ++ e) {
3379 parts = g_strsplit (*e, "=", 2);
3381 str = mono_string_new (domain, *parts);
3382 mono_array_set (names, MonoString *, n, str);
3394 * Returns the number of milliseconds elapsed since the system started.
3397 ves_icall_System_Environment_get_TickCount (void)
3399 #if defined (PLATFORM_WIN32)
3400 return GetTickCount();
3406 MONO_ARCH_SAVE_REGS;
3408 res = (gint32) gettimeofday (&tv, &tz);
3411 res = (gint32) ((tv.tv_sec & 0xFFFFF) * 1000 + (tv.tv_usec / 1000));
3418 ves_icall_System_Environment_Exit (int result)
3420 MONO_ARCH_SAVE_REGS;
3422 mono_runtime_quit ();
3424 /* we may need to do some cleanup here... */
3429 ves_icall_System_Text_Encoding_InternalCodePage (void)
3433 MONO_ARCH_SAVE_REGS;
3435 g_get_charset (&cset);
3436 /* g_print ("charset: %s\n", cset); */
3437 /* handle some common aliases */
3440 if (strcmp (cset, "ANSI_X3.4-1968") == 0)
3444 return mono_string_new (mono_domain_get (), cset);
3448 ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this,
3449 MonoReflectionMethod *method,
3450 MonoArray *out_args)
3452 MONO_ARCH_SAVE_REGS;
3454 mono_message_init (mono_object_domain (this), this, method, out_args);
3458 ves_icall_IsTransparentProxy (MonoObject *proxy)
3460 MONO_ARCH_SAVE_REGS;
3465 if (proxy->vtable->klass == mono_defaults.transparent_proxy_class)
3472 ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionType *type, MonoBoolean enable)
3477 MONO_ARCH_SAVE_REGS;
3479 klass = mono_class_from_mono_type (type->type);
3480 vtable = mono_class_vtable (mono_domain_get (), klass);
3482 if (enable) vtable->remote = 1;
3483 else vtable->remote = 0;
3487 ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance (MonoReflectionType *type)
3492 MONO_ARCH_SAVE_REGS;
3494 domain = mono_object_domain (type);
3495 klass = mono_class_from_mono_type (type->type);
3497 // Bypass remoting object creation check
3498 return mono_object_new_alloc_specific (mono_class_vtable (domain, klass));
3502 ves_icall_System_Runtime_Serialization_FormatterServices_GetUninitializedObject_Internal (MonoReflectionType *type)
3508 MONO_ARCH_SAVE_REGS;
3510 domain = mono_object_domain (type);
3511 klass = mono_class_from_mono_type (type->type);
3513 if (klass->rank >= 1) {
3514 g_assert (klass->rank == 1);
3515 obj = (MonoObject *) mono_array_new (domain, klass->element_class, 0);
3517 obj = mono_object_new (domain, klass);
3524 ves_icall_System_IO_get_temp_path (void)
3526 MONO_ARCH_SAVE_REGS;
3528 return mono_string_new (mono_domain_get (), g_get_tmp_dir ());
3532 ves_icall_RuntimeMethod_GetFunctionPointer (MonoMethod *method)
3534 MONO_ARCH_SAVE_REGS;
3536 return mono_compile_method (method);
3539 char const * mono_cfg_dir = "";
3542 mono_install_get_config_dir (void)
3544 #ifdef PLATFORM_WIN32
3548 mono_cfg_dir = getenv ("MONO_CFG_DIR");
3550 if (!mono_cfg_dir) {
3551 #ifndef PLATFORM_WIN32
3552 mono_cfg_dir = MONO_CFG_DIR;
3554 mono_cfg_dir = g_strdup (MONO_CFG_DIR);
3555 for (i = strlen (mono_cfg_dir) - 1; i >= 0; i--) {
3556 if (mono_cfg_dir [i] == '/')
3557 ((char*) mono_cfg_dir) [i] = '\\';
3565 ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
3570 MONO_ARCH_SAVE_REGS;
3572 path = g_build_path (G_DIR_SEPARATOR_S, mono_cfg_dir, "mono", "machine.config", NULL);
3574 #if defined (PLATFORM_WIN32)
3575 /* Avoid mixing '/' and '\\' */
3578 for (i = strlen (path) - 1; i >= 0; i--)
3579 if (path [i] == '/')
3583 mcpath = mono_string_new (mono_domain_get (), path);
3590 ves_icall_System_Web_Util_ICalls_get_machine_install_dir (void)
3595 MONO_ARCH_SAVE_REGS;
3597 path = g_path_get_dirname (mono_cfg_dir);
3599 #if defined (PLATFORM_WIN32)
3600 /* Avoid mixing '/' and '\\' */
3603 for (i = strlen (path) - 1; i >= 0; i--)
3604 if (path [i] == '/')
3608 ipath = mono_string_new (mono_domain_get (), path);
3615 ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString (MonoString *message)
3617 #if defined (PLATFORM_WIN32)
3618 static void (*output_debug) (gchar *);
3619 static gboolean tried_loading = FALSE;
3622 MONO_ARCH_SAVE_REGS;
3624 if (!tried_loading && output_debug == NULL) {
3627 tried_loading = TRUE;
3628 k32 = g_module_open ("kernel32", G_MODULE_BIND_LAZY);
3630 gchar *error = g_strdup (g_module_error ());
3631 g_warning ("Failed to load kernel32.dll: %s\n", error);
3636 g_module_symbol (k32, "OutputDebugStringW", (gpointer *) &output_debug);
3637 if (!output_debug) {
3638 gchar *error = g_strdup (g_module_error ());
3639 g_warning ("Failed to load OutputDebugStringW: %s\n", error);
3645 if (output_debug == NULL)
3648 str = mono_string_to_utf8 (message);
3652 g_warning ("WriteWindowsDebugString called and PLATFORM_WIN32 not defined!\n");
3656 /* Only used for value types */
3658 ves_icall_System_Activator_CreateInstanceInternal (MonoReflectionType *type)
3663 MONO_ARCH_SAVE_REGS;
3665 domain = mono_object_domain (type);
3666 klass = mono_class_from_mono_type (type->type);
3668 return mono_object_new (domain, klass);
3671 static MonoReflectionMethod *
3672 ves_icall_MonoMethod_get_base_definition (MonoReflectionMethod *m)
3675 MonoMethod *method = m->method;
3676 MonoMethod *result = NULL;
3678 MONO_ARCH_SAVE_REGS;
3680 if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
3681 method->klass->flags & TYPE_ATTRIBUTE_INTERFACE ||
3682 method->flags & METHOD_ATTRIBUTE_NEW_SLOT)
3685 if (method->klass == NULL || (klass = method->klass->parent) == NULL)
3688 while (result == NULL && klass != NULL && (klass->vtable_size > method->slot))
3690 result = klass->vtable [method->slot];
3691 if (result == NULL) {
3692 /* It is an abstract method */
3694 for (i=0; i<klass->method.count; i++) {
3695 if (klass->methods [i]->slot == method->slot) {
3696 result = klass->methods [i];
3701 klass = klass->parent;
3707 return mono_method_get_object (mono_domain_get (), result, NULL);
3711 mono_ArgIterator_Setup (MonoArgIterator *iter, char* argsp, char* start)
3713 MONO_ARCH_SAVE_REGS;
3715 iter->sig = *(MonoMethodSignature**)argsp;
3717 g_assert (iter->sig->sentinelpos <= iter->sig->param_count);
3718 g_assert (iter->sig->call_convention == MONO_CALL_VARARG);
3721 /* FIXME: it's not documented what start is exactly... */
3722 iter->args = start? start: argsp + sizeof (gpointer);
3723 iter->num_args = iter->sig->param_count - iter->sig->sentinelpos;
3725 // g_print ("sig %p, param_count: %d, sent: %d\n", iter->sig, iter->sig->param_count, iter->sig->sentinelpos);
3729 mono_ArgIterator_IntGetNextArg (MonoArgIterator *iter)
3731 gint i, align, arg_size;
3733 MONO_ARCH_SAVE_REGS;
3735 i = iter->sig->sentinelpos + iter->next_arg;
3737 g_assert (i < iter->sig->param_count);
3739 res.type = iter->sig->params [i];
3740 /* FIXME: endianess issue... */
3741 res.value = iter->args;
3742 arg_size = mono_type_stack_size (res.type, &align);
3743 iter->args = (char*)iter->args + arg_size;
3746 //g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value);
3752 mono_ArgIterator_IntGetNextArgT (MonoArgIterator *iter, MonoType *type)
3754 gint i, align, arg_size;
3756 MONO_ARCH_SAVE_REGS;
3758 i = iter->sig->sentinelpos + iter->next_arg;
3760 g_assert (i < iter->sig->param_count);
3762 while (i < iter->sig->param_count) {
3763 if (!mono_metadata_type_equal (type, iter->sig->params [i]))
3765 res.type = iter->sig->params [i];
3766 /* FIXME: endianess issue... */
3767 res.value = iter->args;
3768 arg_size = mono_type_stack_size (res.type, &align);
3769 iter->args = (char*)iter->args + arg_size;
3771 //g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value);
3774 //g_print ("arg type 0x%02x not found\n", res.type->type);
3782 mono_ArgIterator_IntGetNextArgType (MonoArgIterator *iter)
3785 MONO_ARCH_SAVE_REGS;
3787 i = iter->sig->sentinelpos + iter->next_arg;
3789 g_assert (i < iter->sig->param_count);
3791 return iter->sig->params [i];
3795 mono_TypedReference_ToObject (MonoTypedRef tref)
3798 MONO_ARCH_SAVE_REGS;
3800 if (MONO_TYPE_IS_REFERENCE (tref.type)) {
3801 MonoObject** objp = tref.value;
3804 klass = mono_class_from_mono_type (tref.type);
3806 return mono_value_box (mono_domain_get (), klass, tref.value);
3810 prelink_method (MonoMethod *method)
3812 if (!(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
3814 mono_lookup_pinvoke_call (method);
3815 /* create the wrapper, too? */
3819 ves_icall_System_Runtime_InteropServices_Marshal_Prelink (MonoReflectionMethod *method)
3821 MONO_ARCH_SAVE_REGS;
3822 prelink_method (method->method);
3826 ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionType *type)
3828 MonoClass *klass = mono_class_from_mono_type (type->type);
3830 MONO_ARCH_SAVE_REGS;
3832 mono_class_init (klass);
3833 for (i = 0; i < klass->method.count; ++i)
3834 prelink_method (klass->methods [i]);
3839 static gconstpointer icall_map [] = {
3843 "System.Array::GetValue", ves_icall_System_Array_GetValue,
3844 "System.Array::SetValue", ves_icall_System_Array_SetValue,
3845 "System.Array::GetValueImpl", ves_icall_System_Array_GetValueImpl,
3846 "System.Array::SetValueImpl", ves_icall_System_Array_SetValueImpl,
3847 "System.Array::GetRank", ves_icall_System_Array_GetRank,
3848 "System.Array::GetLength", ves_icall_System_Array_GetLength,
3849 "System.Array::GetLowerBound", ves_icall_System_Array_GetLowerBound,
3850 "System.Array::CreateInstanceImpl", ves_icall_System_Array_CreateInstanceImpl,
3851 "System.Array::FastCopy", ves_icall_System_Array_FastCopy,
3852 "System.Array::Clone", mono_array_clone,
3855 * System.ArgIterator
3857 "System.ArgIterator::Setup", mono_ArgIterator_Setup,
3858 "System.ArgIterator::IntGetNextArg()", mono_ArgIterator_IntGetNextArg,
3859 "System.ArgIterator::IntGetNextArg(intptr)", mono_ArgIterator_IntGetNextArgT,
3860 "System.ArgIterator::IntGetNextArgType", mono_ArgIterator_IntGetNextArgType,
3863 * System.TypedReference
3865 "System.TypedReference::ToObject", mono_TypedReference_ToObject,
3870 "System.Object::MemberwiseClone", ves_icall_System_Object_MemberwiseClone,
3871 "System.Object::GetType", ves_icall_System_Object_GetType,
3872 "System.Object::InternalGetHashCode", ves_icall_System_Object_GetHashCode,
3873 "System.Object::obj_address", ves_icall_System_Object_obj_address,
3878 "System.ValueType::GetHashCode", ves_icall_System_ValueType_GetHashCode,
3879 "System.ValueType::InternalEquals", ves_icall_System_ValueType_Equals,
3885 "System.String::.ctor(char*)", ves_icall_System_String_ctor_charp,
3886 "System.String::.ctor(char*,int,int)", ves_icall_System_String_ctor_charp_int_int,
3887 "System.String::.ctor(sbyte*)", ves_icall_System_String_ctor_sbytep,
3888 "System.String::.ctor(sbyte*,int,int)", ves_icall_System_String_ctor_sbytep_int_int,
3889 "System.String::.ctor(sbyte*,int,int,System.Text.Encoding)", ves_icall_System_String_ctor_encoding,
3890 "System.String::.ctor(char[])", ves_icall_System_String_ctor_chara,
3891 "System.String::.ctor(char[],int,int)", ves_icall_System_String_ctor_chara_int_int,
3892 "System.String::.ctor(char,int)", ves_icall_System_String_ctor_char_int,
3893 "System.String::InternalEquals", ves_icall_System_String_InternalEquals,
3894 "System.String::InternalJoin", ves_icall_System_String_InternalJoin,
3895 "System.String::InternalInsert", ves_icall_System_String_InternalInsert,
3896 "System.String::InternalReplace(char,char)", ves_icall_System_String_InternalReplace_Char,
3897 "System.String::InternalReplace(string,string)", ves_icall_System_String_InternalReplace_Str,
3898 "System.String::InternalRemove", ves_icall_System_String_InternalRemove,
3899 "System.String::InternalCopyTo", ves_icall_System_String_InternalCopyTo,
3900 "System.String::InternalSplit", ves_icall_System_String_InternalSplit,
3901 "System.String::InternalTrim", ves_icall_System_String_InternalTrim,
3902 "System.String::InternalIndexOf(char,int,int)", ves_icall_System_String_InternalIndexOf_Char,
3903 "System.String::InternalIndexOf(string,int,int)", ves_icall_System_String_InternalIndexOf_Str,
3904 "System.String::InternalIndexOfAny", ves_icall_System_String_InternalIndexOfAny,
3905 "System.String::InternalLastIndexOf(char,int,int)", ves_icall_System_String_InternalLastIndexOf_Char,
3906 "System.String::InternalLastIndexOf(string,int,int)", ves_icall_System_String_InternalLastIndexOf_Str,
3907 "System.String::InternalLastIndexOfAny", ves_icall_System_String_InternalLastIndexOfAny,
3908 "System.String::InternalPad", ves_icall_System_String_InternalPad,
3909 "System.String::InternalToLower", ves_icall_System_String_InternalToLower,
3910 "System.String::InternalToUpper", ves_icall_System_String_InternalToUpper,
3911 "System.String::InternalAllocateStr", ves_icall_System_String_InternalAllocateStr,
3912 "System.String::InternalStrcpy(string,int,string)", ves_icall_System_String_InternalStrcpy_Str,
3913 "System.String::InternalStrcpy(string,int,string,int,int)", ves_icall_System_String_InternalStrcpy_StrN,
3914 "System.String::InternalIntern", ves_icall_System_String_InternalIntern,
3915 "System.String::InternalIsInterned", ves_icall_System_String_InternalIsInterned,
3916 "System.String::InternalCompare(string,int,string,int,int,int)", ves_icall_System_String_InternalCompareStr_N,
3917 "System.String::GetHashCode", ves_icall_System_String_GetHashCode,
3918 "System.String::get_Chars", ves_icall_System_String_get_Chars,
3923 "System.AppDomain::createDomain", ves_icall_System_AppDomain_createDomain,
3924 "System.AppDomain::getCurDomain", ves_icall_System_AppDomain_getCurDomain,
3925 "System.AppDomain::GetData", ves_icall_System_AppDomain_GetData,
3926 "System.AppDomain::SetData", ves_icall_System_AppDomain_SetData,
3927 "System.AppDomain::getSetup", ves_icall_System_AppDomain_getSetup,
3928 "System.AppDomain::getFriendlyName", ves_icall_System_AppDomain_getFriendlyName,
3929 "System.AppDomain::GetAssemblies", ves_icall_System_AppDomain_GetAssemblies,
3930 "System.AppDomain::LoadAssembly", ves_icall_System_AppDomain_LoadAssembly,
3931 "System.AppDomain::InternalUnload", ves_icall_System_AppDomain_InternalUnload,
3932 "System.AppDomain::ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly,
3933 "System.AppDomain::InternalSetDomain", ves_icall_System_AppDomain_InternalSetDomain,
3934 "System.AppDomain::InternalSetDomainByID", ves_icall_System_AppDomain_InternalSetDomainByID,
3935 "System.AppDomain::InternalSetContext", ves_icall_System_AppDomain_InternalSetContext,
3936 "System.AppDomain::InternalGetContext", ves_icall_System_AppDomain_InternalGetContext,
3937 "System.AppDomain::InternalGetDefaultContext", ves_icall_System_AppDomain_InternalGetDefaultContext,
3938 "System.AppDomain::InternalGetProcessGuid", ves_icall_System_AppDomain_InternalGetProcessGuid,
3941 * System.AppDomainSetup
3943 "System.AppDomainSetup::InitAppDomainSetup", ves_icall_System_AppDomainSetup_InitAppDomainSetup,
3948 "System.Double::ParseImpl", mono_double_ParseImpl,
3949 "System.Double::AssertEndianity", ves_icall_System_Double_AssertEndianity,
3954 "System.Decimal::decimal2UInt64", mono_decimal2UInt64,
3955 "System.Decimal::decimal2Int64", mono_decimal2Int64,
3956 "System.Decimal::double2decimal", mono_double2decimal, /* FIXME: wrong signature. */
3957 "System.Decimal::decimalIncr", mono_decimalIncr,
3958 "System.Decimal::decimalSetExponent", mono_decimalSetExponent,
3959 "System.Decimal::decimal2double", mono_decimal2double,
3960 "System.Decimal::decimalFloorAndTrunc", mono_decimalFloorAndTrunc,
3961 "System.Decimal::decimalRound", mono_decimalRound,
3962 "System.Decimal::decimalMult", mono_decimalMult,
3963 "System.Decimal::decimalDiv", mono_decimalDiv,
3964 "System.Decimal::decimalIntDiv", mono_decimalIntDiv,
3965 "System.Decimal::decimalCompare", mono_decimalCompare,
3966 "System.Decimal::string2decimal", mono_string2decimal,
3967 "System.Decimal::decimal2string", mono_decimal2string,
3972 "System.Reflection.Emit.ModuleBuilder::create_modified_type", ves_icall_ModuleBuilder_create_modified_type,
3973 "System.Reflection.Emit.ModuleBuilder::basic_init", mono_image_module_basic_init,
3978 "System.Reflection.Emit.AssemblyBuilder::getDataChunk", ves_icall_AssemblyBuilder_getDataChunk,
3979 "System.Reflection.Emit.AssemblyBuilder::getUSIndex", mono_image_insert_string,
3980 "System.Reflection.Emit.AssemblyBuilder::getToken", ves_icall_AssemblyBuilder_getToken,
3981 "System.Reflection.Emit.AssemblyBuilder::basic_init", mono_image_basic_init,
3982 "System.Reflection.Emit.AssemblyBuilder::build_metadata", ves_icall_AssemblyBuilder_build_metadata,
3987 "System.Reflection.MonoMethodInfo::get_method_info", ves_icall_get_method_info,
3988 "System.Reflection.MonoMethodInfo::get_parameter_info", ves_icall_get_parameter_info,
3989 "System.Reflection.MonoPropertyInfo::get_property_info", ves_icall_get_property_info,
3990 "System.Reflection.MonoEventInfo::get_event_info", ves_icall_get_event_info,
3991 "System.Reflection.MonoMethod::InternalInvoke", ves_icall_InternalInvoke,
3992 "System.Reflection.MonoCMethod::InternalInvoke", ves_icall_InternalInvoke,
3993 "System.Reflection.MethodBase::GetCurrentMethod", ves_icall_GetCurrentMethod,
3994 "System.MonoCustomAttrs::GetCustomAttributes", mono_reflection_get_custom_attrs,
3995 "System.Reflection.Emit.CustomAttributeBuilder::GetBlob", mono_reflection_get_custom_attrs_blob,
3996 "System.Reflection.MonoField::GetParentType", ves_icall_MonoField_GetParentType,
3997 "System.Reflection.MonoField::GetValueInternal", ves_icall_MonoField_GetValueInternal,
3998 "System.Reflection.MonoField::SetValueInternal", ves_icall_FieldInfo_SetValueInternal,
3999 "System.Reflection.Emit.SignatureHelper::get_signature_local", mono_reflection_sighelper_get_signature_local,
4000 "System.Reflection.Emit.SignatureHelper::get_signature_field", mono_reflection_sighelper_get_signature_field,
4002 "System.RuntimeMethodHandle::GetFunctionPointer", ves_icall_RuntimeMethod_GetFunctionPointer,
4003 "System.Reflection.MonoMethod::get_base_definition", ves_icall_MonoMethod_get_base_definition,
4007 "System.MonoEnumInfo::get_enum_info", ves_icall_get_enum_info,
4008 "System.Enum::get_value", ves_icall_System_Enum_get_value,
4009 "System.Enum::ToObject", ves_icall_System_Enum_ToObject,
4014 "System.Reflection.Emit.TypeBuilder::setup_internal_class", mono_reflection_setup_internal_class,
4015 "System.Reflection.Emit.TypeBuilder::create_internal_class", mono_reflection_create_internal_class,
4016 "System.Reflection.Emit.TypeBuilder::create_runtime_class", mono_reflection_create_runtime_class,
4017 "System.Reflection.Emit.TypeBuilder::setup_generic_class", mono_reflection_setup_generic_class,
4018 "System.Reflection.Emit.TypeBuilder::define_generic_parameter", mono_reflection_define_generic_parameter,
4021 * TypeBuilder generics icalls.
4023 "System.Reflection.Emit.TypeBuilder::get_IsUnboundGenericParameter", ves_icall_TypeBuilder_get_IsUnboundGenericParameter,
4032 "System.Type::internal_from_name", ves_icall_type_from_name,
4033 "System.Type::internal_from_handle", ves_icall_type_from_handle,
4034 "System.MonoType::get_attributes", ves_icall_get_attributes,
4035 "System.Type::type_is_subtype_of", ves_icall_type_is_subtype_of,
4036 "System.Type::type_is_assignable_from", ves_icall_type_is_assignable_from,
4037 "System.Type::Equals", ves_icall_type_Equals,
4038 "System.Type::GetTypeCode", ves_icall_type_GetTypeCode,
4039 "System.Type::GetInterfaceMapData", ves_icall_Type_GetInterfaceMapData,
4040 "System.Type::IsArrayImpl", ves_icall_Type_IsArrayImpl,
4042 /* Type generics icalls */
4043 "System.Type::GetGenericParameters", ves_icall_Type_GetGenericParameters,
4044 "System.Type::GetGenericParameterPosition", ves_icall_Type_GetGenericParameterPosition,
4045 "System.Type::GetGenericTypeDefinition", ves_icall_Type_GetGenericTypeDefinition,
4046 "System.Type::BindGenericParameters", ves_icall_Type_BindGenericParameters,
4047 "System.Type::get_IsGenericInstance", ves_icall_Type_get_IsGenericInstance,
4049 "System.MonoType::get_HasGenericParameters", ves_icall_MonoType_get_HasGenericParameteres,
4050 "System.MonoType::get_HasUnboundGenericParameters", ves_icall_MonoType_get_HasUnboundGenericParameters,
4051 "System.MonoType::get_IsUnboundGenericParameter", ves_icall_MonoType_get_IsUnboundGenericParameter,
4054 * System.Reflection.FieldInfo
4056 "System.Reflection.FieldInfo::internal_from_handle", ves_icall_System_Reflection_FieldInfo_internal_from_handle,
4059 * System.Runtime.CompilerServices.RuntimeHelpers
4061 "System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray,
4062 "System.Runtime.CompilerServices.RuntimeHelpers::GetOffsetToStringData", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData,
4063 "System.Runtime.CompilerServices.RuntimeHelpers::GetObjectValue", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue,
4064 "System.Runtime.CompilerServices.RuntimeHelpers::RunClassConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor,
4069 "System.Threading.Thread::Abort_internal(object)", ves_icall_System_Threading_Thread_Abort,
4070 "System.Threading.Thread::ResetAbort_internal()", ves_icall_System_Threading_Thread_ResetAbort,
4071 "System.Threading.Thread::Thread_internal", ves_icall_System_Threading_Thread_Thread_internal,
4072 "System.Threading.Thread::Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal,
4073 "System.Threading.Thread::Start_internal", ves_icall_System_Threading_Thread_Start_internal,
4074 "System.Threading.Thread::Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal,
4075 "System.Threading.Thread::CurrentThread_internal", mono_thread_current,
4076 "System.Threading.Thread::Join_internal", ves_icall_System_Threading_Thread_Join_internal,
4077 "System.Threading.Thread::SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup,
4078 "System.Threading.Thread::SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store,
4079 "System.Threading.Thread::GetDomainID", ves_icall_System_Threading_Thread_GetDomainID,
4080 "System.Threading.Monitor::Monitor_exit", ves_icall_System_Threading_Monitor_Monitor_exit,
4081 "System.Threading.Monitor::Monitor_test_owner", ves_icall_System_Threading_Monitor_Monitor_test_owner,
4082 "System.Threading.Monitor::Monitor_test_synchronised", ves_icall_System_Threading_Monitor_Monitor_test_synchronised,
4083 "System.Threading.Monitor::Monitor_pulse", ves_icall_System_Threading_Monitor_Monitor_pulse,
4084 "System.Threading.Monitor::Monitor_pulse_all", ves_icall_System_Threading_Monitor_Monitor_pulse_all,
4085 "System.Threading.Monitor::Monitor_try_enter", ves_icall_System_Threading_Monitor_Monitor_try_enter,
4086 "System.Threading.Monitor::Monitor_wait", ves_icall_System_Threading_Monitor_Monitor_wait,
4087 "System.Threading.Mutex::CreateMutex_internal", ves_icall_System_Threading_Mutex_CreateMutex_internal,
4088 "System.Threading.Mutex::ReleaseMutex_internal", ves_icall_System_Threading_Mutex_ReleaseMutex_internal,
4089 "System.Threading.NativeEventCalls::CreateEvent_internal", ves_icall_System_Threading_Events_CreateEvent_internal,
4090 "System.Threading.NativeEventCalls::SetEvent_internal", ves_icall_System_Threading_Events_SetEvent_internal,
4091 "System.Threading.NativeEventCalls::ResetEvent_internal", ves_icall_System_Threading_Events_ResetEvent_internal,
4092 "System.Threading.NativeEventCalls::CloseEvent_internal", ves_icall_System_Threading_Events_CloseEvent_internal,
4093 "System.Threading.ThreadPool::GetAvailableThreads", ves_icall_System_Threading_ThreadPool_GetAvailableThreads,
4094 "System.Threading.ThreadPool::GetMaxThreads", ves_icall_System_Threading_ThreadPool_GetMaxThreads,
4097 * System.Threading.WaitHandle
4099 "System.Threading.WaitHandle::WaitAll_internal", ves_icall_System_Threading_WaitHandle_WaitAll_internal,
4100 "System.Threading.WaitHandle::WaitAny_internal", ves_icall_System_Threading_WaitHandle_WaitAny_internal,
4101 "System.Threading.WaitHandle::WaitOne_internal", ves_icall_System_Threading_WaitHandle_WaitOne_internal,
4104 * System.Runtime.InteropServices.Marshal
4106 "System.Runtime.InteropServices.Marshal::ReadIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr,
4107 "System.Runtime.InteropServices.Marshal::ReadByte", ves_icall_System_Runtime_InteropServices_Marshal_ReadByte,
4108 "System.Runtime.InteropServices.Marshal::ReadInt16", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt16,
4109 "System.Runtime.InteropServices.Marshal::ReadInt32", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt32,
4110 "System.Runtime.InteropServices.Marshal::ReadInt64", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt64,
4111 "System.Runtime.InteropServices.Marshal::WriteIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_WriteIntPtr,
4112 "System.Runtime.InteropServices.Marshal::WriteByte", ves_icall_System_Runtime_InteropServices_Marshal_WriteByte,
4113 "System.Runtime.InteropServices.Marshal::WriteInt16", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt16,
4114 "System.Runtime.InteropServices.Marshal::WriteInt32", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt32,
4115 "System.Runtime.InteropServices.Marshal::WriteInt64", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt64,
4117 "System.Runtime.InteropServices.Marshal::PtrToStringAnsi(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi,
4118 "System.Runtime.InteropServices.Marshal::PtrToStringAnsi(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len,
4119 "System.Runtime.InteropServices.Marshal::PtrToStringAuto(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi,
4120 "System.Runtime.InteropServices.Marshal::PtrToStringAuto(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len,
4121 "System.Runtime.InteropServices.Marshal::PtrToStringUni(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni,
4122 "System.Runtime.InteropServices.Marshal::PtrToStringUni(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni_len,
4123 "System.Runtime.InteropServices.Marshal::PtrToStringBSTR", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR,
4125 "System.Runtime.InteropServices.Marshal::GetLastWin32Error", ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error,
4126 "System.Runtime.InteropServices.Marshal::AllocHGlobal", mono_marshal_alloc,
4127 "System.Runtime.InteropServices.Marshal::FreeHGlobal", mono_marshal_free,
4128 "System.Runtime.InteropServices.Marshal::ReAllocHGlobal", mono_marshal_realloc,
4129 "System.Runtime.InteropServices.Marshal::copy_to_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_to_unmanaged,
4130 "System.Runtime.InteropServices.Marshal::copy_from_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_from_unmanaged,
4131 "System.Runtime.InteropServices.Marshal::SizeOf", ves_icall_System_Runtime_InteropServices_Marshal_SizeOf,
4132 "System.Runtime.InteropServices.Marshal::StructureToPtr", ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr,
4133 "System.Runtime.InteropServices.Marshal::PtrToStructure(intptr,object)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure,
4134 "System.Runtime.InteropServices.Marshal::PtrToStructure(intptr,System.Type)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type,
4135 "System.Runtime.InteropServices.Marshal::OffsetOf", ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf,
4136 "System.Runtime.InteropServices.Marshal::StringToHGlobalAnsi", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi,
4137 "System.Runtime.InteropServices.Marshal::StringToHGlobalAuto", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi,
4138 "System.Runtime.InteropServices.Marshal::StringToHGlobalUni", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni,
4139 "System.Runtime.InteropServices.Marshal::DestroyStructure", ves_icall_System_Runtime_InteropServices_Marshal_DestroyStructure,
4140 "System.Runtime.InteropServices.Marshal::Prelink", ves_icall_System_Runtime_InteropServices_Marshal_Prelink,
4141 "System.Runtime.InteropServices.Marshal::PrelinkAll", ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll,
4144 "System.Reflection.Assembly::LoadFrom", ves_icall_System_Reflection_Assembly_LoadFrom,
4145 "System.Reflection.Assembly::InternalGetType", ves_icall_System_Reflection_Assembly_InternalGetType,
4146 "System.Reflection.Assembly::GetTypes", ves_icall_System_Reflection_Assembly_GetTypes,
4147 "System.Reflection.Assembly::FillName", ves_icall_System_Reflection_Assembly_FillName,
4148 "System.Reflection.Assembly::get_code_base", ves_icall_System_Reflection_Assembly_get_code_base,
4149 "System.Reflection.Assembly::get_location", ves_icall_System_Reflection_Assembly_get_location,
4150 "System.Reflection.Assembly::InternalImageRuntimeVersion", ves_icall_System_Reflection_Assembly_InternalImageRuntimeVersion,
4151 "System.Reflection.Assembly::GetExecutingAssembly", ves_icall_System_Reflection_Assembly_GetExecutingAssembly,
4152 "System.Reflection.Assembly::GetEntryAssembly", ves_icall_System_Reflection_Assembly_GetEntryAssembly,
4153 "System.Reflection.Assembly::GetCallingAssembly", ves_icall_System_Reflection_Assembly_GetCallingAssembly,
4154 "System.Reflection.Assembly::get_EntryPoint", ves_icall_System_Reflection_Assembly_get_EntryPoint,
4155 "System.Reflection.Assembly::GetManifestResourceNames", ves_icall_System_Reflection_Assembly_GetManifestResourceNames,
4156 "System.Reflection.Assembly::GetManifestResourceInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInternal,
4157 "System.Reflection.Assembly::GetManifestResourceInfoInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal,
4158 "System.Reflection.Assembly::GetFilesInternal", ves_icall_System_Reflection_Assembly_GetFilesInternal,
4159 "System.Reflection.Assembly::GetReferencedAssemblies", ves_icall_System_Reflection_Assembly_GetReferencedAssemblies,
4160 "System.Reflection.Assembly::GetNamespaces", ves_icall_System_Reflection_Assembly_GetNamespaces,
4161 "System.Reflection.Assembly::GetModulesInternal", ves_icall_System_Reflection_Assembly_GetModulesInternal,
4164 * System.Reflection.Module
4166 "System.Reflection.Module::GetGlobalType", ves_icall_System_Reflection_Module_GetGlobalType,
4167 "System.Reflection.Module::GetGuidInternal", ves_icall_System_Reflection_Module_GetGuidInternal,
4172 "System.MonoType::getFullName", ves_icall_System_MonoType_getFullName,
4173 "System.MonoType::type_from_obj", mono_type_type_from_obj,
4174 "System.MonoType::GetElementType", ves_icall_MonoType_GetElementType,
4175 "System.MonoType::get_type_info", ves_icall_get_type_info,
4176 "System.MonoType::get_BaseType", ves_icall_get_type_parent,
4177 "System.MonoType::get_Module", ves_icall_MonoType_get_Module,
4178 "System.MonoType::IsPointerImpl", ves_icall_type_ispointer,
4179 "System.MonoType::IsPrimitiveImpl", ves_icall_type_isprimitive,
4180 "System.MonoType::IsByRefImpl", ves_icall_type_isbyref,
4181 "System.MonoType::GetField", ves_icall_Type_GetField,
4182 "System.MonoType::GetFields", ves_icall_Type_GetFields,
4183 "System.MonoType::GetMethods", ves_icall_Type_GetMethods,
4184 "System.MonoType::GetConstructors", ves_icall_Type_GetConstructors,
4185 "System.MonoType::GetProperties", ves_icall_Type_GetProperties,
4186 "System.MonoType::GetEvents", ves_icall_Type_GetEvents,
4187 "System.MonoType::InternalGetEvent", ves_icall_MonoType_GetEvent,
4188 "System.MonoType::GetInterfaces", ves_icall_Type_GetInterfaces,
4189 "System.MonoType::GetNestedTypes", ves_icall_Type_GetNestedTypes,
4190 "System.MonoType::GetNestedType", ves_icall_Type_GetNestedType,
4193 * System.Net.Sockets I/O Services
4195 "System.Net.Sockets.Socket::Socket_internal", ves_icall_System_Net_Sockets_Socket_Socket_internal,
4196 "System.Net.Sockets.Socket::Close_internal", ves_icall_System_Net_Sockets_Socket_Close_internal,
4197 "System.Net.Sockets.SocketException::WSAGetLastError_internal", ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal,
4198 "System.Net.Sockets.Socket::Available_internal", ves_icall_System_Net_Sockets_Socket_Available_internal,
4199 "System.Net.Sockets.Socket::Blocking_internal", ves_icall_System_Net_Sockets_Socket_Blocking_internal,
4200 "System.Net.Sockets.Socket::Accept_internal", ves_icall_System_Net_Sockets_Socket_Accept_internal,
4201 "System.Net.Sockets.Socket::Listen_internal", ves_icall_System_Net_Sockets_Socket_Listen_internal,
4202 "System.Net.Sockets.Socket::LocalEndPoint_internal", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal,
4203 "System.Net.Sockets.Socket::RemoteEndPoint_internal", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal,
4204 "System.Net.Sockets.Socket::Bind_internal", ves_icall_System_Net_Sockets_Socket_Bind_internal,
4205 "System.Net.Sockets.Socket::Connect_internal", ves_icall_System_Net_Sockets_Socket_Connect_internal,
4206 "System.Net.Sockets.Socket::Receive_internal", ves_icall_System_Net_Sockets_Socket_Receive_internal,
4207 "System.Net.Sockets.Socket::RecvFrom_internal", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal,
4208 "System.Net.Sockets.Socket::Send_internal", ves_icall_System_Net_Sockets_Socket_Send_internal,
4209 "System.Net.Sockets.Socket::SendTo_internal", ves_icall_System_Net_Sockets_Socket_SendTo_internal,
4210 "System.Net.Sockets.Socket::Select_internal", ves_icall_System_Net_Sockets_Socket_Select_internal,
4211 "System.Net.Sockets.Socket::Shutdown_internal", ves_icall_System_Net_Sockets_Socket_Shutdown_internal,
4212 "System.Net.Sockets.Socket::GetSocketOption_obj_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal,
4213 "System.Net.Sockets.Socket::GetSocketOption_arr_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal,
4214 "System.Net.Sockets.Socket::SetSocketOption_internal", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal,
4215 "System.Net.Dns::GetHostByName_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByName_internal,
4216 "System.Net.Dns::GetHostByAddr_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByAddr_internal,
4217 "System.Net.Dns::GetHostName_internal(string&)", ves_icall_System_Net_Dns_GetHostName_internal,
4222 "System.Char::GetNumericValue", ves_icall_System_Char_GetNumericValue,
4223 "System.Char::GetUnicodeCategory", ves_icall_System_Char_GetUnicodeCategory,
4224 "System.Char::IsControl", ves_icall_System_Char_IsControl,
4225 "System.Char::IsDigit", ves_icall_System_Char_IsDigit,
4226 "System.Char::IsLetter", ves_icall_System_Char_IsLetter,
4227 "System.Char::IsLower", ves_icall_System_Char_IsLower,
4228 "System.Char::IsUpper", ves_icall_System_Char_IsUpper,
4229 "System.Char::IsNumber", ves_icall_System_Char_IsNumber,
4230 "System.Char::IsPunctuation", ves_icall_System_Char_IsPunctuation,
4231 "System.Char::IsSeparator", ves_icall_System_Char_IsSeparator,
4232 "System.Char::IsSurrogate", ves_icall_System_Char_IsSurrogate,
4233 "System.Char::IsSymbol", ves_icall_System_Char_IsSymbol,
4234 "System.Char::IsWhiteSpace", ves_icall_System_Char_IsWhiteSpace,
4235 "System.Char::ToLower", ves_icall_System_Char_ToLower,
4236 "System.Char::ToUpper", ves_icall_System_Char_ToUpper,
4239 * System.Text.Encoding
4241 "System.Text.Encoding::InternalCodePage", ves_icall_System_Text_Encoding_InternalCodePage,
4243 "System.DateTime::GetNow", ves_icall_System_DateTime_GetNow,
4244 "System.CurrentTimeZone::GetTimeZoneData", ves_icall_System_CurrentTimeZone_GetTimeZoneData,
4249 "System.GC::InternalCollect", ves_icall_System_GC_InternalCollect,
4250 "System.GC::GetTotalMemory", ves_icall_System_GC_GetTotalMemory,
4251 "System.GC::KeepAlive", ves_icall_System_GC_KeepAlive,
4252 "System.GC::ReRegisterForFinalize", ves_icall_System_GC_ReRegisterForFinalize,
4253 "System.GC::SuppressFinalize", ves_icall_System_GC_SuppressFinalize,
4254 "System.GC::WaitForPendingFinalizers", ves_icall_System_GC_WaitForPendingFinalizers,
4255 "System.Runtime.InteropServices.GCHandle::GetTarget", ves_icall_System_GCHandle_GetTarget,
4256 "System.Runtime.InteropServices.GCHandle::GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle,
4257 "System.Runtime.InteropServices.GCHandle::FreeHandle", ves_icall_System_GCHandle_FreeHandle,
4258 "System.Runtime.InteropServices.GCHandle::GetAddrOfPinnedObject", ves_icall_System_GCHandle_GetAddrOfPinnedObject,
4261 * System.Security.Cryptography calls
4264 "System.Security.Cryptography.RNGCryptoServiceProvider::InternalGetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_InternalGetBytes,
4265 "System.Security.Cryptography.RNGCryptoServiceProvider::InternalGetNonZeroBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_InternalGetNonZeroBytes,
4270 "System.Buffer::ByteLengthInternal", ves_icall_System_Buffer_ByteLengthInternal,
4271 "System.Buffer::GetByteInternal", ves_icall_System_Buffer_GetByteInternal,
4272 "System.Buffer::SetByteInternal", ves_icall_System_Buffer_SetByteInternal,
4273 "System.Buffer::BlockCopyInternal", ves_icall_System_Buffer_BlockCopyInternal,
4278 "System.IO.MonoIO::CreateDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CreateDirectory,
4279 "System.IO.MonoIO::RemoveDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_RemoveDirectory,
4280 "System.IO.MonoIO::FindFirstFile(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindFirstFile,
4281 "System.IO.MonoIO::FindNextFile(intptr,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindNextFile,
4282 "System.IO.MonoIO::FindClose(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindClose,
4283 "System.IO.MonoIO::GetCurrentDirectory(System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetCurrentDirectory,
4284 "System.IO.MonoIO::SetCurrentDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetCurrentDirectory,
4285 "System.IO.MonoIO::MoveFile(string,string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_MoveFile,
4286 "System.IO.MonoIO::CopyFile(string,string,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CopyFile,
4287 "System.IO.MonoIO::DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile,
4288 "System.IO.MonoIO::GetFileAttributes(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileAttributes,
4289 "System.IO.MonoIO::SetFileAttributes(string,System.IO.FileAttributes,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileAttributes,
4290 "System.IO.MonoIO::GetFileType(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileType,
4291 "System.IO.MonoIO::GetFileStat(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileStat,
4292 "System.IO.MonoIO::Open(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Open,
4293 "System.IO.MonoIO::Close(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Close,
4294 "System.IO.MonoIO::Read(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Read,
4295 "System.IO.MonoIO::Write(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Write,
4296 "System.IO.MonoIO::Seek(intptr,long,System.IO.SeekOrigin,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Seek,
4297 "System.IO.MonoIO::GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength,
4298 "System.IO.MonoIO::SetLength(intptr,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetLength,
4299 "System.IO.MonoIO::SetFileTime(intptr,long,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileTime,
4300 "System.IO.MonoIO::Flush(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Flush,
4301 "System.IO.MonoIO::get_ConsoleOutput", ves_icall_System_IO_MonoIO_get_ConsoleOutput,
4302 "System.IO.MonoIO::get_ConsoleInput", ves_icall_System_IO_MonoIO_get_ConsoleInput,
4303 "System.IO.MonoIO::get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError,
4304 "System.IO.MonoIO::CreatePipe(intptr&,intptr&)", ves_icall_System_IO_MonoIO_CreatePipe,
4305 "System.IO.MonoIO::get_VolumeSeparatorChar", ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar,
4306 "System.IO.MonoIO::get_DirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar,
4307 "System.IO.MonoIO::get_AltDirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar,
4308 "System.IO.MonoIO::get_PathSeparator", ves_icall_System_IO_MonoIO_get_PathSeparator,
4309 "System.IO.MonoIO::get_InvalidPathChars", ves_icall_System_IO_MonoIO_get_InvalidPathChars,
4310 "System.IO.MonoIO::GetTempPath(string&)", ves_icall_System_IO_MonoIO_GetTempPath,
4315 "System.Math::Floor", ves_icall_System_Math_Floor,
4316 "System.Math::Round", ves_icall_System_Math_Round,
4317 "System.Math::Round2", ves_icall_System_Math_Round2,
4318 "System.Math::Sin", ves_icall_System_Math_Sin,
4319 "System.Math::Cos", ves_icall_System_Math_Cos,
4320 "System.Math::Tan", ves_icall_System_Math_Tan,
4321 "System.Math::Sinh", ves_icall_System_Math_Sinh,
4322 "System.Math::Cosh", ves_icall_System_Math_Cosh,
4323 "System.Math::Tanh", ves_icall_System_Math_Tanh,
4324 "System.Math::Acos", ves_icall_System_Math_Acos,
4325 "System.Math::Asin", ves_icall_System_Math_Asin,
4326 "System.Math::Atan", ves_icall_System_Math_Atan,
4327 "System.Math::Atan2", ves_icall_System_Math_Atan2,
4328 "System.Math::Exp", ves_icall_System_Math_Exp,
4329 "System.Math::Log", ves_icall_System_Math_Log,
4330 "System.Math::Log10", ves_icall_System_Math_Log10,
4331 "System.Math::Pow", ves_icall_System_Math_Pow,
4332 "System.Math::Sqrt", ves_icall_System_Math_Sqrt,
4335 * System.Environment
4337 "System.Environment::get_MachineName", ves_icall_System_Environment_get_MachineName,
4338 "System.Environment::get_NewLine", ves_icall_System_Environment_get_NewLine,
4339 "System.Environment::GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable,
4340 "System.Environment::GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames,
4341 "System.Environment::GetCommandLineArgs", mono_runtime_get_main_args,
4342 "System.Environment::get_TickCount", ves_icall_System_Environment_get_TickCount,
4343 "System.Environment::Exit", ves_icall_System_Environment_Exit,
4344 "System.Environment::get_Platform", ves_icall_System_Environment_get_Platform,
4345 "System.Environment::get_ExitCode", mono_environment_exitcode_get,
4346 "System.Environment::set_ExitCode", mono_environment_exitcode_set,
4349 * System.Runtime.Remoting
4351 "System.Runtime.Remoting.RemotingServices::InternalExecute",
4352 ves_icall_InternalExecute,
4353 "System.Runtime.Remoting.RemotingServices::IsTransparentProxy",
4354 ves_icall_IsTransparentProxy,
4357 * System.Runtime.Remoting.Activation
4359 "System.Runtime.Remoting.Activation.ActivationServices::AllocateUninitializedClassInstance",
4360 ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance,
4361 "System.Runtime.Remoting.Activation.ActivationServices::EnableProxyActivation",
4362 ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation,
4365 * System.Runtime.Remoting.Messaging
4367 "System.Runtime.Remoting.Messaging.MonoMethodMessage::InitMessage",
4368 ves_icall_MonoMethodMessage_InitMessage,
4371 * System.Runtime.Remoting.Proxies
4373 "System.Runtime.Remoting.Proxies.RealProxy::InternalGetTransparentProxy",
4374 ves_icall_Remoting_RealProxy_GetTransparentProxy,
4377 * System.Threading.Interlocked
4379 "System.Threading.Interlocked::Increment(int&)", ves_icall_System_Threading_Interlocked_Increment_Int,
4380 "System.Threading.Interlocked::Increment(long&)", ves_icall_System_Threading_Interlocked_Increment_Long,
4381 "System.Threading.Interlocked::Decrement(int&)", ves_icall_System_Threading_Interlocked_Decrement_Int,
4382 "System.Threading.Interlocked::Decrement(long&)", ves_icall_System_Threading_Interlocked_Decrement_Long,
4383 "System.Threading.Interlocked::CompareExchange(int&,int,int)", ves_icall_System_Threading_Interlocked_CompareExchange_Int,
4384 "System.Threading.Interlocked::CompareExchange(object&,object,object)", ves_icall_System_Threading_Interlocked_CompareExchange_Object,
4385 "System.Threading.Interlocked::CompareExchange(single&,single,single)", ves_icall_System_Threading_Interlocked_CompareExchange_Single,
4386 "System.Threading.Interlocked::Exchange(int&,int)", ves_icall_System_Threading_Interlocked_Exchange_Int,
4387 "System.Threading.Interlocked::Exchange(object&,object)", ves_icall_System_Threading_Interlocked_Exchange_Object,
4388 "System.Threading.Interlocked::Exchange(single&,single)", ves_icall_System_Threading_Interlocked_Exchange_Single,
4391 * System.Diagnostics.Process
4393 "System.Diagnostics.Process::GetProcess_internal(int)", ves_icall_System_Diagnostics_Process_GetProcess_internal,
4394 "System.Diagnostics.Process::GetProcesses_internal()", ves_icall_System_Diagnostics_Process_GetProcesses_internal,
4395 "System.Diagnostics.Process::GetPid_internal()", ves_icall_System_Diagnostics_Process_GetPid_internal,
4396 "System.Diagnostics.Process::Process_free_internal(intptr)", ves_icall_System_Diagnostics_Process_Process_free_internal,
4397 "System.Diagnostics.Process::GetModules_internal()", ves_icall_System_Diagnostics_Process_GetModules_internal,
4398 "System.Diagnostics.Process::Start_internal(string,string,intptr,intptr,intptr,System.Diagnostics.Process/ProcInfo&)", ves_icall_System_Diagnostics_Process_Start_internal,
4399 "System.Diagnostics.Process::WaitForExit_internal(intptr,int)", ves_icall_System_Diagnostics_Process_WaitForExit_internal,
4400 "System.Diagnostics.Process::ExitTime_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitTime_internal,
4401 "System.Diagnostics.Process::StartTime_internal(intptr)", ves_icall_System_Diagnostics_Process_StartTime_internal,
4402 "System.Diagnostics.Process::ExitCode_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitCode_internal,
4403 "System.Diagnostics.Process::ProcessName_internal(intptr)", ves_icall_System_Diagnostics_Process_ProcessName_internal,
4404 "System.Diagnostics.Process::GetWorkingSet_internal(intptr,int&,int&)", ves_icall_System_Diagnostics_Process_GetWorkingSet_internal,
4405 "System.Diagnostics.Process::SetWorkingSet_internal(intptr,int,int,bool)", ves_icall_System_Diagnostics_Process_SetWorkingSet_internal,
4406 "System.Diagnostics.FileVersionInfo::GetVersionInfo_internal(string)", ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal,
4411 "System.Delegate::CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal,
4414 * System.Runtime.Serialization
4416 "System.Runtime.Serialization.FormatterServices::GetUninitializedObjectInternal",
4417 ves_icall_System_Runtime_Serialization_FormatterServices_GetUninitializedObject_Internal,
4422 "System.IO.Path::get_temp_path", ves_icall_System_IO_get_temp_path,
4425 * Private icalls for the Mono Debugger
4427 "System.Reflection.Assembly::MonoDebugger_GetMethod",
4428 ves_icall_MonoDebugger_GetMethod,
4430 "System.Reflection.Assembly::MonoDebugger_GetMethodToken",
4431 ves_icall_MonoDebugger_GetMethodToken,
4433 "System.Reflection.Assembly::MonoDebugger_GetLocalTypeFromSignature",
4434 ves_icall_MonoDebugger_GetLocalTypeFromSignature,
4436 "System.Reflection.Assembly::MonoDebugger_GetType",
4437 ves_icall_MonoDebugger_GetType,
4440 * System.Configuration
4442 "System.Configuration.DefaultConfig::get_machine_config_path",
4443 ves_icall_System_Configuration_DefaultConfig_get_machine_config_path,
4446 * System.Diagnostics.DefaultTraceListener
4448 "System.Diagnostics.DefaultTraceListener::WriteWindowsDebugString",
4449 ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString,
4453 "System.Activator::CreateInstanceInternal",
4454 ves_icall_System_Activator_CreateInstanceInternal,
4459 "System.Web.Util.ICalls::GetMachineConfigPath",
4460 ves_icall_System_Configuration_DefaultConfig_get_machine_config_path,
4462 "System.Web.Util.ICalls::GetMachineInstallDirectory",
4463 ves_icall_System_Web_Util_ICalls_get_machine_install_dir,
4466 * add other internal calls here
4472 mono_init_icall (void)
4477 while ((name = icall_map [i])) {
4478 mono_add_internal_call (name, icall_map [i+1]);