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_Array_GetValueImpl (MonoObject *this, guint32 pos)
87 ao = (MonoArray *)this;
88 ac = (MonoClass *)ao->obj.vtable->klass;
90 esize = mono_array_element_size (ac);
91 ea = (gpointer*)((char*)ao->vector + (pos * esize));
93 if (ac->element_class->valuetype)
94 return mono_value_box (this->vtable->domain, ac->element_class, ea);
100 ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs)
108 MONO_CHECK_ARG_NULL (idxs);
110 io = (MonoArray *)idxs;
111 ic = (MonoClass *)io->obj.vtable->klass;
113 ao = (MonoArray *)this;
114 ac = (MonoClass *)ao->obj.vtable->klass;
116 g_assert (ic->rank == 1);
117 if (io->bounds != NULL || io->max_length != ac->rank)
118 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
120 ind = (guint32 *)io->vector;
122 if (ao->bounds == NULL) {
123 if (*ind < 0 || *ind >= ao->max_length)
124 mono_raise_exception (mono_get_exception_index_out_of_range ());
126 return ves_icall_System_Array_GetValueImpl (this, *ind);
129 for (i = 0; i < ac->rank; i++)
130 if ((ind [i] < ao->bounds [i].lower_bound) ||
131 (ind [i] >= ao->bounds [i].length + ao->bounds [i].lower_bound))
132 mono_raise_exception (mono_get_exception_index_out_of_range ());
134 pos = ind [0] - ao->bounds [0].lower_bound;
135 for (i = 1; i < ac->rank; i++)
136 pos = pos*ao->bounds [i].length + ind [i] -
137 ao->bounds [i].lower_bound;
139 return ves_icall_System_Array_GetValueImpl (this, pos);
143 ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 pos)
145 MonoClass *ac, *vc, *ec;
156 vc = value->vtable->klass;
160 ac = this->obj.vtable->klass;
161 ec = ac->element_class;
163 esize = mono_array_element_size (ac);
164 ea = (gpointer*)((char*)this->vector + (pos * esize));
165 va = (gpointer*)((char*)value + sizeof (MonoObject));
168 memset (ea, 0, esize);
172 #define NO_WIDENING_CONVERSION G_STMT_START{\
173 mono_raise_exception (mono_get_exception_argument ( \
174 "value", "not a widening conversion")); \
177 #define CHECK_WIDENING_CONVERSION(extra) G_STMT_START{\
178 if (esize < vsize + (extra)) \
179 mono_raise_exception (mono_get_exception_argument ( \
180 "value", "not a widening conversion")); \
183 #define INVALID_CAST G_STMT_START{\
184 mono_raise_exception (mono_get_exception_invalid_cast ()); \
187 /* Check element (destination) type. */
188 switch (ec->byval_arg.type) {
189 case MONO_TYPE_STRING:
190 switch (vc->byval_arg.type) {
191 case MONO_TYPE_STRING:
197 case MONO_TYPE_BOOLEAN:
198 switch (vc->byval_arg.type) {
199 case MONO_TYPE_BOOLEAN:
212 NO_WIDENING_CONVERSION;
219 if (!ec->valuetype) {
220 *ea = (gpointer)value;
224 if (mono_object_isinst (value, ec)) {
225 memcpy (ea, (char *)value + sizeof (MonoObject), esize);
232 vsize = mono_class_instance_size (vc) - sizeof (MonoObject);
235 g_message (G_STRLOC ": %d (%d) <= %d (%d)",
236 ec->byval_arg.type, esize,
237 vc->byval_arg.type, vsize);
240 #define ASSIGN_UNSIGNED(etype) G_STMT_START{\
241 switch (vc->byval_arg.type) { \
246 case MONO_TYPE_CHAR: \
247 CHECK_WIDENING_CONVERSION(0); \
248 *(etype *) ea = (etype) u64; \
250 /* You can't assign a signed value to an unsigned array. */ \
255 /* You can't assign a floating point number to an integer array. */ \
258 NO_WIDENING_CONVERSION; \
262 #define ASSIGN_SIGNED(etype) G_STMT_START{\
263 switch (vc->byval_arg.type) { \
268 CHECK_WIDENING_CONVERSION(0); \
269 *(etype *) ea = (etype) i64; \
271 /* You can assign an unsigned value to a signed array if the array's */ \
272 /* element size is larger than the value size. */ \
277 case MONO_TYPE_CHAR: \
278 CHECK_WIDENING_CONVERSION(1); \
279 *(etype *) ea = (etype) u64; \
281 /* You can't assign a floating point number to an integer array. */ \
284 NO_WIDENING_CONVERSION; \
288 #define ASSIGN_REAL(etype) G_STMT_START{\
289 switch (vc->byval_arg.type) { \
292 CHECK_WIDENING_CONVERSION(0); \
293 *(etype *) ea = (etype) r64; \
295 /* All integer values fit into a floating point array, so we don't */ \
296 /* need to CHECK_WIDENING_CONVERSION here. */ \
301 *(etype *) ea = (etype) i64; \
307 case MONO_TYPE_CHAR: \
308 *(etype *) ea = (etype) u64; \
313 switch (vc->byval_arg.type) {
315 u64 = *(guint8 *) va;
318 u64 = *(guint16 *) va;
321 u64 = *(guint32 *) va;
324 u64 = *(guint64 *) va;
330 i64 = *(gint16 *) va;
333 i64 = *(gint32 *) va;
336 i64 = *(gint64 *) va;
339 r64 = *(gfloat *) va;
342 r64 = *(gdouble *) va;
345 u64 = *(guint16 *) va;
347 case MONO_TYPE_BOOLEAN:
348 /* Boolean is only compatible with itself. */
349 switch (ec->byval_arg.type) {
361 NO_WIDENING_CONVERSION;
368 /* If we can't do a direct copy, let's try a widening conversion. */
369 switch (ec->byval_arg.type) {
371 ASSIGN_UNSIGNED (guint16);
373 ASSIGN_UNSIGNED (guint8);
375 ASSIGN_UNSIGNED (guint16);
377 ASSIGN_UNSIGNED (guint32);
379 ASSIGN_UNSIGNED (guint64);
381 ASSIGN_SIGNED (gint8);
383 ASSIGN_SIGNED (gint16);
385 ASSIGN_SIGNED (gint32);
387 ASSIGN_SIGNED (gint64);
389 ASSIGN_REAL (gfloat);
391 ASSIGN_REAL (gdouble);
395 /* Not reached, INVALID_CAST does not return. Just to avoid a compiler warning ... */
399 #undef NO_WIDENING_CONVERSION
400 #undef CHECK_WIDENING_CONVERSION
401 #undef ASSIGN_UNSIGNED
407 ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value,
415 MONO_CHECK_ARG_NULL (idxs);
417 ic = idxs->obj.vtable->klass;
418 ac = this->obj.vtable->klass;
420 g_assert (ic->rank == 1);
421 if (idxs->bounds != NULL || idxs->max_length != ac->rank)
422 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
424 ind = (guint32 *)idxs->vector;
426 if (this->bounds == NULL) {
427 if (*ind < 0 || *ind >= this->max_length)
428 mono_raise_exception (mono_get_exception_index_out_of_range ());
430 ves_icall_System_Array_SetValueImpl (this, value, *ind);
434 for (i = 0; i < ac->rank; i++)
435 if ((ind [i] < this->bounds [i].lower_bound) ||
436 (ind [i] >= this->bounds [i].length + this->bounds [i].lower_bound))
437 mono_raise_exception (mono_get_exception_index_out_of_range ());
439 pos = ind [0] - this->bounds [0].lower_bound;
440 for (i = 1; i < ac->rank; i++)
441 pos = pos * this->bounds [i].length + ind [i] -
442 this->bounds [i].lower_bound;
444 ves_icall_System_Array_SetValueImpl (this, value, pos);
448 ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *lengths, MonoArray *bounds)
456 MONO_CHECK_ARG_NULL (type);
457 MONO_CHECK_ARG_NULL (lengths);
459 MONO_CHECK_ARG (lengths, mono_array_length (lengths) > 0);
461 MONO_CHECK_ARG (bounds, mono_array_length (lengths) == mono_array_length (bounds));
463 for (i = 0; i < mono_array_length (lengths); i++)
464 if (mono_array_get (lengths, gint32, i) < 0)
465 mono_raise_exception (mono_get_exception_argument_out_of_range (NULL));
467 aklass = mono_array_class_get (type->type, mono_array_length (lengths));
469 sizes = alloca (aklass->rank * sizeof(guint32) * 2);
470 for (i = 0; i < aklass->rank; ++i) {
471 sizes [i] = mono_array_get (lengths, gint32, i);
473 sizes [i + aklass->rank] = mono_array_get (bounds, gint32, i);
475 sizes [i + aklass->rank] = 0;
478 array = mono_array_new_full (mono_object_domain (type), aklass, sizes, sizes + aklass->rank);
484 ves_icall_System_Array_GetRank (MonoObject *this)
488 return this->vtable->klass->rank;
492 ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension)
494 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
498 if ((dimension < 0) || (dimension >= rank))
499 mono_raise_exception (mono_get_exception_index_out_of_range ());
501 if (this->bounds == NULL)
502 return this->max_length;
504 return this->bounds [dimension].length;
508 ves_icall_System_Array_GetLowerBound (MonoArray *this, gint32 dimension)
510 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
514 if ((dimension < 0) || (dimension >= rank))
515 mono_raise_exception (mono_get_exception_index_out_of_range ());
517 if (this->bounds == NULL)
520 return this->bounds [dimension].lower_bound;
524 ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* dest, int dest_idx, int length)
529 MonoClass *src_class;
530 MonoClass *dest_class;
535 if (source->obj.vtable->klass->rank != dest->obj.vtable->klass->rank)
538 if (source->bounds || dest->bounds)
541 if ((dest_idx + length > mono_array_length (dest)) ||
542 (source_idx + length > mono_array_length (source)))
545 element_size = mono_array_element_size (source->obj.vtable->klass);
546 dest_addr = mono_array_addr_with_size (dest, element_size, dest_idx);
547 source_addr = mono_array_addr_with_size (source, element_size, source_idx);
549 src_class = source->obj.vtable->klass->element_class;
550 dest_class = dest->obj.vtable->klass->element_class;
553 * Handle common cases.
556 /* Case1: object[] -> valuetype[] (ArrayList::ToArray) */
557 if (src_class == mono_defaults.object_class && dest_class->valuetype) {
558 for (i = source_idx; i < source_idx + length; ++i) {
559 MonoObject *elem = mono_array_get (source, MonoObject*, i);
560 if (elem && !mono_object_isinst (elem, dest_class))
564 element_size = mono_array_element_size (dest->obj.vtable->klass);
565 for (i = 0; i < length; ++i) {
566 MonoObject *elem = mono_array_get (source, MonoObject*, source_idx + i);
567 void *addr = mono_array_addr_with_size (dest, element_size, dest_idx + i);
569 memset (addr, 0, element_size);
571 memcpy (addr, (char *)elem + sizeof (MonoObject), element_size);
576 if (src_class != dest_class) {
577 if (dest_class->valuetype || dest_class->enumtype || src_class->valuetype || src_class->enumtype)
580 if (mono_class_is_subclass_of (src_class, dest_class, FALSE))
582 /* Case2: object[] -> reftype[] (ArrayList::ToArray) */
583 else if (mono_class_is_subclass_of (dest_class, src_class, FALSE))
584 for (i = source_idx; i < source_idx + length; ++i) {
585 MonoObject *elem = mono_array_get (source, MonoObject*, i);
586 if (elem && !mono_object_isinst (elem, dest_class))
593 memmove (dest_addr, source_addr, element_size * length);
599 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoArray *array, MonoClassField *field_handle)
601 MonoClass *klass = array->obj.vtable->klass;
602 guint32 size = mono_array_element_size (klass);
607 if (array->bounds == NULL)
608 size *= array->max_length;
610 for (i = 0; i < klass->rank; ++i)
611 size *= array->bounds [i].length;
613 memcpy (mono_array_addr (array, char, 0), field_handle->data, size);
615 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
619 guint ## n *data = (guint ## n *) mono_array_addr (array, char, 0); \
621 for (i = 0; i < size; i += n/8, data++) { \
622 tmp = read ## n (data); \
627 /* printf ("Initialize array with elements of %s type\n", klass->element_class->name); */
629 switch (klass->element_class->byval_arg.type) {
649 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData (void)
653 return offsetof (MonoString, chars);
657 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObject *obj)
661 if ((obj == NULL) || (! (obj->vtable->klass->valuetype)))
664 return mono_object_clone (obj);
668 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (MonoType *handle)
674 MONO_CHECK_ARG_NULL (handle);
676 klass = mono_class_from_mono_type (handle);
677 MONO_CHECK_ARG (handle, klass);
679 /* This will call the type constructor */
680 if (! (klass->flags & TYPE_ATTRIBUTE_INTERFACE))
681 mono_runtime_class_init (mono_class_vtable (mono_domain_get (), klass));
685 ves_icall_System_Object_MemberwiseClone (MonoObject *this)
689 return mono_object_clone (this);
693 #define MONO_OBJECT_ALIGNMENT_SHIFT 3
695 #define MONO_OBJECT_ALIGNMENT_SHIFT 2
699 * Return hashcode based on object address. This function will need to be
700 * smarter in the presence of a moving garbage collector, which will cache
701 * the address hash before relocating the object.
703 * Wang's address-based hash function:
704 * http://www.concentric.net/~Ttwang/tech/addrhash.htm
707 ves_icall_System_Object_GetHashCode (MonoObject *this)
709 register guint32 key;
713 key = (GPOINTER_TO_UINT (this) >> MONO_OBJECT_ALIGNMENT_SHIFT) * 2654435761u;
715 return key & 0x7fffffff;
719 * A hash function for value types. I have no idea if this is a good hash
720 * function (its similar to g_str_hash).
723 ves_icall_System_ValueType_GetHashCode (MonoObject *this)
731 MONO_CHECK_ARG_NULL (this);
733 size = this->vtable->klass->instance_size - sizeof (MonoObject);
735 p = (const char *)this + sizeof (MonoObject);
737 for (i = 0; i < size; i++) {
738 h = (h << 5) - h + *p;
746 ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that)
753 MONO_CHECK_ARG_NULL (that);
755 if (this->vtable != that->vtable)
758 size = this->vtable->klass->instance_size - sizeof (MonoObject);
760 p = (const char *)this + sizeof (MonoObject);
761 s = (const char *)that + sizeof (MonoObject);
763 return memcmp (p, s, size)? FALSE: TRUE;
766 static MonoReflectionType *
767 ves_icall_System_Object_GetType (MonoObject *obj)
771 return mono_type_get_object (mono_object_domain (obj), &obj->vtable->klass->byval_arg);
775 mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
779 mtype->type = &obj->vtable->klass->byval_arg;
780 g_assert (mtype->type->type);
784 ves_icall_AssemblyBuilder_getToken (MonoReflectionAssemblyBuilder *assb, MonoObject *obj)
788 return mono_image_create_token (assb->dynamic_assembly, obj);
792 ves_icall_AssemblyBuilder_getDataChunk (MonoReflectionAssemblyBuilder *assb, MonoArray *buf, gint32 offset)
795 MonoDynamicAssembly *ass = assb->dynamic_assembly;
796 char *p = mono_array_addr (buf, char, 0);
800 mono_image_create_pefile (assb);
802 if (offset >= ass->pefile.index)
804 count = mono_array_length (buf);
805 count = MIN (count, ass->pefile.index - offset);
807 memcpy (p, ass->pefile.data + offset, count);
813 ves_icall_AssemblyBuilder_build_metadata (MonoReflectionAssemblyBuilder *assb)
817 mono_image_build_metadata (assb);
820 static MonoReflectionType*
821 ves_icall_type_from_name (MonoString *name,
822 MonoBoolean throwOnError,
823 MonoBoolean ignoreCase)
826 MonoType *type = NULL;
827 MonoAssembly *assembly;
828 MonoTypeNameParse info;
832 str = mono_string_to_utf8 (name);
833 if (!mono_reflection_parse_type (str, &info)) {
835 g_list_free (info.modifiers);
836 g_list_free (info.nested);
837 if (throwOnError) /* uhm: this is a parse error, though... */
838 mono_raise_exception (mono_get_exception_type_load ());
843 if (info.assembly.name) {
844 assembly = mono_assembly_load (&info.assembly, NULL, NULL);
846 MonoReflectionAssembly *refass;
848 refass = ves_icall_System_Reflection_Assembly_GetCallingAssembly ();
849 assembly = refass->assembly;
853 type = mono_reflection_get_type (assembly->image, &info, ignoreCase);
855 if (!info.assembly.name && !type) /* try mscorlib */
856 type = mono_reflection_get_type (NULL, &info, ignoreCase);
859 g_list_free (info.modifiers);
860 g_list_free (info.nested);
863 mono_raise_exception (mono_get_exception_type_load ());
868 return mono_type_get_object (mono_domain_get (), type);
871 static MonoReflectionType*
872 ves_icall_type_from_handle (MonoType *handle)
874 MonoDomain *domain = mono_domain_get ();
875 MonoClass *klass = mono_class_from_mono_type (handle);
879 mono_class_init (klass);
880 return mono_type_get_object (domain, handle);
884 ves_icall_type_Equals (MonoReflectionType *type, MonoReflectionType *c)
888 if (type->type && c->type)
889 return mono_metadata_type_equal (type->type, c->type);
890 g_print ("type equals\n");
894 /* System.TypeCode */
917 ves_icall_type_GetTypeCode (MonoReflectionType *type)
919 int t = type->type->type;
926 return TYPECODE_OBJECT;
927 case MONO_TYPE_BOOLEAN:
928 return TYPECODE_BOOLEAN;
930 return TYPECODE_BYTE;
932 return TYPECODE_SBYTE;
934 return TYPECODE_UINT16;
936 return TYPECODE_INT16;
938 return TYPECODE_CHAR;
942 return TYPECODE_OBJECT;
944 return TYPECODE_UINT32;
946 return TYPECODE_INT32;
948 return TYPECODE_UINT64;
950 return TYPECODE_INT64;
952 return TYPECODE_SINGLE;
954 return TYPECODE_DOUBLE;
955 case MONO_TYPE_VALUETYPE:
956 if (type->type->data.klass->enumtype) {
957 t = type->type->data.klass->enum_basetype->type;
960 MonoClass *k = type->type->data.klass;
961 if (strcmp (k->name_space, "System") == 0) {
962 if (strcmp (k->name, "Decimal") == 0)
963 return TYPECODE_DECIMAL;
964 else if (strcmp (k->name, "DateTime") == 0)
965 return TYPECODE_DATETIME;
968 return TYPECODE_OBJECT;
969 case MONO_TYPE_STRING:
970 return TYPECODE_STRING;
971 case MONO_TYPE_SZARRAY:
972 case MONO_TYPE_ARRAY:
973 case MONO_TYPE_OBJECT:
974 return TYPECODE_OBJECT;
975 case MONO_TYPE_CLASS:
977 MonoClass *k = type->type->data.klass;
978 if (strcmp (k->name_space, "System") == 0) {
979 if (strcmp (k->name, "DBNull") == 0)
980 return TYPECODE_DBNULL;
983 return TYPECODE_OBJECT;
985 g_error ("type 0x%02x not handled in GetTypeCode()", t);
991 ves_icall_type_is_subtype_of (MonoReflectionType *type, MonoReflectionType *c, MonoBoolean check_interfaces)
999 g_assert (type != NULL);
1001 domain = ((MonoObject *)type)->vtable->domain;
1003 if (!c) /* FIXME: dont know what do do here */
1006 klass = mono_class_from_mono_type (type->type);
1007 klassc = mono_class_from_mono_type (c->type);
1009 return mono_class_is_subclass_of (klass, klassc, check_interfaces);
1013 ves_icall_get_attributes (MonoReflectionType *type)
1015 MonoClass *klass = mono_class_from_mono_type (type->type);
1017 MONO_ARCH_SAVE_REGS;
1019 return klass->flags;
1022 static MonoFieldInfo*
1023 ves_icall_System_Reflection_FieldInfo_internal_from_handle (MonoClassField *handle)
1025 MONO_ARCH_SAVE_REGS;
1029 return (MonoFieldInfo*) mono_field_get_object (mono_domain_get (),
1035 ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info)
1037 MonoDomain *domain = mono_domain_get ();
1039 MONO_ARCH_SAVE_REGS;
1041 info->parent = mono_type_get_object (domain, &method->klass->byval_arg);
1042 info->ret = mono_type_get_object (domain, method->signature->ret);
1043 info->attrs = method->flags;
1044 info->implattrs = method->iflags;
1048 ves_icall_get_parameter_info (MonoMethod *method)
1050 MonoDomain *domain = mono_domain_get ();
1052 static MonoClass *System_Reflection_ParameterInfo;
1053 MonoReflectionParameter** args;
1056 MONO_ARCH_SAVE_REGS;
1058 args = mono_param_get_objects (domain, method);
1059 if (!System_Reflection_ParameterInfo)
1060 System_Reflection_ParameterInfo = mono_class_from_name (
1061 mono_defaults.corlib, "System.Reflection", "ParameterInfo");
1062 res = mono_array_new (domain, System_Reflection_ParameterInfo, method->signature->param_count);
1063 for (i = 0; i < method->signature->param_count; ++i) {
1064 mono_array_set (res, gpointer, i, args [i]);
1070 ves_icall_get_field_info (MonoReflectionField *field, MonoFieldInfo *info)
1072 MonoDomain *domain = mono_object_domain (field);
1074 MONO_ARCH_SAVE_REGS;
1076 info->parent = mono_type_get_object (domain, &field->klass->byval_arg);
1077 info->type = mono_type_get_object (domain, field->field->type);
1078 info->name = mono_string_new (domain, field->field->name);
1079 info->attrs = field->field->type->attrs;
1083 ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *obj)
1086 MonoClassField *cf = field->field;
1089 MonoDomain *domain = mono_object_domain (field);
1091 gboolean is_static = FALSE;
1092 gboolean is_ref = FALSE;
1094 MONO_ARCH_SAVE_REGS;
1096 mono_class_init (field->klass);
1098 switch (cf->type->type) {
1099 case MONO_TYPE_STRING:
1100 case MONO_TYPE_OBJECT:
1101 case MONO_TYPE_CLASS:
1102 case MONO_TYPE_ARRAY:
1103 case MONO_TYPE_SZARRAY:
1108 case MONO_TYPE_BOOLEAN:
1111 case MONO_TYPE_CHAR:
1120 case MONO_TYPE_VALUETYPE:
1121 is_ref = cf->type->byref;
1124 g_error ("type 0x%x not handled in "
1125 "ves_icall_Monofield_GetValue", cf->type->type);
1129 if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1131 vtable = mono_class_vtable (domain, field->klass);
1132 if (!vtable->initialized)
1133 mono_runtime_class_init (vtable);
1138 mono_field_static_get_value (vtable, cf, &o);
1140 mono_field_get_value (obj, cf, &o);
1145 /* boxed value type */
1146 klass = mono_class_from_mono_type (cf->type);
1147 o = mono_object_new (domain, klass);
1148 v = ((gchar *) o) + sizeof (MonoObject);
1150 mono_field_static_get_value (vtable, cf, v);
1152 mono_field_get_value (obj, cf, v);
1159 ves_icall_FieldInfo_SetValueInternal (MonoReflectionField *field, MonoObject *obj, MonoObject *value)
1161 MonoClassField *cf = field->field;
1164 MONO_ARCH_SAVE_REGS;
1166 v = (gchar *) value;
1167 if (!cf->type->byref) {
1168 switch (cf->type->type) {
1171 case MONO_TYPE_BOOLEAN:
1174 case MONO_TYPE_CHAR:
1183 case MONO_TYPE_VALUETYPE:
1184 v += sizeof (MonoObject);
1186 case MONO_TYPE_STRING:
1187 case MONO_TYPE_OBJECT:
1188 case MONO_TYPE_CLASS:
1189 case MONO_TYPE_ARRAY:
1190 case MONO_TYPE_SZARRAY:
1194 g_error ("type 0x%x not handled in "
1195 "ves_icall_FieldInfo_SetValueInternal", cf->type->type);
1200 if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1201 MonoVTable *vtable = mono_class_vtable (mono_object_domain (field), field->klass);
1202 if (!vtable->initialized)
1203 mono_runtime_class_init (vtable);
1204 mono_field_static_set_value (vtable, cf, v);
1206 mono_field_set_value (obj, cf, v);
1211 ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info)
1213 MonoDomain *domain = mono_object_domain (property);
1215 MONO_ARCH_SAVE_REGS;
1217 info->parent = mono_type_get_object (domain, &property->klass->byval_arg);
1218 info->name = mono_string_new (domain, property->property->name);
1219 info->attrs = property->property->attrs;
1220 info->get = property->property->get ? mono_method_get_object (domain, property->property->get, NULL): NULL;
1221 info->set = property->property->set ? mono_method_get_object (domain, property->property->set, NULL): NULL;
1223 * There may be other methods defined for properties, though, it seems they are not exposed
1224 * in the reflection API
1229 ves_icall_get_event_info (MonoReflectionEvent *event, MonoEventInfo *info)
1231 MonoDomain *domain = mono_object_domain (event);
1233 MONO_ARCH_SAVE_REGS;
1235 info->parent = mono_type_get_object (domain, &event->klass->byval_arg);
1236 info->name = mono_string_new (domain, event->event->name);
1237 info->attrs = event->event->attrs;
1238 info->add_method = event->event->add ? mono_method_get_object (domain, event->event->add, NULL): NULL;
1239 info->remove_method = event->event->remove ? mono_method_get_object (domain, event->event->remove, NULL): NULL;
1240 info->raise_method = event->event->raise ? mono_method_get_object (domain, event->event->raise, NULL): NULL;
1244 ves_icall_Type_GetInterfaces (MonoReflectionType* type)
1246 MonoDomain *domain = mono_object_domain (type);
1249 MonoClass *class = mono_class_from_mono_type (type->type);
1252 MONO_ARCH_SAVE_REGS;
1255 for (parent = class; parent; parent = parent->parent) {
1256 ninterf += parent->interface_count;
1258 intf = mono_array_new (domain, mono_defaults.monotype_class, ninterf);
1260 for (parent = class; parent; parent = parent->parent) {
1261 for (i = 0; i < parent->interface_count; ++i) {
1262 mono_array_set (intf, gpointer, ninterf, mono_type_get_object (domain, &parent->interfaces [i]->byval_arg));
1270 ves_icall_Type_GetInterfaceMapData (MonoReflectionType *type, MonoReflectionType *iface, MonoArray **targets, MonoArray **methods)
1272 MonoClass *class = mono_class_from_mono_type (type->type);
1273 MonoClass *iclass = mono_class_from_mono_type (iface->type);
1274 MonoReflectionMethod *member;
1275 int i, len, ioffset;
1278 MONO_ARCH_SAVE_REGS;
1280 /* type doesn't implement iface: the exception is thrown in managed code */
1281 if ((iclass->interface_id > class->max_interface_id) || !class->interface_offsets [iclass->interface_id])
1284 len = iclass->method.count;
1285 ioffset = class->interface_offsets [iclass->interface_id];
1286 domain = mono_object_domain (type);
1287 *targets = mono_array_new (domain, mono_defaults.method_info_class, len);
1288 *methods = mono_array_new (domain, mono_defaults.method_info_class, len);
1289 for (i = 0; i < len; ++i) {
1290 member = mono_method_get_object (domain, iclass->methods [i], iclass);
1291 mono_array_set (*methods, gpointer, i, member);
1292 member = mono_method_get_object (domain, class->vtable [i + ioffset], class);
1293 mono_array_set (*targets, gpointer, i, member);
1297 static MonoReflectionType*
1298 ves_icall_MonoType_GetElementType (MonoReflectionType *type)
1300 MonoClass *class = mono_class_from_mono_type (type->type);
1302 MONO_ARCH_SAVE_REGS;
1304 if (type->type->byref)
1305 return mono_type_get_object (mono_object_domain (type), &class->byval_arg);
1306 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
1307 return mono_type_get_object (mono_object_domain (type), class->enum_basetype);
1308 else if (class->element_class)
1309 return mono_type_get_object (mono_object_domain (type), &class->element_class->byval_arg);
1314 static MonoReflectionType*
1315 ves_icall_get_type_parent (MonoReflectionType *type)
1317 MonoClass *class = mono_class_from_mono_type (type->type);
1319 MONO_ARCH_SAVE_REGS;
1321 return class->parent ? mono_type_get_object (mono_object_domain (type), &class->parent->byval_arg): NULL;
1325 ves_icall_type_ispointer (MonoReflectionType *type)
1327 MONO_ARCH_SAVE_REGS;
1329 return type->type->type == MONO_TYPE_PTR;
1333 ves_icall_type_isbyref (MonoReflectionType *type)
1335 MONO_ARCH_SAVE_REGS;
1337 return type->type->byref;
1340 static MonoReflectionModule*
1341 ves_icall_MonoType_get_Module (MonoReflectionType *type)
1343 MonoClass *class = mono_class_from_mono_type (type->type);
1345 MONO_ARCH_SAVE_REGS;
1347 return mono_module_get_object (mono_object_domain (type), class->image);
1351 ves_icall_get_type_info (MonoType *type, MonoTypeInfo *info)
1353 MonoDomain *domain = mono_domain_get ();
1354 MonoClass *class = mono_class_from_mono_type (type);
1356 MONO_ARCH_SAVE_REGS;
1358 info->nested_in = class->nested_in ? mono_type_get_object (domain, &class->nested_in->byval_arg): NULL;
1359 info->name = mono_string_new (domain, class->name);
1360 info->name_space = mono_string_new (domain, class->name_space);
1361 info->rank = class->rank;
1362 info->assembly = mono_assembly_get_object (domain, class->image->assembly);
1363 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
1364 info->etype = mono_type_get_object (domain, class->enum_basetype);
1365 else if (class->element_class)
1366 info->etype = mono_type_get_object (domain, &class->element_class->byval_arg);
1370 info->isprimitive = (!type->byref && (type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8));
1374 ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params)
1377 * Invoke from reflection is supposed to always be a virtual call (the API
1378 * is stupid), mono_runtime_invoke_*() calls the provided method, allowing
1379 * greater flexibility.
1381 MonoMethod *m = method->method;
1384 MONO_ARCH_SAVE_REGS;
1387 if (!mono_object_isinst (this, m->klass))
1388 mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
1389 m = mono_object_get_virtual_method (this, m);
1390 } else if (!(m->flags & METHOD_ATTRIBUTE_STATIC) && strcmp (m->name, ".ctor"))
1391 mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
1393 pcount = params? mono_array_length (params): 0;
1394 if (pcount != m->signature->param_count)
1395 mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetParameterCountException"));
1397 if (m->klass->rank && !strcmp (m->name, ".ctor")) {
1400 guint32 *lower_bounds;
1401 pcount = mono_array_length (params);
1402 lengths = alloca (sizeof (guint32) * pcount);
1403 for (i = 0; i < pcount; ++i)
1404 lengths [i] = *(gint32*) ((char*)mono_array_get (params, gpointer, i) + sizeof (MonoObject));
1406 if (m->klass->rank == pcount) {
1407 /* Only lengths provided. */
1408 lower_bounds = NULL;
1410 g_assert (pcount == (m->klass->rank * 2));
1411 /* lower bounds are first. */
1412 lower_bounds = lengths;
1413 lengths += m->klass->rank;
1416 return (MonoObject*)mono_array_new_full (mono_object_domain (params), m->klass, lengths, lower_bounds);
1418 return mono_runtime_invoke_array (m, this, params, NULL);
1422 ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoArray *params, MonoArray **outArgs)
1424 MonoDomain *domain = mono_object_domain (method);
1425 MonoMethod *m = method->method;
1426 MonoMethodSignature *sig = m->signature;
1427 MonoArray *out_args;
1429 int i, j, outarg_count = 0;
1431 MONO_ARCH_SAVE_REGS;
1433 if (m->klass == mono_defaults.object_class) {
1435 if (!strcmp (m->name, "FieldGetter")) {
1436 MonoClass *k = this->vtable->klass;
1437 MonoString *name = mono_array_get (params, MonoString *, 1);
1440 str = mono_string_to_utf8 (name);
1442 for (i = 0; i < k->field.count; i++) {
1443 if (!strcmp (k->fields [i].name, str)) {
1444 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
1445 if (field_klass->valuetype)
1446 result = mono_value_box (domain, field_klass,
1447 (char *)this + k->fields [i].offset);
1449 result = *((gpointer *)((char *)this + k->fields [i].offset));
1452 out_args = mono_array_new (domain, mono_defaults.object_class, 1);
1453 *outArgs = out_args;
1454 mono_array_set (out_args, gpointer, 0, result);
1461 g_assert_not_reached ();
1463 } else if (!strcmp (m->name, "FieldSetter")) {
1464 MonoClass *k = this->vtable->klass;
1465 MonoString *name = mono_array_get (params, MonoString *, 1);
1469 str = mono_string_to_utf8 (name);
1471 for (i = 0; i < k->field.count; i++) {
1472 if (!strcmp (k->fields [i].name, str)) {
1473 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
1474 MonoObject *val = mono_array_get (params, gpointer, 2);
1476 if (field_klass->valuetype) {
1477 size = mono_type_size (k->fields [i].type, &align);
1478 memcpy ((char *)this + k->fields [i].offset,
1479 ((char *)val) + sizeof (MonoObject), size);
1481 *(MonoObject**)((char *)this + k->fields [i].offset) = val;
1483 out_args = mono_array_new (domain, mono_defaults.object_class, 0);
1484 *outArgs = out_args;
1492 g_assert_not_reached ();
1497 for (i = 0; i < mono_array_length (params); i++) {
1498 if (sig->params [i]->byref)
1502 out_args = mono_array_new (domain, mono_defaults.object_class, outarg_count);
1504 /* fixme: handle constructors? */
1505 if (!strcmp (method->method->name, ".ctor"))
1506 g_assert_not_reached ();
1508 result = mono_runtime_invoke_array (method->method, this, params, NULL);
1510 for (i = 0, j = 0; i < mono_array_length (params); i++) {
1511 if (sig->params [i]->byref) {
1513 arg = mono_array_get (params, gpointer, i);
1514 mono_array_set (out_args, gpointer, j, arg);
1519 *outArgs = out_args;
1525 ves_icall_System_Enum_ToObject (MonoReflectionType *type, MonoObject *obj)
1528 MonoClass *enumc, *objc;
1532 MONO_ARCH_SAVE_REGS;
1534 MONO_CHECK_ARG_NULL (type);
1535 MONO_CHECK_ARG_NULL (obj);
1537 domain = mono_object_domain (type);
1538 enumc = mono_class_from_mono_type (type->type);
1539 objc = obj->vtable->klass;
1541 MONO_CHECK_ARG (obj, enumc->enumtype == TRUE);
1542 MONO_CHECK_ARG (obj, (objc->enumtype) || (objc->byval_arg.type >= MONO_TYPE_I1 &&
1543 objc->byval_arg.type <= MONO_TYPE_U8));
1545 s1 = mono_class_value_size (enumc, NULL);
1546 s2 = mono_class_value_size (objc, NULL);
1548 res = mono_object_new (domain, enumc);
1550 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1551 memcpy ((char *)res + sizeof (MonoObject), (char *)obj + sizeof (MonoObject), MIN (s1, s2));
1553 memcpy ((char *)res + sizeof (MonoObject) + (s1 > s2 ? s1 - s2 : 0),
1554 (char *)obj + sizeof (MonoObject) + (s2 > s1 ? s2 - s1 : 0),
1561 ves_icall_System_Enum_get_value (MonoObject *this)
1569 MONO_ARCH_SAVE_REGS;
1574 g_assert (this->vtable->klass->enumtype);
1576 enumc = mono_class_from_mono_type (this->vtable->klass->enum_basetype);
1577 res = mono_object_new (mono_object_domain (this), enumc);
1578 dst = (char *)res + sizeof (MonoObject);
1579 src = (char *)this + sizeof (MonoObject);
1580 size = mono_class_value_size (enumc, NULL);
1582 memcpy (dst, src, size);
1588 ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
1590 MonoDomain *domain = mono_object_domain (type);
1591 MonoClass *enumc = mono_class_from_mono_type (type->type);
1592 guint i, j, nvalues, crow;
1593 MonoClassField *field;
1595 MONO_ARCH_SAVE_REGS;
1597 info->utype = mono_type_get_object (domain, enumc->enum_basetype);
1598 nvalues = enumc->field.count - 1;
1599 info->names = mono_array_new (domain, mono_defaults.string_class, nvalues);
1600 info->values = mono_array_new (domain, enumc, nvalues);
1602 for (i = 0, j = 0; i < enumc->field.count; ++i) {
1603 field = &enumc->fields [i];
1604 if (strcmp ("value__", field->name) == 0)
1606 mono_array_set (info->names, gpointer, j, mono_string_new (domain, field->name));
1608 crow = mono_metadata_get_constant_index (enumc->image, MONO_TOKEN_FIELD_DEF | (i+enumc->field.first+1));
1609 crow = mono_metadata_decode_row_col (&enumc->image->tables [MONO_TABLE_CONSTANT], crow-1, MONO_CONSTANT_VALUE);
1610 /* 1 is the length of the blob */
1611 field->data = 1 + mono_metadata_blob_heap (enumc->image, crow);
1613 switch (enumc->enum_basetype->type) {
1616 mono_array_set (info->values, gchar, j, *field->data);
1618 case MONO_TYPE_CHAR:
1621 mono_array_set (info->values, gint16, j, read16 (field->data));
1625 mono_array_set (info->values, gint32, j, read32 (field->data));
1629 mono_array_set (info->values, gint64, j, read64 (field->data));
1632 g_error ("Implement type 0x%02x in get_enum_info", enumc->enum_basetype->type);
1639 BFLAGS_IgnoreCase = 1,
1640 BFLAGS_DeclaredOnly = 2,
1641 BFLAGS_Instance = 4,
1643 BFLAGS_Public = 0x10,
1644 BFLAGS_NonPublic = 0x20,
1645 BFLAGS_InvokeMethod = 0x100,
1646 BFLAGS_CreateInstance = 0x200,
1647 BFLAGS_GetField = 0x400,
1648 BFLAGS_SetField = 0x800,
1649 BFLAGS_GetProperty = 0x1000,
1650 BFLAGS_SetProperty = 0x2000,
1651 BFLAGS_ExactBinding = 0x10000,
1652 BFLAGS_SuppressChangeType = 0x20000,
1653 BFLAGS_OptionalParamBinding = 0x40000
1656 static MonoFieldInfo *
1657 ves_icall_Type_GetField (MonoReflectionType *type, MonoString *name, guint32 bflags)
1660 MonoClass *startklass, *klass;
1662 MonoClassField *field;
1664 domain = ((MonoObject *)type)->vtable->domain;
1665 klass = startklass = mono_class_from_mono_type (type->type);
1667 MONO_ARCH_SAVE_REGS;
1670 mono_raise_exception (mono_get_exception_argument_null ("name"));
1673 for (i = 0; i < klass->field.count; ++i) {
1675 field = &klass->fields [i];
1676 if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
1677 if (bflags & BFLAGS_Public)
1680 if (bflags & BFLAGS_NonPublic)
1686 if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1687 if (bflags & BFLAGS_Static)
1690 if (bflags & BFLAGS_Instance)
1697 utf8_name = mono_string_to_utf8 (name);
1699 if (strcmp (field->name, utf8_name)) {
1705 return (MonoFieldInfo *)mono_field_get_object (domain, klass, field);
1707 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1714 ves_icall_Type_GetFields (MonoReflectionType *type, guint32 bflags)
1717 GSList *l = NULL, *tmp;
1718 MonoClass *startklass, *klass;
1722 MonoClassField *field;
1724 MONO_ARCH_SAVE_REGS;
1726 domain = ((MonoObject *)type)->vtable->domain;
1727 klass = startklass = mono_class_from_mono_type (type->type);
1730 for (i = 0; i < klass->field.count; ++i) {
1732 field = &klass->fields [i];
1733 if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
1734 if (bflags & BFLAGS_Public)
1737 if (bflags & BFLAGS_NonPublic)
1743 if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1744 if (bflags & BFLAGS_Static)
1747 if (bflags & BFLAGS_Instance)
1753 member = (MonoObject*)mono_field_get_object (domain, klass, field);
1754 l = g_slist_prepend (l, member);
1756 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1758 len = g_slist_length (l);
1759 res = mono_array_new (domain, mono_defaults.field_info_class, len);
1761 tmp = g_slist_reverse (l);
1762 for (; tmp; tmp = tmp->next, ++i)
1763 mono_array_set (res, gpointer, i, tmp->data);
1769 ves_icall_Type_GetMethods (MonoReflectionType *type, guint32 bflags)
1772 GSList *l = NULL, *tmp;
1773 MonoClass *startklass, *klass;
1778 GHashTable *method_slots = g_hash_table_new (NULL, NULL);
1780 MONO_ARCH_SAVE_REGS;
1782 domain = ((MonoObject *)type)->vtable->domain;
1783 klass = startklass = mono_class_from_mono_type (type->type);
1787 for (i = 0; i < klass->method.count; ++i) {
1789 method = klass->methods [i];
1790 if (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0)
1792 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1793 if (bflags & BFLAGS_Public)
1796 if (bflags & BFLAGS_NonPublic)
1802 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1803 if (bflags & BFLAGS_Static)
1806 if (bflags & BFLAGS_Instance)
1813 if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
1815 g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), method);
1816 member = (MonoObject*)mono_method_get_object (domain, method, startklass);
1818 l = g_slist_prepend (l, member);
1821 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1823 res = mono_array_new (domain, mono_defaults.method_info_class, len);
1825 #ifdef FIXED_MCS_45127
1826 tmp = g_slist_reverse (l);
1830 for (; tmp; tmp = tmp->next, ++i)
1831 mono_array_set (res, gpointer, i, tmp->data);
1833 g_hash_table_destroy (method_slots);
1838 ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
1841 GSList *l = NULL, *tmp;
1842 static MonoClass *System_Reflection_ConstructorInfo;
1843 MonoClass *startklass, *klass;
1849 MONO_ARCH_SAVE_REGS;
1851 domain = ((MonoObject *)type)->vtable->domain;
1852 klass = startklass = mono_class_from_mono_type (type->type);
1854 for (i = 0; i < klass->method.count; ++i) {
1856 method = klass->methods [i];
1857 if (strcmp (method->name, ".ctor") && strcmp (method->name, ".cctor"))
1859 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1860 if (bflags & BFLAGS_Public)
1863 if (bflags & BFLAGS_NonPublic)
1869 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1870 if (bflags & BFLAGS_Static)
1873 if (bflags & BFLAGS_Instance)
1879 member = (MonoObject*)mono_method_get_object (domain, method, startklass);
1881 l = g_slist_prepend (l, member);
1883 len = g_slist_length (l);
1884 if (!System_Reflection_ConstructorInfo)
1885 System_Reflection_ConstructorInfo = mono_class_from_name (
1886 mono_defaults.corlib, "System.Reflection", "ConstructorInfo");
1887 res = mono_array_new (domain, System_Reflection_ConstructorInfo, len);
1889 tmp = g_slist_reverse (l);
1890 for (; tmp; tmp = tmp->next, ++i)
1891 mono_array_set (res, gpointer, i, tmp->data);
1897 ves_icall_Type_GetProperties (MonoReflectionType *type, guint32 bflags)
1900 GSList *l = NULL, *tmp;
1901 static MonoClass *System_Reflection_PropertyInfo;
1902 MonoClass *startklass, *klass;
1908 GHashTable *method_slots = g_hash_table_new (NULL, NULL);
1910 MONO_ARCH_SAVE_REGS;
1912 domain = ((MonoObject *)type)->vtable->domain;
1913 klass = startklass = mono_class_from_mono_type (type->type);
1916 for (i = 0; i < klass->property.count; ++i) {
1917 prop = &klass->properties [i];
1922 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1923 if (bflags & BFLAGS_Public)
1926 if (bflags & BFLAGS_NonPublic)
1932 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1933 if (bflags & BFLAGS_Static)
1936 if (bflags & BFLAGS_Instance)
1944 if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
1946 g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), prop);
1948 l = g_slist_prepend (l, mono_property_get_object (domain, klass, prop));
1951 if ((!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)))
1953 if (!System_Reflection_PropertyInfo)
1954 System_Reflection_PropertyInfo = mono_class_from_name (
1955 mono_defaults.corlib, "System.Reflection", "PropertyInfo");
1956 res = mono_array_new (domain, System_Reflection_PropertyInfo, len);
1958 #ifdef FIXED_MCS_45127
1959 tmp = g_slist_reverse (l);
1963 for (; tmp; tmp = tmp->next, ++i)
1964 mono_array_set (res, gpointer, i, tmp->data);
1966 g_hash_table_destroy (method_slots);
1970 static MonoReflectionEvent *
1971 ves_icall_MonoType_GetEvent (MonoReflectionType *type, MonoString *name, guint32 bflags)
1980 MONO_ARCH_SAVE_REGS;
1982 event_name = mono_string_to_utf8 (name);
1983 klass = mono_class_from_mono_type (type->type);
1984 domain = mono_object_domain (type);
1987 for (i = 0; i < klass->event.count; i++) {
1988 event = &klass->events [i];
1989 if (strcmp (event->name, event_name))
1992 method = event->add;
1994 method = event->remove;
1996 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1997 if (!(bflags & BFLAGS_Public))
2000 if (!(bflags & BFLAGS_NonPublic))
2004 g_free (event_name);
2005 return mono_event_get_object (domain, klass, event);
2008 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
2011 g_free (event_name);
2016 ves_icall_Type_GetEvents (MonoReflectionType *type, guint32 bflags)
2019 GSList *l = NULL, *tmp;
2020 static MonoClass *System_Reflection_EventInfo;
2021 MonoClass *startklass, *klass;
2027 MONO_ARCH_SAVE_REGS;
2029 domain = ((MonoObject *)type)->vtable->domain;
2030 klass = startklass = mono_class_from_mono_type (type->type);
2033 for (i = 0; i < klass->event.count; ++i) {
2034 event = &klass->events [i];
2036 method = event->add;
2038 method = event->remove;
2039 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
2040 if (bflags & BFLAGS_Public)
2043 if (bflags & BFLAGS_NonPublic)
2049 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
2050 if (bflags & BFLAGS_Static)
2053 if (bflags & BFLAGS_Instance)
2060 l = g_slist_prepend (l, mono_event_get_object (domain, klass, event));
2062 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
2064 len = g_slist_length (l);
2065 if (!System_Reflection_EventInfo)
2066 System_Reflection_EventInfo = mono_class_from_name (
2067 mono_defaults.corlib, "System.Reflection", "EventInfo");
2068 res = mono_array_new (domain, System_Reflection_EventInfo, len);
2070 #ifdef FIXED_MCS_45127
2071 tmp = g_slist_reverse (l);
2075 for (; tmp; tmp = tmp->next, ++i)
2076 mono_array_set (res, gpointer, i, tmp->data);
2081 static MonoReflectionType *
2082 ves_icall_Type_GetNestedType (MonoReflectionType *type, MonoString *name, guint32 bflags)
2085 MonoClass *startklass, *klass;
2090 MONO_ARCH_SAVE_REGS;
2092 domain = ((MonoObject *)type)->vtable->domain;
2093 klass = startklass = mono_class_from_mono_type (type->type);
2094 str = mono_string_to_utf8 (name);
2097 for (tmpn = klass->nested_classes; tmpn; tmpn = tmpn->next) {
2099 nested = tmpn->data;
2100 if ((nested->flags & TYPE_ATTRIBUTE_VISIBILITY_MASK) == TYPE_ATTRIBUTE_NESTED_PUBLIC) {
2101 if (bflags & BFLAGS_Public)
2104 if (bflags & BFLAGS_NonPublic)
2109 if (strcmp (nested->name, str) == 0){
2111 return mono_type_get_object (domain, &nested->byval_arg);
2114 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
2121 ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags)
2124 GSList *l = NULL, *tmp;
2126 MonoClass *startklass, *klass;
2132 MONO_ARCH_SAVE_REGS;
2134 domain = ((MonoObject *)type)->vtable->domain;
2135 klass = startklass = mono_class_from_mono_type (type->type);
2137 for (tmpn = klass->nested_classes; tmpn; tmpn = tmpn->next) {
2139 nested = tmpn->data;
2140 if ((nested->flags & TYPE_ATTRIBUTE_VISIBILITY_MASK) == TYPE_ATTRIBUTE_NESTED_PUBLIC) {
2141 if (bflags & BFLAGS_Public)
2144 if (bflags & BFLAGS_NonPublic)
2149 member = (MonoObject*)mono_type_get_object (domain, &nested->byval_arg);
2150 l = g_slist_prepend (l, member);
2152 len = g_slist_length (l);
2153 res = mono_array_new (domain, mono_defaults.monotype_class, len);
2155 tmp = g_slist_reverse (l);
2156 for (; tmp; tmp = tmp->next, ++i)
2157 mono_array_set (res, gpointer, i, tmp->data);
2162 static MonoReflectionType*
2163 ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly *assembly, MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase)
2167 MonoTypeNameParse info;
2169 MONO_ARCH_SAVE_REGS;
2171 str = mono_string_to_utf8 (name);
2172 /*g_print ("requested type %s in %s\n", str, assembly->assembly->aname.name);*/
2173 if (!mono_reflection_parse_type (str, &info)) {
2175 g_list_free (info.modifiers);
2176 g_list_free (info.nested);
2177 if (throwOnError) /* uhm: this is a parse error, though... */
2178 mono_raise_exception (mono_get_exception_type_load ());
2179 /*g_print ("failed parse\n");*/
2183 type = mono_reflection_get_type (assembly->assembly->image, &info, ignoreCase);
2185 g_list_free (info.modifiers);
2186 g_list_free (info.nested);
2189 mono_raise_exception (mono_get_exception_type_load ());
2190 /* g_print ("failed find\n"); */
2193 /* g_print ("got it\n"); */
2194 return mono_type_get_object (mono_object_domain (assembly), type);
2199 ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly *assembly)
2201 MonoDomain *domain = mono_object_domain (assembly);
2202 MonoAssembly *mass = assembly->assembly;
2207 MONO_ARCH_SAVE_REGS;
2209 absolute = g_build_filename (mass->basedir, mass->image->module_name, NULL);
2210 uri = g_filename_to_uri (absolute, NULL, NULL);
2211 res = mono_string_new (domain, uri);
2218 ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssembly *assembly)
2220 MonoDomain *domain = mono_object_domain (assembly);
2222 char *name = g_build_filename (
2223 assembly->assembly->basedir,
2224 assembly->assembly->image->module_name, NULL);
2226 MONO_ARCH_SAVE_REGS;
2228 res = mono_string_new (domain, name);
2233 static MonoReflectionMethod*
2234 ves_icall_System_Reflection_Assembly_get_EntryPoint (MonoReflectionAssembly *assembly)
2236 guint32 token = mono_image_get_entry_point (assembly->assembly->image);
2238 MONO_ARCH_SAVE_REGS;
2242 return mono_method_get_object (mono_object_domain (assembly), mono_get_method (assembly->assembly->image, token, NULL), NULL);
2246 ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAssembly *assembly)
2248 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
2249 MonoArray *result = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, table->rows);
2253 MONO_ARCH_SAVE_REGS;
2255 for (i = 0; i < table->rows; ++i) {
2256 val = mono_metadata_string_heap (assembly->assembly->image, mono_metadata_decode_row_col (table, i, MONO_MANIFEST_NAME));
2257 mono_array_set (result, gpointer, i, mono_string_new (mono_object_domain (assembly), val));
2263 ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAssembly *assembly)
2265 static MonoClass *System_Reflection_AssemblyName;
2268 MonoDomain *domain = mono_object_domain (assembly);
2271 MONO_ARCH_SAVE_REGS;
2273 if (!System_Reflection_AssemblyName)
2274 System_Reflection_AssemblyName = mono_class_from_name (
2275 mono_defaults.corlib, "System.Reflection", "AssemblyName");
2277 for (ptr = assembly->assembly->image->references; ptr && *ptr; ptr++)
2280 result = mono_array_new (mono_object_domain (assembly), System_Reflection_AssemblyName, count);
2282 for (i = 0; i < count; i++) {
2283 MonoAssembly *assem = assembly->assembly->image->references [i];
2284 MonoReflectionAssemblyName *aname;
2285 char *codebase, *absolute;
2287 aname = (MonoReflectionAssemblyName *) mono_object_new (
2288 domain, System_Reflection_AssemblyName);
2290 if (strcmp (assem->aname.name, "corlib") == 0)
2291 aname->name = mono_string_new (domain, "mscorlib");
2293 aname->name = mono_string_new (domain, assem->aname.name);
2294 aname->major = assem->aname.major;
2296 absolute = g_build_filename (assem->basedir, assem->image->module_name, NULL);
2297 codebase = g_filename_to_uri (absolute, NULL, NULL);
2298 aname->codebase = mono_string_new (domain, codebase);
2301 mono_array_set (result, gpointer, i, aname);
2312 foreach_namespace (const char* key, gconstpointer val, NameSpaceInfo *info)
2314 MonoString *name = mono_string_new (mono_object_domain (info->res), key);
2316 mono_array_set (info->res, gpointer, info->idx, name);
2321 ves_icall_System_Reflection_Assembly_GetNamespaces (MonoReflectionAssembly *assembly)
2323 MonoImage *img = assembly->assembly->image;
2328 MONO_ARCH_SAVE_REGS;
2330 n = g_hash_table_size (img->name_cache);
2331 res = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, n);
2334 g_hash_table_foreach (img->name_cache, (GHFunc)foreach_namespace, &info);
2338 /* move this in some file in mono/util/ */
2340 g_concat_dir_and_file (const char *dir, const char *file)
2342 g_return_val_if_fail (dir != NULL, NULL);
2343 g_return_val_if_fail (file != NULL, NULL);
2346 * If the directory name doesn't have a / on the end, we need
2347 * to add one so we get a proper path to the file
2349 if (dir [strlen(dir) - 1] != G_DIR_SEPARATOR)
2350 return g_strconcat (dir, G_DIR_SEPARATOR_S, file, NULL);
2352 return g_strconcat (dir, file, NULL);
2356 ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflectionAssembly *assembly, MonoString *name)
2358 char *n = mono_string_to_utf8 (name);
2359 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
2361 guint32 cols [MONO_MANIFEST_SIZE];
2365 MONO_ARCH_SAVE_REGS;
2367 for (i = 0; i < table->rows; ++i) {
2368 mono_metadata_decode_row (table, i, cols, MONO_MANIFEST_SIZE);
2369 val = mono_metadata_string_heap (assembly->assembly->image, cols [MONO_MANIFEST_NAME]);
2370 if (strcmp (val, n) == 0)
2374 if (i == table->rows)
2377 if (!cols [MONO_MANIFEST_IMPLEMENTATION]) {
2380 val = mono_image_get_resource (assembly->assembly->image, cols [MONO_MANIFEST_OFFSET], &size);
2383 data = mono_array_new (mono_object_domain (assembly), mono_defaults.byte_class, size);
2384 memcpy (mono_array_addr (data, char, 0), val, size);
2385 return (MonoObject*)data;
2387 switch (cols [MONO_MANIFEST_IMPLEMENTATION] & IMPLEMENTATION_MASK) {
2388 case IMPLEMENTATION_FILE:
2389 i = cols [MONO_MANIFEST_IMPLEMENTATION] >> IMPLEMENTATION_BITS;
2390 table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
2391 i = mono_metadata_decode_row_col (table, i - 1, MONO_FILE_NAME);
2392 val = mono_metadata_string_heap (assembly->assembly->image, i);
2393 n = g_concat_dir_and_file (assembly->assembly->basedir, val);
2394 result = (MonoObject*)mono_string_new (mono_object_domain (assembly), n);
2395 /* check hash if needed */
2399 case IMPLEMENTATION_ASSEMBLYREF:
2402 case IMPLEMENTATION_EXP_TYPE:
2403 g_assert_not_reached ();
2410 ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (MonoReflectionAssembly *assembly, MonoString *name, MonoManifestResourceInfo *info)
2412 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
2414 guint32 cols [MONO_MANIFEST_SIZE];
2415 guint32 file_cols [MONO_FILE_SIZE];
2419 MONO_ARCH_SAVE_REGS;
2421 n = mono_string_to_utf8 (name);
2422 for (i = 0; i < table->rows; ++i) {
2423 mono_metadata_decode_row (table, i, cols, MONO_MANIFEST_SIZE);
2424 val = mono_metadata_string_heap (assembly->assembly->image, cols [MONO_MANIFEST_NAME]);
2425 if (strcmp (val, n) == 0)
2429 if (i == table->rows)
2432 if (!cols [MONO_MANIFEST_IMPLEMENTATION]) {
2433 info->location = RESOURCE_LOCATION_EMBEDDED | RESOURCE_LOCATION_IN_MANIFEST;
2436 switch (cols [MONO_MANIFEST_IMPLEMENTATION] & IMPLEMENTATION_MASK) {
2437 case IMPLEMENTATION_FILE:
2438 i = cols [MONO_MANIFEST_IMPLEMENTATION] >> IMPLEMENTATION_BITS;
2439 table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
2440 mono_metadata_decode_row (table, i - 1, file_cols, MONO_FILE_SIZE);
2441 val = mono_metadata_string_heap (assembly->assembly->image, file_cols [MONO_FILE_NAME]);
2442 info->filename = mono_string_new (mono_object_domain (assembly), val);
2443 if (file_cols [MONO_FILE_FLAGS] && FILE_CONTAINS_NO_METADATA)
2446 info->location = RESOURCE_LOCATION_EMBEDDED;
2449 case IMPLEMENTATION_ASSEMBLYREF:
2450 i = cols [MONO_MANIFEST_IMPLEMENTATION] >> IMPLEMENTATION_BITS;
2451 info->assembly = mono_assembly_get_object (mono_domain_get (), assembly->assembly->image->references [i - 1]);
2453 // Obtain info recursively
2454 ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal (info->assembly, name, info);
2455 info->location |= RESOURCE_LOCATION_ANOTHER_ASSEMBLY;
2458 case IMPLEMENTATION_EXP_TYPE:
2459 g_assert_not_reached ();
2468 ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssembly *assembly, MonoString *name)
2470 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
2471 MonoArray *result = NULL;
2476 MONO_ARCH_SAVE_REGS;
2478 /* check hash if needed */
2480 n = mono_string_to_utf8 (name);
2481 for (i = 0; i < table->rows; ++i) {
2482 val = mono_metadata_string_heap (assembly->assembly->image, mono_metadata_decode_row_col (table, i, MONO_FILE_NAME));
2483 if (strcmp (val, n) == 0) {
2486 n = g_concat_dir_and_file (assembly->assembly->basedir, val);
2487 fn = mono_string_new (mono_object_domain (assembly), n);
2489 return (MonoObject*)fn;
2496 for (i = 0; i < table->rows; ++i) {
2497 result = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, table->rows);
2498 val = mono_metadata_string_heap (assembly->assembly->image, mono_metadata_decode_row_col (table, i, MONO_FILE_NAME));
2499 n = g_concat_dir_and_file (assembly->assembly->basedir, val);
2500 mono_array_set (result, gpointer, i, mono_string_new (mono_object_domain (assembly), n));
2503 return (MonoObject*)result;
2507 ves_icall_System_Reflection_Assembly_GetModulesInternal (MonoReflectionAssembly *assembly)
2509 MonoDomain *domain = mono_domain_get();
2512 int i, module_count = 0, file_count = 0;
2513 MonoImage **modules = assembly->assembly->image->modules;
2514 MonoTableInfo *table;
2517 while (modules[module_count])
2521 table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
2522 file_count = table->rows;
2524 g_assert( assembly->assembly->image != NULL);
2527 klass = mono_class_from_name ( mono_defaults.corlib, "System.Reflection", "Module");
2528 res = mono_array_new (domain, klass, module_count + file_count);
2530 mono_array_set (res, gpointer, 0, mono_module_get_object (domain, assembly->assembly->image));
2531 for ( i = 1; i < module_count; ++i )
2532 mono_array_set (res, gpointer, i, mono_module_get_object (domain, modules[i]));
2534 for (i = 0; i < table->rows; ++i)
2535 mono_array_set (res, gpointer, module_count + i, mono_module_file_get_object (domain, assembly->assembly->image, i));
2540 static MonoReflectionMethod*
2541 ves_icall_GetCurrentMethod (void)
2543 MonoMethod *m = mono_method_get_last_managed ();
2545 MONO_ARCH_SAVE_REGS;
2547 return mono_method_get_object (mono_domain_get (), m, NULL);
2550 static MonoReflectionAssembly*
2551 ves_icall_System_Reflection_Assembly_GetExecutingAssembly (void)
2553 MonoMethod *m = mono_method_get_last_managed ();
2555 MONO_ARCH_SAVE_REGS;
2557 return mono_assembly_get_object (mono_domain_get (), m->klass->image->assembly);
2562 get_caller (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
2564 MonoMethod **dest = data;
2566 /* skip unmanaged frames */
2581 static MonoReflectionAssembly*
2582 ves_icall_System_Reflection_Assembly_GetEntryAssembly (void)
2584 MonoDomain* domain = mono_domain_get ();
2586 MONO_ARCH_SAVE_REGS;
2588 if (!domain->entry_assembly)
2589 domain = mono_root_domain;
2591 return mono_assembly_get_object (domain, domain->entry_assembly);
2595 static MonoReflectionAssembly*
2596 ves_icall_System_Reflection_Assembly_GetCallingAssembly (void)
2598 MonoMethod *m = mono_method_get_last_managed ();
2599 MonoMethod *dest = m;
2601 MONO_ARCH_SAVE_REGS;
2603 mono_stack_walk (get_caller, &dest);
2606 return mono_assembly_get_object (mono_domain_get (), dest->klass->image->assembly);
2610 ves_icall_System_MonoType_getFullName (MonoReflectionType *object)
2612 MonoDomain *domain = mono_object_domain (object);
2616 MONO_ARCH_SAVE_REGS;
2618 name = mono_type_get_name (object->type);
2619 res = mono_string_new (domain, name);
2626 ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, MonoReflectionAssemblyName *aname)
2628 MonoAssemblyName *name = &assembly->assembly->aname;
2630 MONO_ARCH_SAVE_REGS;
2632 if (strcmp (name->name, "corlib") == 0)
2633 aname->name = mono_string_new (mono_object_domain (assembly), "mscorlib");
2635 aname->name = mono_string_new (mono_object_domain (assembly), name->name);
2637 aname->major = name->major;
2638 aname->minor = name->minor;
2639 aname->build = name->build;
2640 aname->revision = name->revision;
2644 ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly)
2646 MonoDomain *domain = mono_object_domain (assembly);
2649 MonoTableInfo *tdef = &assembly->assembly->image->tables [MONO_TABLE_TYPEDEF];
2651 guint32 attrs, visibility;
2653 MONO_ARCH_SAVE_REGS;
2655 /* we start the count from 1 because we skip the special type <Module> */
2658 for (i = 1; i < tdef->rows; ++i) {
2659 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
2660 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
2661 if (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)
2665 count = tdef->rows - 1;
2667 res = mono_array_new (domain, mono_defaults.monotype_class, count);
2669 for (i = 1; i < tdef->rows; ++i) {
2670 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
2671 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
2672 if (!exportedOnly || (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)) {
2673 klass = mono_class_get (assembly->assembly->image, (i + 1) | MONO_TOKEN_TYPE_DEF);
2674 mono_array_set (res, gpointer, count, mono_type_get_object (domain, &klass->byval_arg));
2682 static MonoReflectionType*
2683 ves_icall_System_Reflection_Module_GetGlobalType (MonoReflectionModule *module)
2685 MonoDomain *domain = mono_object_domain (module);
2688 MONO_ARCH_SAVE_REGS;
2690 g_assert (module->image);
2691 klass = mono_class_get (module->image, 1 | MONO_TOKEN_TYPE_DEF);
2692 return mono_type_get_object (domain, &klass->byval_arg);
2696 ves_icall_System_Reflection_Module_GetGuidInternal (MonoReflectionModule *module)
2698 MonoDomain *domain = mono_object_domain (module);
2700 MONO_ARCH_SAVE_REGS;
2702 g_assert (module->image);
2703 return mono_string_new (domain, module->image->guid);
2706 static MonoReflectionType*
2707 ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, MonoString *smodifiers)
2710 int isbyref = 0, rank;
2711 char *str = mono_string_to_utf8 (smodifiers);
2714 MONO_ARCH_SAVE_REGS;
2716 klass = mono_class_from_mono_type (tb->type.type);
2718 /* logic taken from mono_reflection_parse_type(): keep in sync */
2722 if (isbyref) { /* only one level allowed by the spec */
2729 return mono_type_get_object (mono_object_domain (tb), &klass->this_arg);
2732 klass = mono_ptr_class_get (&klass->byval_arg);
2733 mono_class_init (klass);
2744 else if (*p != '*') { /* '*' means unknown lower bound */
2755 klass = mono_array_class_get (&klass->byval_arg, rank);
2756 mono_class_init (klass);
2763 return mono_type_get_object (mono_object_domain (tb), &klass->byval_arg);
2767 ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, MonoObject *target,
2768 MonoReflectionMethod *info)
2770 MonoClass *delegate_class = mono_class_from_mono_type (type->type);
2771 MonoObject *delegate;
2774 MONO_ARCH_SAVE_REGS;
2776 mono_assert (delegate_class->parent == mono_defaults.multicastdelegate_class);
2778 delegate = mono_object_new (mono_object_domain (type), delegate_class);
2780 func = mono_compile_method (info->method);
2782 mono_delegate_ctor (delegate, target, func);
2788 * Magic number to convert a time which is relative to
2789 * Jan 1, 1970 into a value which is relative to Jan 1, 0001.
2791 #define EPOCH_ADJUST ((gint64)62135596800L)
2794 ves_icall_System_DateTime_GetNow (void)
2796 #ifdef PLATFORM_WIN32
2801 SystemTimeToFileTime (&st, &ft);
2802 return (gint64)504911232000000000L + ((((gint64)ft.dwHighDateTime)<<32) | ft.dwLowDateTime);
2804 /* FIXME: put this in io-layer and call it GetLocalTime */
2808 MONO_ARCH_SAVE_REGS;
2810 if (gettimeofday (&tv, NULL) == 0) {
2811 res = (((gint64)tv.tv_sec + EPOCH_ADJUST)* 1000000 + tv.tv_usec)*10;
2814 /* fixme: raise exception */
2820 * This is heavily based on zdump.c from glibc 2.2.
2822 * * data[0]: start of daylight saving time (in DateTime ticks).
2823 * * data[1]: end of daylight saving time (in DateTime ticks).
2824 * * data[2]: utcoffset (in TimeSpan ticks).
2825 * * data[3]: additional offset when daylight saving (in TimeSpan ticks).
2826 * * name[0]: name of this timezone when not daylight saving.
2827 * * name[1]: name of this timezone when daylight saving.
2829 * FIXME: This only works with "standard" Unix dates (years between 1900 and 2100) while
2830 * the class library allows years between 1 and 9999.
2832 * Returns true on success and zero on failure.
2835 ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names)
2837 #ifndef PLATFORM_WIN32
2838 MonoDomain *domain = mono_domain_get ();
2839 struct tm start, tt;
2843 int is_daylight = 0, day;
2846 MONO_ARCH_SAVE_REGS;
2848 MONO_CHECK_ARG_NULL (data);
2849 MONO_CHECK_ARG_NULL (names);
2851 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
2852 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
2855 * no info is better than crashing: we'll need our own tz data to make
2856 * this work properly, anyway. The range is reduced to 1970 .. 2037 because
2857 * that is what mktime is guaranteed to support (we get into an infinite loop
2860 if ((year < 1970) || (year > 2037)) {
2862 tt = *localtime (&t);
2863 strftime (tzone, sizeof (tzone), "%Z", &tt);
2864 mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tzone));
2865 mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tzone));
2869 memset (&start, 0, sizeof (start));
2872 start.tm_year = year-1900;
2874 t = mktime (&start);
2875 #if defined (HAVE_TIMEZONE)
2876 #define gmt_offset(x) (-1 * (((timezone / 60 / 60) - daylight) * 100))
2877 #elif defined (HAVE_TM_GMTOFF)
2878 #define gmt_offset(x) x.tm_gmtoff
2880 #error Neither HAVE_TIMEZONE nor HAVE_TM_GMTOFF defined. Rerun autoheader, autoconf, etc.
2883 gmtoff = gmt_offset (start);
2885 /* For each day of the year, calculate the tm_gmtoff. */
2886 for (day = 0; day < 365; day++) {
2889 tt = *localtime (&t);
2891 /* Daylight saving starts or ends here. */
2892 if (gmt_offset (tt) != gmtoff) {
2896 /* Try to find the exact hour when daylight saving starts/ends. */
2900 tt1 = *localtime (&t1);
2901 } while (gmt_offset (tt1) != gmtoff);
2903 /* Try to find the exact minute when daylight saving starts/ends. */
2906 tt1 = *localtime (&t1);
2907 } while (gmt_offset (tt1) == gmtoff);
2909 strftime (tzone, sizeof (tzone), "%Z", &tt);
2911 /* Write data, if we're already in daylight saving, we're done. */
2913 mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tzone));
2914 mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
2917 mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tzone));
2918 mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
2922 /* This is only set once when we enter daylight saving. */
2923 mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L);
2924 mono_array_set ((*data), gint64, 3, (gint64)(gmt_offset (tt) - gmtoff) * 10000000L);
2926 gmtoff = gmt_offset (tt);
2929 gmtoff = gmt_offset (tt);
2933 strftime (tzone, sizeof (tzone), "%Z", &tt);
2934 mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tzone));
2935 mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tzone));
2936 mono_array_set ((*data), gint64, 0, 0);
2937 mono_array_set ((*data), gint64, 1, 0);
2938 mono_array_set ((*data), gint64, 2, (gint64) gmtoff * 10000000L);
2939 mono_array_set ((*data), gint64, 3, 0);
2944 MonoDomain *domain = mono_domain_get ();
2945 TIME_ZONE_INFORMATION tz_info;
2949 GetTimeZoneInformation (&tz_info);
2951 MONO_CHECK_ARG_NULL (data);
2952 MONO_CHECK_ARG_NULL (names);
2954 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
2955 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
2957 for (i = 0; i < 32; ++i)
2958 if (!tz_info.DaylightName [i])
2960 mono_array_set ((*names), gpointer, 1, mono_string_new_utf16 (domain, tz_info.DaylightName, i));
2961 for (i = 0; i < 32; ++i)
2962 if (!tz_info.StandardName [i])
2964 mono_array_set ((*names), gpointer, 0, mono_string_new_utf16 (domain, tz_info.StandardName, i));
2966 SystemTimeToFileTime (&tz_info.StandardDate, &ft);
2967 mono_array_set ((*data), gint64, 1, ((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime);
2968 SystemTimeToFileTime (&tz_info.DaylightDate, &ft);
2969 mono_array_set ((*data), gint64, 0, ((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime);
2970 mono_array_set ((*data), gint64, 3, tz_info.Bias + tz_info.StandardBias);
2971 mono_array_set ((*data), gint64, 2, tz_info.Bias + tz_info.DaylightBias);
2978 ves_icall_System_Object_obj_address (MonoObject *this)
2980 MONO_ARCH_SAVE_REGS;
2988 ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array)
2995 MONO_ARCH_SAVE_REGS;
2997 klass = array->obj.vtable->klass;
2998 etype = klass->element_class->byval_arg.type;
2999 if (etype < MONO_TYPE_BOOLEAN || etype > MONO_TYPE_R8)
3002 if (array->bounds == NULL)
3003 length = array->max_length;
3006 for (i = 0; i < klass->rank; ++ i)
3007 length *= array->bounds [i].length;
3010 esize = mono_array_element_size (klass);
3011 return length * esize;
3015 ves_icall_System_Buffer_GetByteInternal (MonoArray *array, gint32 idx)
3017 MONO_ARCH_SAVE_REGS;
3019 return mono_array_get (array, gint8, idx);
3023 ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 value)
3025 MONO_ARCH_SAVE_REGS;
3027 mono_array_set (array, gint8, idx, value);
3031 ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count)
3033 char *src_buf, *dest_buf;
3035 MONO_ARCH_SAVE_REGS;
3037 src_buf = (gint8 *)src->vector + src_offset;
3038 dest_buf = (gint8 *)dest->vector + dest_offset;
3040 memcpy (dest_buf, src_buf, count);
3044 ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this)
3046 MonoDomain *domain = mono_object_domain (this);
3048 MonoRealProxy *rp = ((MonoRealProxy *)this);
3052 MONO_ARCH_SAVE_REGS;
3054 res = mono_object_new (domain, mono_defaults.transparent_proxy_class);
3056 ((MonoTransparentProxy *)res)->rp = rp;
3057 type = ((MonoReflectionType *)rp->class_to_proxy)->type;
3058 klass = mono_class_from_mono_type (type);
3060 if (klass->flags & TYPE_ATTRIBUTE_INTERFACE)
3061 ((MonoTransparentProxy *)res)->klass = mono_defaults.marshalbyrefobject_class;
3063 ((MonoTransparentProxy *)res)->klass = klass;
3065 res->vtable = mono_class_proxy_vtable (domain, klass);
3070 /* System.Environment */
3073 ves_icall_System_Environment_get_MachineName (void)
3075 #if defined (PLATFORM_WIN32)
3080 len = MAX_COMPUTERNAME_LENGTH + 1;
3081 buf = g_new (gunichar2, len);
3084 if (GetComputerName (buf, (PDWORD) &len))
3085 result = mono_string_new_utf16 (mono_domain_get (), buf, len);
3094 MONO_ARCH_SAVE_REGS;
3097 buf = g_new (gchar, len);
3100 if (gethostname (buf, len) == 0)
3101 result = mono_string_new (mono_domain_get (), buf);
3109 ves_icall_System_Environment_get_Platform (void)
3111 MONO_ARCH_SAVE_REGS;
3113 #if defined (PLATFORM_WIN32)
3123 ves_icall_System_Environment_get_NewLine (void)
3125 MONO_ARCH_SAVE_REGS;
3127 #if defined (PLATFORM_WIN32)
3128 return mono_string_new (mono_domain_get (), "\r\n");
3130 return mono_string_new (mono_domain_get (), "\n");
3135 ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
3140 MONO_ARCH_SAVE_REGS;
3145 utf8_name = mono_string_to_utf8 (name); /* FIXME: this should be ascii */
3146 value = g_getenv (utf8_name);
3152 return mono_string_new (mono_domain_get (), value);
3156 * There is no standard way to get at environ.
3164 ves_icall_System_Environment_GetEnvironmentVariableNames (void)
3172 MONO_ARCH_SAVE_REGS;
3175 for (e = environ; *e != 0; ++ e)
3178 domain = mono_domain_get ();
3179 names = mono_array_new (domain, mono_defaults.string_class, n);
3182 for (e = environ; *e != 0; ++ e) {
3183 parts = g_strsplit (*e, "=", 2);
3185 str = mono_string_new (domain, *parts);
3186 mono_array_set (names, MonoString *, n, str);
3198 * Returns the number of milliseconds elapsed since the system started.
3201 ves_icall_System_Environment_get_TickCount (void)
3203 #if defined (PLATFORM_WIN32)
3204 return GetTickCount();
3210 MONO_ARCH_SAVE_REGS;
3212 res = (gint32) gettimeofday (&tv, &tz);
3215 res = (gint32) ((tv.tv_sec & 0xFFFFF) * 1000 + (tv.tv_usec / 1000));
3222 ves_icall_System_Environment_Exit (int result)
3224 MONO_ARCH_SAVE_REGS;
3226 mono_profiler_shutdown ();
3228 /* we may need to do some cleanup here... */
3233 ves_icall_System_Text_Encoding_InternalCodePage (void)
3237 MONO_ARCH_SAVE_REGS;
3239 g_get_charset (&cset);
3240 /* g_print ("charset: %s\n", cset); */
3241 /* handle some common aliases */
3244 if (strcmp (cset, "ANSI_X3.4-1968") == 0)
3248 return mono_string_new (mono_domain_get (), cset);
3252 ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this,
3253 MonoReflectionMethod *method,
3254 MonoArray *out_args)
3256 MONO_ARCH_SAVE_REGS;
3258 mono_message_init (mono_object_domain (this), this, method, out_args);
3262 ves_icall_IsTransparentProxy (MonoObject *proxy)
3264 MONO_ARCH_SAVE_REGS;
3269 if (proxy->vtable->klass == mono_defaults.transparent_proxy_class)
3276 ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionType *type, MonoBoolean enable)
3281 MONO_ARCH_SAVE_REGS;
3283 klass = mono_class_from_mono_type (type->type);
3284 vtable = mono_class_vtable (mono_domain_get (), klass);
3286 if (enable) vtable->remote = 1;
3287 else vtable->remote = 0;
3291 ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance (MonoReflectionType *type)
3296 MONO_ARCH_SAVE_REGS;
3298 domain = mono_object_domain (type);
3299 klass = mono_class_from_mono_type (type->type);
3301 // Bypass remoting object creation check
3302 return mono_object_new_alloc_specific (mono_class_vtable (domain, klass));
3306 ves_icall_System_Runtime_Serialization_FormatterServices_GetUninitializedObject_Internal (MonoReflectionType *type)
3312 MONO_ARCH_SAVE_REGS;
3314 domain = mono_object_domain (type);
3315 klass = mono_class_from_mono_type (type->type);
3317 if (klass->rank >= 1) {
3318 g_assert (klass->rank == 1);
3319 obj = (MonoObject *) mono_array_new (domain, klass->element_class, 0);
3321 obj = mono_object_new (domain, klass);
3328 ves_icall_System_IO_get_temp_path (void)
3330 MONO_ARCH_SAVE_REGS;
3332 return mono_string_new (mono_domain_get (), g_get_tmp_dir ());
3336 ves_icall_RuntimeMethod_GetFunctionPointer (MonoMethod *method)
3338 MONO_ARCH_SAVE_REGS;
3340 return mono_compile_method (method);
3343 char const * mono_cfg_dir = "";
3346 mono_install_get_config_dir (void)
3348 #ifdef PLATFORM_WIN32
3352 mono_cfg_dir = getenv ("MONO_CFG_DIR");
3354 if (!mono_cfg_dir) {
3355 #ifndef PLATFORM_WIN32
3356 mono_cfg_dir = MONO_CFG_DIR;
3358 mono_cfg_dir = g_strdup (MONO_CFG_DIR);
3359 for (i = strlen (mono_cfg_dir) - 1; i >= 0; i--) {
3360 if (mono_cfg_dir [i] == '/')
3361 ((char*) mono_cfg_dir) [i] = '\\';
3369 ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
3371 static MonoString *mcpath;
3374 MONO_ARCH_SAVE_REGS;
3379 path = g_build_path (G_DIR_SEPARATOR_S, mono_cfg_dir, "mono", "machine.config", NULL);
3381 #if defined (PLATFORM_WIN32)
3382 /* Avoid mixing '/' and '\\' */
3385 for (i = strlen (path) - 1; i >= 0; i--)
3386 if (path [i] == '/')
3390 mcpath = mono_string_new (mono_domain_get (), path);
3397 ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString (MonoString *message)
3399 #if defined (PLATFORM_WIN32)
3400 static void (*output_debug) (gchar *);
3401 static gboolean tried_loading = FALSE;
3404 MONO_ARCH_SAVE_REGS;
3406 if (!tried_loading && output_debug == NULL) {
3409 tried_loading = TRUE;
3410 k32 = g_module_open ("kernel32", G_MODULE_BIND_LAZY);
3412 gchar *error = g_strdup (g_module_error ());
3413 g_warning ("Failed to load kernel32.dll: %s\n", error);
3418 g_module_symbol (k32, "OutputDebugStringW", (gpointer *) &output_debug);
3419 if (!output_debug) {
3420 gchar *error = g_strdup (g_module_error ());
3421 g_warning ("Failed to load OutputDebugStringW: %s\n", error);
3427 if (output_debug == NULL)
3430 str = mono_string_to_utf8 (message);
3434 g_warning ("WriteWindowsDebugString called and PLATFORM_WIN32 not defined!\n");
3438 /* Only used for value types */
3440 ves_icall_System_Activator_CreateInstanceInternal (MonoReflectionType *type)
3445 MONO_ARCH_SAVE_REGS;
3447 domain = mono_object_domain (type);
3448 klass = mono_class_from_mono_type (type->type);
3450 return mono_object_new (domain, klass);
3453 static MonoReflectionMethod *
3454 ves_icall_MonoMethod_get_base_definition (MonoReflectionMethod *m)
3457 MonoMethod *method = m->method;
3458 MonoMethod *result = NULL;
3460 MONO_ARCH_SAVE_REGS;
3462 if (!(method->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
3463 method->klass->flags & TYPE_ATTRIBUTE_INTERFACE ||
3464 method->flags & METHOD_ATTRIBUTE_NEW_SLOT)
3467 if (method->klass == NULL || (klass = method->klass->parent) == NULL)
3470 if (klass->vtable_size > method->slot)
3471 result = klass->vtable [method->slot];
3476 return mono_method_get_object (mono_domain_get (), result, NULL);
3480 mono_ArgIterator_Setup (MonoArgIterator *iter, char* argsp, char* start)
3482 MONO_ARCH_SAVE_REGS;
3484 iter->sig = *(MonoMethodSignature**)argsp;
3486 g_assert (iter->sig->sentinelpos <= iter->sig->param_count);
3487 g_assert (iter->sig->call_convention == MONO_CALL_VARARG);
3490 /* FIXME: it's not documented what start is exactly... */
3491 iter->args = start? start: argsp + sizeof (gpointer);
3492 iter->num_args = iter->sig->param_count - iter->sig->sentinelpos;
3494 // g_print ("sig %p, param_count: %d, sent: %d\n", iter->sig, iter->sig->param_count, iter->sig->sentinelpos);
3498 mono_ArgIterator_IntGetNextArg (MonoArgIterator *iter)
3500 gint i, align, arg_size;
3502 MONO_ARCH_SAVE_REGS;
3504 i = iter->sig->sentinelpos + iter->next_arg;
3506 g_assert (i < iter->sig->param_count);
3508 res.type = iter->sig->params [i];
3509 /* FIXME: endianess issue... */
3510 res.value = iter->args;
3511 arg_size = mono_type_stack_size (res.type, &align);
3512 iter->args = (char*)iter->args + arg_size;
3515 //g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value);
3521 mono_ArgIterator_IntGetNextArgT (MonoArgIterator *iter, MonoType *type)
3523 gint i, align, arg_size;
3525 MONO_ARCH_SAVE_REGS;
3527 i = iter->sig->sentinelpos + iter->next_arg;
3529 g_assert (i < iter->sig->param_count);
3531 while (i < iter->sig->param_count) {
3532 if (!mono_metadata_type_equal (type, iter->sig->params [i]))
3534 res.type = iter->sig->params [i];
3535 /* FIXME: endianess issue... */
3536 res.value = iter->args;
3537 arg_size = mono_type_stack_size (res.type, &align);
3538 iter->args = (char*)iter->args + arg_size;
3540 //g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value);
3543 //g_print ("arg type 0x%02x not found\n", res.type->type);
3551 mono_ArgIterator_IntGetNextArgType (MonoArgIterator *iter)
3554 MONO_ARCH_SAVE_REGS;
3556 i = iter->sig->sentinelpos + iter->next_arg;
3558 g_assert (i < iter->sig->param_count);
3560 return iter->sig->params [i];
3564 mono_TypedReference_ToObject (MonoTypedRef tref)
3567 MONO_ARCH_SAVE_REGS;
3569 if (MONO_TYPE_IS_REFERENCE (tref.type)) {
3570 MonoObject** objp = tref.value;
3573 klass = mono_class_from_mono_type (tref.type);
3575 return mono_value_box (mono_domain_get (), klass, tref.value);
3579 prelink_method (MonoMethod *method)
3581 if (!(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
3583 mono_lookup_pinvoke_call (method);
3584 /* create the wrapper, too? */
3588 ves_icall_System_Runtime_InteropServices_Marshal_Prelink (MonoReflectionMethod *method)
3590 MONO_ARCH_SAVE_REGS;
3591 prelink_method (method->method);
3595 ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionType *type)
3597 MonoClass *klass = mono_class_from_mono_type (type->type);
3599 MONO_ARCH_SAVE_REGS;
3601 mono_class_init (klass);
3602 for (i = 0; i < klass->method.count; ++i)
3603 prelink_method (klass->methods [i]);
3608 static gconstpointer icall_map [] = {
3612 "System.Array::GetValue", ves_icall_System_Array_GetValue,
3613 "System.Array::SetValue", ves_icall_System_Array_SetValue,
3614 "System.Array::GetValueImpl", ves_icall_System_Array_GetValueImpl,
3615 "System.Array::SetValueImpl", ves_icall_System_Array_SetValueImpl,
3616 "System.Array::GetRank", ves_icall_System_Array_GetRank,
3617 "System.Array::GetLength", ves_icall_System_Array_GetLength,
3618 "System.Array::GetLowerBound", ves_icall_System_Array_GetLowerBound,
3619 "System.Array::CreateInstanceImpl", ves_icall_System_Array_CreateInstanceImpl,
3620 "System.Array::FastCopy", ves_icall_System_Array_FastCopy,
3621 "System.Array::Clone", mono_array_clone,
3624 * System.ArgIterator
3626 "System.ArgIterator::Setup", mono_ArgIterator_Setup,
3627 "System.ArgIterator::IntGetNextArg()", mono_ArgIterator_IntGetNextArg,
3628 "System.ArgIterator::IntGetNextArg(System.RuntimeTypeHandle)", mono_ArgIterator_IntGetNextArgT,
3629 "System.ArgIterator::IntGetNextArgType", mono_ArgIterator_IntGetNextArgType,
3632 * System.TypedReference
3634 "System.TypedReference::ToObject", mono_TypedReference_ToObject,
3639 "System.Object::MemberwiseClone", ves_icall_System_Object_MemberwiseClone,
3640 "System.Object::GetType", ves_icall_System_Object_GetType,
3641 "System.Object::InternalGetHashCode", ves_icall_System_Object_GetHashCode,
3642 "System.Object::obj_address", ves_icall_System_Object_obj_address,
3647 "System.ValueType::GetHashCode", ves_icall_System_ValueType_GetHashCode,
3648 "System.ValueType::InternalEquals", ves_icall_System_ValueType_Equals,
3654 "System.String::.ctor(char*)", ves_icall_System_String_ctor_charp,
3655 "System.String::.ctor(char*,int,int)", ves_icall_System_String_ctor_charp_int_int,
3656 "System.String::.ctor(sbyte*)", ves_icall_System_String_ctor_sbytep,
3657 "System.String::.ctor(sbyte*,int,int)", ves_icall_System_String_ctor_sbytep_int_int,
3658 "System.String::.ctor(sbyte*,int,int,System.Text.Encoding)", ves_icall_System_String_ctor_encoding,
3659 "System.String::.ctor(char[])", ves_icall_System_String_ctor_chara,
3660 "System.String::.ctor(char[],int,int)", ves_icall_System_String_ctor_chara_int_int,
3661 "System.String::.ctor(char,int)", ves_icall_System_String_ctor_char_int,
3662 "System.String::InternalEquals", ves_icall_System_String_InternalEquals,
3663 "System.String::InternalJoin", ves_icall_System_String_InternalJoin,
3664 "System.String::InternalInsert", ves_icall_System_String_InternalInsert,
3665 "System.String::InternalReplace(char,char)", ves_icall_System_String_InternalReplace_Char,
3666 "System.String::InternalReplace(string,string)", ves_icall_System_String_InternalReplace_Str,
3667 "System.String::InternalRemove", ves_icall_System_String_InternalRemove,
3668 "System.String::InternalCopyTo", ves_icall_System_String_InternalCopyTo,
3669 "System.String::InternalSplit", ves_icall_System_String_InternalSplit,
3670 "System.String::InternalTrim", ves_icall_System_String_InternalTrim,
3671 "System.String::InternalIndexOf(char,int,int)", ves_icall_System_String_InternalIndexOf_Char,
3672 "System.String::InternalIndexOf(string,int,int)", ves_icall_System_String_InternalIndexOf_Str,
3673 "System.String::InternalIndexOfAny", ves_icall_System_String_InternalIndexOfAny,
3674 "System.String::InternalLastIndexOf(char,int,int)", ves_icall_System_String_InternalLastIndexOf_Char,
3675 "System.String::InternalLastIndexOf(string,int,int)", ves_icall_System_String_InternalLastIndexOf_Str,
3676 "System.String::InternalLastIndexOfAny", ves_icall_System_String_InternalLastIndexOfAny,
3677 "System.String::InternalPad", ves_icall_System_String_InternalPad,
3678 "System.String::InternalToLower", ves_icall_System_String_InternalToLower,
3679 "System.String::InternalToUpper", ves_icall_System_String_InternalToUpper,
3680 "System.String::InternalAllocateStr", ves_icall_System_String_InternalAllocateStr,
3681 "System.String::InternalStrcpy(string,int,string)", ves_icall_System_String_InternalStrcpy_Str,
3682 "System.String::InternalStrcpy(string,int,string,int,int)", ves_icall_System_String_InternalStrcpy_StrN,
3683 "System.String::InternalIntern", ves_icall_System_String_InternalIntern,
3684 "System.String::InternalIsInterned", ves_icall_System_String_InternalIsInterned,
3685 "System.String::InternalCompare(string,int,string,int,int,int)", ves_icall_System_String_InternalCompareStr_N,
3686 "System.String::GetHashCode", ves_icall_System_String_GetHashCode,
3687 "System.String::get_Chars", ves_icall_System_String_get_Chars,
3692 "System.AppDomain::createDomain", ves_icall_System_AppDomain_createDomain,
3693 "System.AppDomain::getCurDomain", ves_icall_System_AppDomain_getCurDomain,
3694 "System.AppDomain::GetData", ves_icall_System_AppDomain_GetData,
3695 "System.AppDomain::SetData", ves_icall_System_AppDomain_SetData,
3696 "System.AppDomain::getSetup", ves_icall_System_AppDomain_getSetup,
3697 "System.AppDomain::getFriendlyName", ves_icall_System_AppDomain_getFriendlyName,
3698 "System.AppDomain::GetAssemblies", ves_icall_System_AppDomain_GetAssemblies,
3699 "System.AppDomain::LoadAssembly", ves_icall_System_AppDomain_LoadAssembly,
3700 "System.AppDomain::InternalUnload", ves_icall_System_AppDomain_InternalUnload,
3701 "System.AppDomain::ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly,
3702 "System.AppDomain::InternalSetDomain", ves_icall_System_AppDomain_InternalSetDomain,
3703 "System.AppDomain::InternalSetDomainByID", ves_icall_System_AppDomain_InternalSetDomainByID,
3704 "System.AppDomain::InternalSetContext", ves_icall_System_AppDomain_InternalSetContext,
3705 "System.AppDomain::InternalGetContext", ves_icall_System_AppDomain_InternalGetContext,
3706 "System.AppDomain::InternalGetDefaultContext", ves_icall_System_AppDomain_InternalGetDefaultContext,
3707 "System.AppDomain::InternalGetProcessGuid", ves_icall_System_AppDomain_InternalGetProcessGuid,
3710 * System.AppDomainSetup
3712 "System.AppDomainSetup::InitAppDomainSetup", ves_icall_System_AppDomainSetup_InitAppDomainSetup,
3717 "System.Double::ParseImpl", mono_double_ParseImpl,
3722 "System.Decimal::decimal2UInt64", mono_decimal2UInt64,
3723 "System.Decimal::decimal2Int64", mono_decimal2Int64,
3724 "System.Decimal::double2decimal", mono_double2decimal, /* FIXME: wrong signature. */
3725 "System.Decimal::decimalIncr", mono_decimalIncr,
3726 "System.Decimal::decimalSetExponent", mono_decimalSetExponent,
3727 "System.Decimal::decimal2double", mono_decimal2double,
3728 "System.Decimal::decimalFloorAndTrunc", mono_decimalFloorAndTrunc,
3729 "System.Decimal::decimalRound", mono_decimalRound,
3730 "System.Decimal::decimalMult", mono_decimalMult,
3731 "System.Decimal::decimalDiv", mono_decimalDiv,
3732 "System.Decimal::decimalIntDiv", mono_decimalIntDiv,
3733 "System.Decimal::decimalCompare", mono_decimalCompare,
3734 "System.Decimal::string2decimal", mono_string2decimal,
3735 "System.Decimal::decimal2string", mono_decimal2string,
3740 "System.Reflection.Emit.ModuleBuilder::create_modified_type", ves_icall_ModuleBuilder_create_modified_type,
3741 "System.Reflection.Emit.ModuleBuilder::basic_init", mono_image_module_basic_init,
3746 "System.Reflection.Emit.AssemblyBuilder::getDataChunk", ves_icall_AssemblyBuilder_getDataChunk,
3747 "System.Reflection.Emit.AssemblyBuilder::getUSIndex", mono_image_insert_string,
3748 "System.Reflection.Emit.AssemblyBuilder::getToken", ves_icall_AssemblyBuilder_getToken,
3749 "System.Reflection.Emit.AssemblyBuilder::basic_init", mono_image_basic_init,
3750 "System.Reflection.Emit.AssemblyBuilder::build_metadata", ves_icall_AssemblyBuilder_build_metadata,
3755 "System.Reflection.MonoMethodInfo::get_method_info", ves_icall_get_method_info,
3756 "System.Reflection.MonoMethodInfo::get_parameter_info", ves_icall_get_parameter_info,
3757 "System.Reflection.MonoFieldInfo::get_field_info", ves_icall_get_field_info,
3758 "System.Reflection.MonoPropertyInfo::get_property_info", ves_icall_get_property_info,
3759 "System.Reflection.MonoEventInfo::get_event_info", ves_icall_get_event_info,
3760 "System.Reflection.MonoMethod::InternalInvoke", ves_icall_InternalInvoke,
3761 "System.Reflection.MonoCMethod::InternalInvoke", ves_icall_InternalInvoke,
3762 "System.Reflection.MethodBase::GetCurrentMethod", ves_icall_GetCurrentMethod,
3763 "System.MonoCustomAttrs::GetCustomAttributes", mono_reflection_get_custom_attrs,
3764 "System.Reflection.Emit.CustomAttributeBuilder::GetBlob", mono_reflection_get_custom_attrs_blob,
3765 "System.Reflection.MonoField::GetValueInternal", ves_icall_MonoField_GetValueInternal,
3766 "System.Reflection.MonoField::SetValueInternal", ves_icall_FieldInfo_SetValueInternal,
3767 "System.Reflection.Emit.SignatureHelper::get_signature_local", mono_reflection_sighelper_get_signature_local,
3768 "System.Reflection.Emit.SignatureHelper::get_signature_field", mono_reflection_sighelper_get_signature_field,
3770 "System.RuntimeMethodHandle::GetFunctionPointer", ves_icall_RuntimeMethod_GetFunctionPointer,
3771 "System.Reflection.MonoMethod::get_base_definition", ves_icall_MonoMethod_get_base_definition,
3775 "System.MonoEnumInfo::get_enum_info", ves_icall_get_enum_info,
3776 "System.Enum::get_value", ves_icall_System_Enum_get_value,
3777 "System.Enum::ToObject", ves_icall_System_Enum_ToObject,
3782 "System.Reflection.Emit.TypeBuilder::setup_internal_class", mono_reflection_setup_internal_class,
3783 "System.Reflection.Emit.TypeBuilder::create_internal_class", mono_reflection_create_internal_class,
3784 "System.Reflection.Emit.TypeBuilder::create_runtime_class", mono_reflection_create_runtime_class,
3793 "System.Type::internal_from_name", ves_icall_type_from_name,
3794 "System.Type::internal_from_handle", ves_icall_type_from_handle,
3795 "System.MonoType::get_attributes", ves_icall_get_attributes,
3796 "System.Type::type_is_subtype_of", ves_icall_type_is_subtype_of,
3797 "System.Type::Equals", ves_icall_type_Equals,
3798 "System.Type::GetTypeCode", ves_icall_type_GetTypeCode,
3799 "System.Type::GetInterfaceMapData", ves_icall_Type_GetInterfaceMapData,
3802 * System.Reflection.FieldInfo
3804 "System.Reflection.FieldInfo::internal_from_handle", ves_icall_System_Reflection_FieldInfo_internal_from_handle,
3807 * System.Runtime.CompilerServices.RuntimeHelpers
3809 "System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray,
3810 "System.Runtime.CompilerServices.RuntimeHelpers::GetOffsetToStringData", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData,
3811 "System.Runtime.CompilerServices.RuntimeHelpers::GetObjectValue", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue,
3812 "System.Runtime.CompilerServices.RuntimeHelpers::RunClassConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor,
3817 "System.Threading.Thread::Abort_internal(object)", ves_icall_System_Threading_Thread_Abort,
3818 "System.Threading.Thread::ResetAbort_internal()", ves_icall_System_Threading_Thread_ResetAbort,
3819 "System.Threading.Thread::Thread_internal", ves_icall_System_Threading_Thread_Thread_internal,
3820 "System.Threading.Thread::Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal,
3821 "System.Threading.Thread::Start_internal", ves_icall_System_Threading_Thread_Start_internal,
3822 "System.Threading.Thread::Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal,
3823 "System.Threading.Thread::CurrentThread_internal", mono_thread_current,
3824 "System.Threading.Thread::Join_internal", ves_icall_System_Threading_Thread_Join_internal,
3825 "System.Threading.Thread::SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup,
3826 "System.Threading.Thread::SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store,
3827 "System.Threading.Thread::GetDomainID", ves_icall_System_Threading_Thread_GetDomainID,
3828 "System.Threading.Monitor::Monitor_exit", ves_icall_System_Threading_Monitor_Monitor_exit,
3829 "System.Threading.Monitor::Monitor_test_owner", ves_icall_System_Threading_Monitor_Monitor_test_owner,
3830 "System.Threading.Monitor::Monitor_test_synchronised", ves_icall_System_Threading_Monitor_Monitor_test_synchronised,
3831 "System.Threading.Monitor::Monitor_pulse", ves_icall_System_Threading_Monitor_Monitor_pulse,
3832 "System.Threading.Monitor::Monitor_pulse_all", ves_icall_System_Threading_Monitor_Monitor_pulse_all,
3833 "System.Threading.Monitor::Monitor_try_enter", ves_icall_System_Threading_Monitor_Monitor_try_enter,
3834 "System.Threading.Monitor::Monitor_wait", ves_icall_System_Threading_Monitor_Monitor_wait,
3835 "System.Threading.Mutex::CreateMutex_internal", ves_icall_System_Threading_Mutex_CreateMutex_internal,
3836 "System.Threading.Mutex::ReleaseMutex_internal", ves_icall_System_Threading_Mutex_ReleaseMutex_internal,
3837 "System.Threading.NativeEventCalls::CreateEvent_internal", ves_icall_System_Threading_Events_CreateEvent_internal,
3838 "System.Threading.NativeEventCalls::SetEvent_internal", ves_icall_System_Threading_Events_SetEvent_internal,
3839 "System.Threading.NativeEventCalls::ResetEvent_internal", ves_icall_System_Threading_Events_ResetEvent_internal,
3840 "System.Threading.NativeEventCalls::CloseEvent_internal", ves_icall_System_Threading_Events_CloseEvent_internal,
3843 * System.Threading.WaitHandle
3845 "System.Threading.WaitHandle::WaitAll_internal", ves_icall_System_Threading_WaitHandle_WaitAll_internal,
3846 "System.Threading.WaitHandle::WaitAny_internal", ves_icall_System_Threading_WaitHandle_WaitAny_internal,
3847 "System.Threading.WaitHandle::WaitOne_internal", ves_icall_System_Threading_WaitHandle_WaitOne_internal,
3850 * System.Runtime.InteropServices.Marshal
3852 "System.Runtime.InteropServices.Marshal::ReadIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr,
3853 "System.Runtime.InteropServices.Marshal::ReadByte", ves_icall_System_Runtime_InteropServices_Marshal_ReadByte,
3854 "System.Runtime.InteropServices.Marshal::ReadInt16", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt16,
3855 "System.Runtime.InteropServices.Marshal::ReadInt32", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt32,
3856 "System.Runtime.InteropServices.Marshal::ReadInt64", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt64,
3857 "System.Runtime.InteropServices.Marshal::WriteIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_WriteIntPtr,
3858 "System.Runtime.InteropServices.Marshal::WriteByte", ves_icall_System_Runtime_InteropServices_Marshal_WriteByte,
3859 "System.Runtime.InteropServices.Marshal::WriteInt16", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt16,
3860 "System.Runtime.InteropServices.Marshal::WriteInt32", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt32,
3861 "System.Runtime.InteropServices.Marshal::WriteInt64", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt64,
3863 "System.Runtime.InteropServices.Marshal::PtrToStringAnsi(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi,
3864 "System.Runtime.InteropServices.Marshal::PtrToStringAnsi(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len,
3865 "System.Runtime.InteropServices.Marshal::PtrToStringAuto(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi,
3866 "System.Runtime.InteropServices.Marshal::PtrToStringAuto(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len,
3867 "System.Runtime.InteropServices.Marshal::PtrToStringUni(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni,
3868 "System.Runtime.InteropServices.Marshal::PtrToStringUni(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni_len,
3869 "System.Runtime.InteropServices.Marshal::PtrToStringBSTR", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR,
3871 "System.Runtime.InteropServices.Marshal::GetLastWin32Error", ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error,
3872 "System.Runtime.InteropServices.Marshal::AllocHGlobal", mono_marshal_alloc,
3873 "System.Runtime.InteropServices.Marshal::FreeHGlobal", mono_marshal_free,
3874 "System.Runtime.InteropServices.Marshal::ReAllocHGlobal", mono_marshal_realloc,
3875 "System.Runtime.InteropServices.Marshal::copy_to_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_to_unmanaged,
3876 "System.Runtime.InteropServices.Marshal::copy_from_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_from_unmanaged,
3877 "System.Runtime.InteropServices.Marshal::SizeOf", ves_icall_System_Runtime_InteropServices_Marshal_SizeOf,
3878 "System.Runtime.InteropServices.Marshal::StructureToPtr", ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr,
3879 "System.Runtime.InteropServices.Marshal::PtrToStructure(intptr,object)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure,
3880 "System.Runtime.InteropServices.Marshal::PtrToStructure(intptr,System.Type)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type,
3881 "System.Runtime.InteropServices.Marshal::OffsetOf", ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf,
3882 "System.Runtime.InteropServices.Marshal::StringToHGlobalAnsi", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi,
3883 "System.Runtime.InteropServices.Marshal::StringToHGlobalAuto", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi,
3884 "System.Runtime.InteropServices.Marshal::StringToHGlobalUni", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni,
3885 "System.Runtime.InteropServices.Marshal::DestroyStructure", ves_icall_System_Runtime_InteropServices_Marshal_DestroyStructure,
3886 "System.Runtime.InteropServices.Marshal::Prelink", ves_icall_System_Runtime_InteropServices_Marshal_Prelink,
3887 "System.Runtime.InteropServices.Marshal::PrelinkAll", ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll,
3890 "System.Reflection.Assembly::LoadFrom", ves_icall_System_Reflection_Assembly_LoadFrom,
3891 "System.Reflection.Assembly::InternalGetType", ves_icall_System_Reflection_Assembly_InternalGetType,
3892 "System.Reflection.Assembly::GetTypes", ves_icall_System_Reflection_Assembly_GetTypes,
3893 "System.Reflection.Assembly::FillName", ves_icall_System_Reflection_Assembly_FillName,
3894 "System.Reflection.Assembly::get_code_base", ves_icall_System_Reflection_Assembly_get_code_base,
3895 "System.Reflection.Assembly::get_location", ves_icall_System_Reflection_Assembly_get_location,
3896 "System.Reflection.Assembly::GetExecutingAssembly", ves_icall_System_Reflection_Assembly_GetExecutingAssembly,
3897 "System.Reflection.Assembly::GetEntryAssembly", ves_icall_System_Reflection_Assembly_GetEntryAssembly,
3898 "System.Reflection.Assembly::GetCallingAssembly", ves_icall_System_Reflection_Assembly_GetCallingAssembly,
3899 "System.Reflection.Assembly::get_EntryPoint", ves_icall_System_Reflection_Assembly_get_EntryPoint,
3900 "System.Reflection.Assembly::GetManifestResourceNames", ves_icall_System_Reflection_Assembly_GetManifestResourceNames,
3901 "System.Reflection.Assembly::GetManifestResourceInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInternal,
3902 "System.Reflection.Assembly::GetManifestResourceInfoInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInfoInternal,
3903 "System.Reflection.Assembly::GetFilesInternal", ves_icall_System_Reflection_Assembly_GetFilesInternal,
3904 "System.Reflection.Assembly::GetReferencedAssemblies", ves_icall_System_Reflection_Assembly_GetReferencedAssemblies,
3905 "System.Reflection.Assembly::GetNamespaces", ves_icall_System_Reflection_Assembly_GetNamespaces,
3906 "System.Reflection.Assembly::GetModulesInternal", ves_icall_System_Reflection_Assembly_GetModulesInternal,
3909 * System.Reflection.Module
3911 "System.Reflection.Module::GetGlobalType", ves_icall_System_Reflection_Module_GetGlobalType,
3912 "System.Reflection.Module::GetGuidInternal", ves_icall_System_Reflection_Module_GetGuidInternal,
3917 "System.MonoType::getFullName", ves_icall_System_MonoType_getFullName,
3918 "System.MonoType::type_from_obj", mono_type_type_from_obj,
3919 "System.MonoType::GetElementType", ves_icall_MonoType_GetElementType,
3920 "System.MonoType::get_type_info", ves_icall_get_type_info,
3921 "System.MonoType::get_BaseType", ves_icall_get_type_parent,
3922 "System.MonoType::get_Module", ves_icall_MonoType_get_Module,
3923 "System.MonoType::IsPointerImpl", ves_icall_type_ispointer,
3924 "System.MonoType::IsByRefImpl", ves_icall_type_isbyref,
3925 "System.MonoType::GetField", ves_icall_Type_GetField,
3926 "System.MonoType::GetFields", ves_icall_Type_GetFields,
3927 "System.MonoType::GetMethods", ves_icall_Type_GetMethods,
3928 "System.MonoType::GetConstructors", ves_icall_Type_GetConstructors,
3929 "System.MonoType::GetProperties", ves_icall_Type_GetProperties,
3930 "System.MonoType::GetEvents", ves_icall_Type_GetEvents,
3931 "System.MonoType::InternalGetEvent", ves_icall_MonoType_GetEvent,
3932 "System.MonoType::GetInterfaces", ves_icall_Type_GetInterfaces,
3933 "System.MonoType::GetNestedTypes", ves_icall_Type_GetNestedTypes,
3934 "System.MonoType::GetNestedType", ves_icall_Type_GetNestedType,
3937 * System.Net.Sockets I/O Services
3939 "System.Net.Sockets.Socket::Socket_internal", ves_icall_System_Net_Sockets_Socket_Socket_internal,
3940 "System.Net.Sockets.Socket::Close_internal", ves_icall_System_Net_Sockets_Socket_Close_internal,
3941 "System.Net.Sockets.SocketException::WSAGetLastError_internal", ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal,
3942 "System.Net.Sockets.Socket::Available_internal", ves_icall_System_Net_Sockets_Socket_Available_internal,
3943 "System.Net.Sockets.Socket::Blocking_internal", ves_icall_System_Net_Sockets_Socket_Blocking_internal,
3944 "System.Net.Sockets.Socket::Accept_internal", ves_icall_System_Net_Sockets_Socket_Accept_internal,
3945 "System.Net.Sockets.Socket::Listen_internal", ves_icall_System_Net_Sockets_Socket_Listen_internal,
3946 "System.Net.Sockets.Socket::LocalEndPoint_internal", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal,
3947 "System.Net.Sockets.Socket::RemoteEndPoint_internal", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal,
3948 "System.Net.Sockets.Socket::Bind_internal", ves_icall_System_Net_Sockets_Socket_Bind_internal,
3949 "System.Net.Sockets.Socket::Connect_internal", ves_icall_System_Net_Sockets_Socket_Connect_internal,
3950 "System.Net.Sockets.Socket::Receive_internal", ves_icall_System_Net_Sockets_Socket_Receive_internal,
3951 "System.Net.Sockets.Socket::RecvFrom_internal", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal,
3952 "System.Net.Sockets.Socket::Send_internal", ves_icall_System_Net_Sockets_Socket_Send_internal,
3953 "System.Net.Sockets.Socket::SendTo_internal", ves_icall_System_Net_Sockets_Socket_SendTo_internal,
3954 "System.Net.Sockets.Socket::Select_internal", ves_icall_System_Net_Sockets_Socket_Select_internal,
3955 "System.Net.Sockets.Socket::Shutdown_internal", ves_icall_System_Net_Sockets_Socket_Shutdown_internal,
3956 "System.Net.Sockets.Socket::GetSocketOption_obj_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal,
3957 "System.Net.Sockets.Socket::GetSocketOption_arr_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal,
3958 "System.Net.Sockets.Socket::SetSocketOption_internal", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal,
3959 "System.Net.Dns::GetHostByName_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByName_internal,
3960 "System.Net.Dns::GetHostByAddr_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByAddr_internal,
3961 "System.Net.Dns::GetHostName_internal(string&)", ves_icall_System_Net_Dns_GetHostName_internal,
3966 "System.Char::GetNumericValue", ves_icall_System_Char_GetNumericValue,
3967 "System.Char::GetUnicodeCategory", ves_icall_System_Char_GetUnicodeCategory,
3968 "System.Char::IsControl", ves_icall_System_Char_IsControl,
3969 "System.Char::IsDigit", ves_icall_System_Char_IsDigit,
3970 "System.Char::IsLetter", ves_icall_System_Char_IsLetter,
3971 "System.Char::IsLower", ves_icall_System_Char_IsLower,
3972 "System.Char::IsUpper", ves_icall_System_Char_IsUpper,
3973 "System.Char::IsNumber", ves_icall_System_Char_IsNumber,
3974 "System.Char::IsPunctuation", ves_icall_System_Char_IsPunctuation,
3975 "System.Char::IsSeparator", ves_icall_System_Char_IsSeparator,
3976 "System.Char::IsSurrogate", ves_icall_System_Char_IsSurrogate,
3977 "System.Char::IsSymbol", ves_icall_System_Char_IsSymbol,
3978 "System.Char::IsWhiteSpace", ves_icall_System_Char_IsWhiteSpace,
3979 "System.Char::ToLower", ves_icall_System_Char_ToLower,
3980 "System.Char::ToUpper", ves_icall_System_Char_ToUpper,
3983 * System.Text.Encoding
3985 "System.Text.Encoding::InternalCodePage", ves_icall_System_Text_Encoding_InternalCodePage,
3987 "System.DateTime::GetNow", ves_icall_System_DateTime_GetNow,
3988 "System.CurrentTimeZone::GetTimeZoneData", ves_icall_System_CurrentTimeZone_GetTimeZoneData,
3993 "System.GC::InternalCollect", ves_icall_System_GC_InternalCollect,
3994 "System.GC::GetTotalMemory", ves_icall_System_GC_GetTotalMemory,
3995 "System.GC::KeepAlive", ves_icall_System_GC_KeepAlive,
3996 "System.GC::ReRegisterForFinalize", ves_icall_System_GC_ReRegisterForFinalize,
3997 "System.GC::SuppressFinalize", ves_icall_System_GC_SuppressFinalize,
3998 "System.GC::WaitForPendingFinalizers", ves_icall_System_GC_WaitForPendingFinalizers,
3999 "System.Runtime.InteropServices.GCHandle::GetTarget", ves_icall_System_GCHandle_GetTarget,
4000 "System.Runtime.InteropServices.GCHandle::GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle,
4001 "System.Runtime.InteropServices.GCHandle::FreeHandle", ves_icall_System_GCHandle_FreeHandle,
4002 "System.Runtime.InteropServices.GCHandle::GetAddrOfPinnedObject", ves_icall_System_GCHandle_GetAddrOfPinnedObject,
4005 * System.Security.Cryptography calls
4008 "System.Security.Cryptography.RNGCryptoServiceProvider::InternalGetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_InternalGetBytes,
4009 "System.Security.Cryptography.RNGCryptoServiceProvider::InternalGetNonZeroBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_InternalGetNonZeroBytes,
4014 "System.Buffer::ByteLengthInternal", ves_icall_System_Buffer_ByteLengthInternal,
4015 "System.Buffer::GetByteInternal", ves_icall_System_Buffer_GetByteInternal,
4016 "System.Buffer::SetByteInternal", ves_icall_System_Buffer_SetByteInternal,
4017 "System.Buffer::BlockCopyInternal", ves_icall_System_Buffer_BlockCopyInternal,
4022 "System.IO.MonoIO::CreateDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CreateDirectory,
4023 "System.IO.MonoIO::RemoveDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_RemoveDirectory,
4024 "System.IO.MonoIO::FindFirstFile(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindFirstFile,
4025 "System.IO.MonoIO::FindNextFile(intptr,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindNextFile,
4026 "System.IO.MonoIO::FindClose(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindClose,
4027 "System.IO.MonoIO::GetCurrentDirectory(System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetCurrentDirectory,
4028 "System.IO.MonoIO::SetCurrentDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetCurrentDirectory,
4029 "System.IO.MonoIO::MoveFile(string,string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_MoveFile,
4030 "System.IO.MonoIO::CopyFile(string,string,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CopyFile,
4031 "System.IO.MonoIO::DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile,
4032 "System.IO.MonoIO::GetFileAttributes(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileAttributes,
4033 "System.IO.MonoIO::SetFileAttributes(string,System.IO.FileAttributes,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileAttributes,
4034 "System.IO.MonoIO::GetFileType(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileType,
4035 "System.IO.MonoIO::GetFileStat(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileStat,
4036 "System.IO.MonoIO::Open(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Open,
4037 "System.IO.MonoIO::Close(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Close,
4038 "System.IO.MonoIO::Read(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Read,
4039 "System.IO.MonoIO::Write(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Write,
4040 "System.IO.MonoIO::Seek(intptr,long,System.IO.SeekOrigin,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Seek,
4041 "System.IO.MonoIO::GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength,
4042 "System.IO.MonoIO::SetLength(intptr,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetLength,
4043 "System.IO.MonoIO::SetFileTime(intptr,long,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileTime,
4044 "System.IO.MonoIO::Flush(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Flush,
4045 "System.IO.MonoIO::get_ConsoleOutput", ves_icall_System_IO_MonoIO_get_ConsoleOutput,
4046 "System.IO.MonoIO::get_ConsoleInput", ves_icall_System_IO_MonoIO_get_ConsoleInput,
4047 "System.IO.MonoIO::get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError,
4048 "System.IO.MonoIO::CreatePipe(intptr&,intptr&)", ves_icall_System_IO_MonoIO_CreatePipe,
4049 "System.IO.MonoIO::get_VolumeSeparatorChar", ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar,
4050 "System.IO.MonoIO::get_DirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar,
4051 "System.IO.MonoIO::get_AltDirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar,
4052 "System.IO.MonoIO::get_PathSeparator", ves_icall_System_IO_MonoIO_get_PathSeparator,
4053 "System.IO.MonoIO::get_InvalidPathChars", ves_icall_System_IO_MonoIO_get_InvalidPathChars,
4054 "System.IO.MonoIO::GetTempPath(string&)", ves_icall_System_IO_MonoIO_GetTempPath,
4059 "System.Math::Floor", ves_icall_System_Math_Floor,
4060 "System.Math::Round", ves_icall_System_Math_Round,
4061 "System.Math::Round2", ves_icall_System_Math_Round2,
4062 "System.Math::Sin", ves_icall_System_Math_Sin,
4063 "System.Math::Cos", ves_icall_System_Math_Cos,
4064 "System.Math::Tan", ves_icall_System_Math_Tan,
4065 "System.Math::Sinh", ves_icall_System_Math_Sinh,
4066 "System.Math::Cosh", ves_icall_System_Math_Cosh,
4067 "System.Math::Tanh", ves_icall_System_Math_Tanh,
4068 "System.Math::Acos", ves_icall_System_Math_Acos,
4069 "System.Math::Asin", ves_icall_System_Math_Asin,
4070 "System.Math::Atan", ves_icall_System_Math_Atan,
4071 "System.Math::Atan2", ves_icall_System_Math_Atan2,
4072 "System.Math::Exp", ves_icall_System_Math_Exp,
4073 "System.Math::Log", ves_icall_System_Math_Log,
4074 "System.Math::Log10", ves_icall_System_Math_Log10,
4075 "System.Math::Pow", ves_icall_System_Math_Pow,
4076 "System.Math::Sqrt", ves_icall_System_Math_Sqrt,
4079 * System.Environment
4081 "System.Environment::get_MachineName", ves_icall_System_Environment_get_MachineName,
4082 "System.Environment::get_NewLine", ves_icall_System_Environment_get_NewLine,
4083 "System.Environment::GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable,
4084 "System.Environment::GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames,
4085 "System.Environment::GetCommandLineArgs", mono_runtime_get_main_args,
4086 "System.Environment::get_TickCount", ves_icall_System_Environment_get_TickCount,
4087 "System.Environment::Exit", ves_icall_System_Environment_Exit,
4088 "System.Environment::get_Platform", ves_icall_System_Environment_get_Platform,
4089 "System.Environment::get_ExitCode", mono_environment_exitcode_get,
4090 "System.Environment::set_ExitCode", mono_environment_exitcode_set,
4093 * System.Runtime.Remoting
4095 "System.Runtime.Remoting.RemotingServices::InternalExecute",
4096 ves_icall_InternalExecute,
4097 "System.Runtime.Remoting.RemotingServices::IsTransparentProxy",
4098 ves_icall_IsTransparentProxy,
4101 * System.Runtime.Remoting.Activation
4103 "System.Runtime.Remoting.Activation.ActivationServices::AllocateUninitializedClassInstance",
4104 ves_icall_System_Runtime_Activation_ActivationServices_AllocateUninitializedClassInstance,
4105 "System.Runtime.Remoting.Activation.ActivationServices::EnableProxyActivation",
4106 ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation,
4109 * System.Runtime.Remoting.Messaging
4111 "System.Runtime.Remoting.Messaging.MonoMethodMessage::InitMessage",
4112 ves_icall_MonoMethodMessage_InitMessage,
4115 * System.Runtime.Remoting.Proxies
4117 "System.Runtime.Remoting.Proxies.RealProxy::InternalGetTransparentProxy",
4118 ves_icall_Remoting_RealProxy_GetTransparentProxy,
4121 * System.Threading.Interlocked
4123 "System.Threading.Interlocked::Increment(int&)", ves_icall_System_Threading_Interlocked_Increment_Int,
4124 "System.Threading.Interlocked::Increment(long&)", ves_icall_System_Threading_Interlocked_Increment_Long,
4125 "System.Threading.Interlocked::Decrement(int&)", ves_icall_System_Threading_Interlocked_Decrement_Int,
4126 "System.Threading.Interlocked::Decrement(long&)", ves_icall_System_Threading_Interlocked_Decrement_Long,
4127 "System.Threading.Interlocked::CompareExchange(int&,int,int)", ves_icall_System_Threading_Interlocked_CompareExchange_Int,
4128 "System.Threading.Interlocked::CompareExchange(object&,object,object)", ves_icall_System_Threading_Interlocked_CompareExchange_Object,
4129 "System.Threading.Interlocked::CompareExchange(single&,single,single)", ves_icall_System_Threading_Interlocked_CompareExchange_Single,
4130 "System.Threading.Interlocked::Exchange(int&,int)", ves_icall_System_Threading_Interlocked_Exchange_Int,
4131 "System.Threading.Interlocked::Exchange(object&,object)", ves_icall_System_Threading_Interlocked_Exchange_Object,
4132 "System.Threading.Interlocked::Exchange(single&,single)", ves_icall_System_Threading_Interlocked_Exchange_Single,
4135 * System.Diagnostics.Process
4137 "System.Diagnostics.Process::GetProcess_internal(int)", ves_icall_System_Diagnostics_Process_GetProcess_internal,
4138 "System.Diagnostics.Process::GetProcesses_internal()", ves_icall_System_Diagnostics_Process_GetProcesses_internal,
4139 "System.Diagnostics.Process::GetPid_internal()", ves_icall_System_Diagnostics_Process_GetPid_internal,
4140 "System.Diagnostics.Process::Process_free_internal(intptr)", ves_icall_System_Diagnostics_Process_Process_free_internal,
4141 "System.Diagnostics.Process::GetModules_internal()", ves_icall_System_Diagnostics_Process_GetModules_internal,
4142 "System.Diagnostics.Process::Start_internal(string,string,intptr,intptr,intptr,ProcInfo&)", ves_icall_System_Diagnostics_Process_Start_internal,
4143 "System.Diagnostics.Process::WaitForExit_internal(intptr,int)", ves_icall_System_Diagnostics_Process_WaitForExit_internal,
4144 "System.Diagnostics.Process::ExitTime_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitTime_internal,
4145 "System.Diagnostics.Process::StartTime_internal(intptr)", ves_icall_System_Diagnostics_Process_StartTime_internal,
4146 "System.Diagnostics.Process::ExitCode_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitCode_internal,
4147 "System.Diagnostics.Process::ProcessName_internal(intptr)", ves_icall_System_Diagnostics_Process_ProcessName_internal,
4148 "System.Diagnostics.Process::GetWorkingSet_internal(intptr,int&,int&)", ves_icall_System_Diagnostics_Process_GetWorkingSet_internal,
4149 "System.Diagnostics.Process::SetWorkingSet_internal(intptr,int,int,bool)", ves_icall_System_Diagnostics_Process_SetWorkingSet_internal,
4150 "System.Diagnostics.FileVersionInfo::GetVersionInfo_internal(string)", ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal,
4155 "System.Delegate::CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal,
4158 * System.Runtime.Serialization
4160 "System.Runtime.Serialization.FormatterServices::GetUninitializedObjectInternal",
4161 ves_icall_System_Runtime_Serialization_FormatterServices_GetUninitializedObject_Internal,
4166 "System.IO.Path::get_temp_path", ves_icall_System_IO_get_temp_path,
4169 * Private icalls for the Mono Debugger
4171 "System.Reflection.Assembly::MonoDebugger_GetMethod",
4172 ves_icall_MonoDebugger_GetMethod,
4174 "System.Reflection.Assembly::MonoDebugger_GetMethodToken",
4175 ves_icall_MonoDebugger_GetMethodToken,
4177 "System.Reflection.Assembly::MonoDebugger_GetLocalTypeFromSignature",
4178 ves_icall_MonoDebugger_GetLocalTypeFromSignature,
4180 "System.Reflection.Assembly::MonoDebugger_GetType",
4181 ves_icall_MonoDebugger_GetType,
4184 * System.Configuration
4186 "System.Configuration.DefaultConfig::get_machine_config_path",
4187 ves_icall_System_Configuration_DefaultConfig_get_machine_config_path,
4190 * System.Diagnostics.DefaultTraceListener
4192 "System.Diagnostics.DefaultTraceListener::WriteWindowsDebugString",
4193 ves_icall_System_Diagnostics_DefaultTraceListener_WriteWindowsDebugString,
4197 "System.Activator::CreateInstanceInternal",
4198 ves_icall_System_Activator_CreateInstanceInternal,
4200 * add other internal calls here
4206 mono_init_icall (void)
4211 while ((name = icall_map [i])) {
4212 mono_add_internal_call (name, icall_map [i+1]);