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/reflection.h>
25 #include <mono/metadata/assembly.h>
26 #include <mono/metadata/tabledefs.h>
27 #include <mono/metadata/exception.h>
28 #include <mono/metadata/file-io.h>
29 #include <mono/metadata/socket-io.h>
30 #include <mono/metadata/mono-endian.h>
31 #include <mono/metadata/tokentype.h>
32 #include <mono/metadata/unicode.h>
33 #include <mono/metadata/appdomain.h>
34 #include <mono/metadata/marshal.h>
35 #include <mono/metadata/gc.h>
36 #include <mono/metadata/rand.h>
37 #include <mono/metadata/sysmath.h>
38 #include <mono/metadata/string-icalls.h>
39 #include <mono/metadata/debug-mono-symfile.h>
40 #include <mono/metadata/process.h>
41 #include <mono/io-layer/io-layer.h>
42 #include <mono/utils/strtod.h>
44 #if defined (PLATFORM_WIN32)
50 mono_double_ToStringImpl (double value)
54 /* FIXME: Handle formats, etc. */
57 retVal = g_strdup_printf ("%.15g", value);
58 s = mono_string_new (mono_domain_get (), retVal);
64 * We expect a pointer to a char, not a string
67 mono_double_ParseImpl (char *ptr)
71 return bsd_strtod (ptr, NULL);
75 mono_float_ToStringImpl (float value)
79 return mono_double_ToStringImpl (value);
83 ves_icall_System_Array_GetValueImpl (MonoObject *this, guint32 pos)
92 ao = (MonoArray *)this;
93 ac = (MonoClass *)ao->obj.vtable->klass;
95 esize = mono_array_element_size (ac);
96 ea = (gpointer*)((char*)ao->vector + (pos * esize));
98 if (ac->element_class->valuetype)
99 return mono_value_box (this->vtable->domain, ac->element_class, ea);
105 ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs)
113 MONO_CHECK_ARG_NULL (idxs);
115 io = (MonoArray *)idxs;
116 ic = (MonoClass *)io->obj.vtable->klass;
118 ao = (MonoArray *)this;
119 ac = (MonoClass *)ao->obj.vtable->klass;
121 g_assert (ic->rank == 1);
122 if (io->bounds != NULL || io->max_length != ac->rank)
123 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
125 ind = (guint32 *)io->vector;
127 if (ao->bounds == NULL) {
128 if (*ind < 0 || *ind >= ao->max_length)
129 mono_raise_exception (mono_get_exception_index_out_of_range ());
131 return ves_icall_System_Array_GetValueImpl (this, *ind);
134 for (i = 0; i < ac->rank; i++)
135 if ((ind [i] < ao->bounds [i].lower_bound) ||
136 (ind [i] >= ao->bounds [i].length + ao->bounds [i].lower_bound))
137 mono_raise_exception (mono_get_exception_index_out_of_range ());
139 pos = ind [0] - ao->bounds [0].lower_bound;
140 for (i = 1; i < ac->rank; i++)
141 pos = pos*ao->bounds [i].length + ind [i] -
142 ao->bounds [i].lower_bound;
144 return ves_icall_System_Array_GetValueImpl (this, pos);
148 ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 pos)
152 MonoClass *ac, *vc, *ec;
161 vc = value->vtable->klass;
165 ac = this->obj.vtable->klass;
166 ec = ac->element_class;
168 esize = mono_array_element_size (ac);
169 ea = (gpointer*)((char*)this->vector + (pos * esize));
170 va = (gpointer*)((char*)value + sizeof (MonoObject));
173 memset (ea, 0, esize);
177 #define NO_WIDENING_CONVERSION G_STMT_START{\
178 mono_raise_exception (mono_get_exception_argument ( \
179 "value", "not a widening conversion")); \
182 #define CHECK_WIDENING_CONVERSION(extra) G_STMT_START{\
183 if (esize < vsize + (extra)) \
184 mono_raise_exception (mono_get_exception_argument ( \
185 "value", "not a widening conversion")); \
188 #define INVALID_CAST G_STMT_START{\
189 mono_raise_exception (mono_get_exception_invalid_cast ()); \
192 /* Check element (destination) type. */
193 switch (ec->byval_arg.type) {
194 case MONO_TYPE_STRING:
195 switch (vc->byval_arg.type) {
196 case MONO_TYPE_STRING:
202 case MONO_TYPE_BOOLEAN:
203 switch (vc->byval_arg.type) {
204 case MONO_TYPE_BOOLEAN:
217 NO_WIDENING_CONVERSION;
224 if (!ec->valuetype) {
225 *ea = (gpointer)value;
229 if (mono_object_isinst (value, ec)) {
230 memcpy (ea, (char *)value + sizeof (MonoObject), esize);
237 vsize = mono_class_instance_size (vc) - sizeof (MonoObject);
240 g_message (G_STRLOC ": %d (%d) <= %d (%d)",
241 ec->byval_arg.type, esize,
242 vc->byval_arg.type, vsize);
245 #define ASSIGN_UNSIGNED(etype) G_STMT_START{\
246 switch (vc->byval_arg.type) { \
251 case MONO_TYPE_CHAR: \
252 CHECK_WIDENING_CONVERSION(0); \
253 *(etype *) ea = (etype) u64; \
255 /* You can't assign a signed value to an unsigned array. */ \
260 /* You can't assign a floating point number to an integer array. */ \
263 NO_WIDENING_CONVERSION; \
267 #define ASSIGN_SIGNED(etype) G_STMT_START{\
268 switch (vc->byval_arg.type) { \
273 CHECK_WIDENING_CONVERSION(0); \
274 *(etype *) ea = (etype) i64; \
276 /* You can assign an unsigned value to a signed array if the array's */ \
277 /* element size is larger than the value size. */ \
282 case MONO_TYPE_CHAR: \
283 CHECK_WIDENING_CONVERSION(1); \
284 *(etype *) ea = (etype) u64; \
286 /* You can't assign a floating point number to an integer array. */ \
289 NO_WIDENING_CONVERSION; \
293 #define ASSIGN_REAL(etype) G_STMT_START{\
294 switch (vc->byval_arg.type) { \
297 CHECK_WIDENING_CONVERSION(0); \
298 *(etype *) ea = (etype) r64; \
300 /* All integer values fit into a floating point array, so we don't */ \
301 /* need to CHECK_WIDENING_CONVERSION here. */ \
306 *(etype *) ea = (etype) i64; \
312 case MONO_TYPE_CHAR: \
313 *(etype *) ea = (etype) u64; \
318 switch (vc->byval_arg.type) {
320 u64 = *(guint8 *) va;
323 u64 = *(guint16 *) va;
326 u64 = *(guint32 *) va;
329 u64 = *(guint64 *) va;
335 i64 = *(gint16 *) va;
338 i64 = *(gint32 *) va;
341 i64 = *(gint64 *) va;
344 r64 = *(gfloat *) va;
347 r64 = *(gdouble *) va;
350 u64 = *(guint16 *) va;
352 case MONO_TYPE_BOOLEAN:
353 /* Boolean is only compatible with itself. */
354 switch (ec->byval_arg.type) {
366 NO_WIDENING_CONVERSION;
373 /* If we can't do a direct copy, let's try a widening conversion. */
374 switch (ec->byval_arg.type) {
376 ASSIGN_UNSIGNED (guint16);
378 ASSIGN_UNSIGNED (guint8);
380 ASSIGN_UNSIGNED (guint16);
382 ASSIGN_UNSIGNED (guint32);
384 ASSIGN_UNSIGNED (guint64);
386 ASSIGN_SIGNED (gint8);
388 ASSIGN_SIGNED (gint16);
390 ASSIGN_SIGNED (gint32);
392 ASSIGN_SIGNED (gint64);
394 ASSIGN_REAL (gfloat);
396 ASSIGN_REAL (gdouble);
400 /* Not reached, INVALID_CAST does not return. Just to avoid a compiler warning ... */
404 #undef NO_WIDENING_CONVERSION
405 #undef CHECK_WIDENING_CONVERSION
406 #undef ASSIGN_UNSIGNED
412 ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value,
420 MONO_CHECK_ARG_NULL (idxs);
422 ic = idxs->obj.vtable->klass;
423 ac = this->obj.vtable->klass;
425 g_assert (ic->rank == 1);
426 if (idxs->bounds != NULL || idxs->max_length != ac->rank)
427 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
429 ind = (guint32 *)idxs->vector;
431 if (this->bounds == NULL) {
432 if (*ind < 0 || *ind >= this->max_length)
433 mono_raise_exception (mono_get_exception_index_out_of_range ());
435 ves_icall_System_Array_SetValueImpl (this, value, *ind);
439 for (i = 0; i < ac->rank; i++)
440 if ((ind [i] < this->bounds [i].lower_bound) ||
441 (ind [i] >= this->bounds [i].length + this->bounds [i].lower_bound))
442 mono_raise_exception (mono_get_exception_index_out_of_range ());
444 pos = ind [0] - this->bounds [0].lower_bound;
445 for (i = 1; i < ac->rank; i++)
446 pos = pos * this->bounds [i].length + ind [i] -
447 this->bounds [i].lower_bound;
449 ves_icall_System_Array_SetValueImpl (this, value, pos);
453 ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *lengths, MonoArray *bounds)
461 MONO_CHECK_ARG_NULL (type);
462 MONO_CHECK_ARG_NULL (lengths);
464 MONO_CHECK_ARG (lengths, mono_array_length (lengths) > 0);
466 MONO_CHECK_ARG (bounds, mono_array_length (lengths) == mono_array_length (bounds));
468 for (i = 0; i < mono_array_length (lengths); i++)
469 if (mono_array_get (lengths, gint32, i) < 0)
470 mono_raise_exception (mono_get_exception_argument_out_of_range (NULL));
472 aklass = mono_array_class_get (type->type, mono_array_length (lengths));
474 sizes = alloca (aklass->rank * sizeof(guint32) * 2);
475 for (i = 0; i < aklass->rank; ++i) {
476 sizes [i] = mono_array_get (lengths, gint32, i);
478 sizes [i + aklass->rank] = mono_array_get (bounds, gint32, i);
480 sizes [i + aklass->rank] = 0;
483 array = mono_array_new_full (mono_object_domain (type), aklass, sizes, sizes + aklass->rank);
489 ves_icall_System_Array_GetRank (MonoObject *this)
493 return this->vtable->klass->rank;
497 ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension)
501 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
502 if ((dimension < 0) || (dimension >= rank))
503 mono_raise_exception (mono_get_exception_index_out_of_range ());
505 if (this->bounds == NULL)
506 return this->max_length;
508 return this->bounds [dimension].length;
512 ves_icall_System_Array_GetLowerBound (MonoArray *this, gint32 dimension)
516 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
517 if ((dimension < 0) || (dimension >= rank))
518 mono_raise_exception (mono_get_exception_index_out_of_range ());
520 if (this->bounds == NULL)
523 return this->bounds [dimension].lower_bound;
527 ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* dest, int dest_idx, int length)
531 int element_size = mono_array_element_size (source->obj.vtable->klass);
532 void * dest_addr = mono_array_addr_with_size (dest, element_size, dest_idx);
533 void * source_addr = mono_array_addr_with_size (source, element_size, source_idx);
535 g_assert (dest_idx + length <= mono_array_length (dest));
536 g_assert (source_idx + length <= mono_array_length (source));
537 memmove (dest_addr, source_addr, element_size * length);
541 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoArray *array, MonoClassField *field_handle)
545 MonoClass *klass = array->obj.vtable->klass;
546 guint32 size = mono_array_element_size (klass);
549 if (array->bounds == NULL)
550 size *= array->max_length;
552 for (i = 0; i < klass->rank; ++i)
553 size *= array->bounds [i].length;
555 memcpy (mono_array_addr (array, char, 0), field_handle->data, size);
557 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
561 guint ## n *data = (guint ## n *) mono_array_addr (array, char, 0); \
563 for (i = 0; i < size; i += n/8, data++) { \
564 tmp = read ## n (data); \
569 /* printf ("Initialize array with elements of %s type\n", klass->element_class->name); */
571 switch (klass->element_class->byval_arg.type) {
591 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData (void)
595 return offsetof (MonoString, chars);
599 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue (MonoObject *obj)
603 if ((obj == NULL) || (! (obj->vtable->klass->valuetype)))
606 return mono_object_clone (obj);
610 ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (MonoType *handle)
616 MONO_CHECK_ARG_NULL (handle);
618 klass = mono_class_from_mono_type (handle);
619 MONO_CHECK_ARG (handle, klass);
621 /* This will call the type constructor */
622 mono_class_vtable (mono_domain_get (), klass);
626 ves_icall_System_Object_MemberwiseClone (MonoObject *this)
630 return mono_object_clone (this);
634 #define MONO_OBJECT_ALIGNMENT_SHIFT 3
636 #define MONO_OBJECT_ALIGNMENT_SHIFT 2
640 * Return hashcode based on object address. This function will need to be
641 * smarter in the presence of a moving garbage collector, which will cache
642 * the address hash before relocating the object.
644 * Wang's address-based hash function:
645 * http://www.concentric.net/~Ttwang/tech/addrhash.htm
648 ves_icall_System_Object_GetHashCode (MonoObject *this)
652 register guint32 key;
653 key = (GPOINTER_TO_UINT (this) >> MONO_OBJECT_ALIGNMENT_SHIFT) * 2654435761u;
655 return key & 0x7fffffff;
659 * A hash function for value types. I have no idea if this is a good hash
660 * function (its similar to g_str_hash).
663 ves_icall_System_ValueType_GetHashCode (MonoObject *this)
671 MONO_CHECK_ARG_NULL (this);
673 size = this->vtable->klass->instance_size - sizeof (MonoObject);
675 p = (const char *)this + sizeof (MonoObject);
677 for (i = 0; i < size; i++) {
678 h = (h << 5) - h + *p;
686 ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that)
693 MONO_CHECK_ARG_NULL (that);
695 if (this->vtable != that->vtable)
698 size = this->vtable->klass->instance_size - sizeof (MonoObject);
700 p = (const char *)this + sizeof (MonoObject);
701 s = (const char *)that + sizeof (MonoObject);
703 return memcmp (p, s, size)? FALSE: TRUE;
706 static MonoReflectionType *
707 ves_icall_System_Object_GetType (MonoObject *obj)
711 return mono_type_get_object (mono_object_domain (obj), &obj->vtable->klass->byval_arg);
715 mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
719 mtype->type = &obj->vtable->klass->byval_arg;
720 g_assert (mtype->type->type);
724 ves_icall_AssemblyBuilder_getToken (MonoReflectionAssemblyBuilder *assb, MonoObject *obj)
728 return mono_image_create_token (assb->dynamic_assembly, obj);
732 ves_icall_AssemblyBuilder_getDataChunk (MonoReflectionAssemblyBuilder *assb, MonoArray *buf, gint32 offset)
737 MonoDynamicAssembly *ass = assb->dynamic_assembly;
738 char *p = mono_array_addr (buf, char, 0);
740 mono_image_create_pefile (assb);
742 if (offset >= ass->pefile.index)
744 count = mono_array_length (buf);
745 count = MIN (count, ass->pefile.index - offset);
747 memcpy (p, ass->pefile.data + offset, count);
753 get_get_type_caller (MonoMethod *m, gint32 no, gint32 ilo, gpointer data) {
754 MonoImage **dest = data;
756 /* skip icalls and Type::GetType () */
757 if (!m || m->wrapper_type || (m->iflags & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL) ||
758 (strcmp (m->name, "GetType") == 0 && m->klass == mono_defaults.monotype_class->parent))
760 *dest = m->klass->image;
764 static MonoReflectionType*
765 ves_icall_type_from_name (MonoString *name)
769 MonoImage *image = NULL;
773 mono_stack_walk (get_get_type_caller, &image);
774 str = mono_string_to_utf8 (name);
775 /*g_print ("requested type %s\n", str);*/
776 type = mono_reflection_type_from_name (str, image);
780 /*g_print ("got it\n");*/
781 return mono_type_get_object (mono_object_domain (name), type);
784 static MonoReflectionType*
785 ves_icall_type_from_handle (MonoType *handle)
789 MonoDomain *domain = mono_domain_get ();
790 MonoClass *klass = mono_class_from_mono_type (handle);
792 mono_class_init (klass);
793 return mono_type_get_object (domain, handle);
797 ves_icall_type_Equals (MonoReflectionType *type, MonoReflectionType *c)
801 if (type->type && c->type)
802 return mono_metadata_type_equal (type->type, c->type);
803 g_print ("type equals\n");
807 /* System.TypeCode */
830 ves_icall_type_GetTypeCode (MonoReflectionType *type)
834 int t = type->type->type;
838 return TYPECODE_OBJECT;
839 case MONO_TYPE_BOOLEAN:
840 return TYPECODE_BOOLEAN;
842 return TYPECODE_BYTE;
844 return TYPECODE_SBYTE;
846 return TYPECODE_UINT16;
848 return TYPECODE_INT16;
850 return TYPECODE_CHAR;
854 return TYPECODE_OBJECT;
856 return TYPECODE_UINT32;
858 return TYPECODE_INT32;
860 return TYPECODE_UINT64;
862 return TYPECODE_INT64;
864 return TYPECODE_SINGLE;
866 return TYPECODE_DOUBLE;
867 case MONO_TYPE_VALUETYPE:
868 if (type->type->data.klass->enumtype) {
869 t = type->type->data.klass->enum_basetype->type;
872 MonoClass *k = type->type->data.klass;
873 if (strcmp (k->name_space, "System") == 0) {
874 if (strcmp (k->name, "Decimal") == 0)
875 return TYPECODE_DECIMAL;
876 else if (strcmp (k->name, "DateTime") == 0)
877 return TYPECODE_DATETIME;
878 else if (strcmp (k->name, "DBNull") == 0)
879 return TYPECODE_DBNULL;
882 /* handle datetime, dbnull.. */
883 return TYPECODE_OBJECT;
884 case MONO_TYPE_STRING:
885 return TYPECODE_STRING;
886 case MONO_TYPE_SZARRAY:
887 case MONO_TYPE_ARRAY:
888 case MONO_TYPE_OBJECT:
889 return TYPECODE_OBJECT;
890 case MONO_TYPE_CLASS:
891 return TYPECODE_OBJECT;
893 g_error ("type 0x%02x not handled in GetTypeCode()", t);
899 ves_icall_type_is_subtype_of (MonoReflectionType *type, MonoReflectionType *c, MonoBoolean check_interfaces)
907 g_assert (type != NULL);
909 domain = ((MonoObject *)type)->vtable->domain;
911 if (!c) /* FIXME: dont know what do do here */
914 klass = mono_class_from_mono_type (type->type);
915 klassc = mono_class_from_mono_type (c->type);
917 /* cut&paste from mono_object_isinst (): keep in sync */
918 if (check_interfaces && (klassc->flags & TYPE_ATTRIBUTE_INTERFACE) && !(klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
919 MonoVTable *klass_vt = mono_class_vtable (domain, klass);
920 if ((klassc->interface_id <= klass->max_interface_id) &&
921 klass_vt->interface_offsets [klassc->interface_id])
923 } else if (check_interfaces && (klassc->flags & TYPE_ATTRIBUTE_INTERFACE) && (klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
926 for (i = 0; i < klass->interface_count; i ++) {
927 MonoClass *ic = klass->interfaces [i];
933 * klass->baseval is 0 for interfaces
935 if (klass->baseval && ((klass->baseval - klassc->baseval) <= klassc->diffval))
942 ves_icall_get_attributes (MonoReflectionType *type)
946 MonoClass *klass = mono_class_from_mono_type (type->type);
952 ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info)
956 MonoDomain *domain = mono_domain_get ();
958 info->parent = mono_type_get_object (domain, &method->klass->byval_arg);
959 info->ret = mono_type_get_object (domain, method->signature->ret);
960 info->attrs = method->flags;
961 info->implattrs = method->iflags;
965 ves_icall_get_parameter_info (MonoMethod *method)
969 MonoDomain *domain = mono_domain_get ();
971 static MonoClass *System_Reflection_ParameterInfo;
972 MonoReflectionParameter** args;
975 args = mono_param_get_objects (domain, method);
976 if (!System_Reflection_ParameterInfo)
977 System_Reflection_ParameterInfo = mono_class_from_name (
978 mono_defaults.corlib, "System.Reflection", "ParameterInfo");
979 res = mono_array_new (domain, System_Reflection_ParameterInfo, method->signature->param_count);
980 for (i = 0; i < method->signature->param_count; ++i) {
981 mono_array_set (res, gpointer, i, args [i]);
987 ves_icall_get_field_info (MonoReflectionField *field, MonoFieldInfo *info)
991 MonoDomain *domain = mono_object_domain (field);
993 info->parent = mono_type_get_object (domain, &field->klass->byval_arg);
994 info->type = mono_type_get_object (domain, field->field->type);
995 info->name = mono_string_new (domain, field->field->name);
996 info->attrs = field->field->type->attrs;
1000 ves_icall_MonoField_GetValueInternal (MonoReflectionField *field, MonoObject *obj)
1002 MONO_ARCH_SAVE_REGS;
1005 MonoClassField *cf = field->field;
1008 MonoDomain *domain = mono_object_domain (field);
1010 gboolean is_static = FALSE;
1011 gboolean is_ref = FALSE;
1013 mono_class_init (field->klass);
1015 switch (cf->type->type) {
1016 case MONO_TYPE_STRING:
1017 case MONO_TYPE_OBJECT:
1018 case MONO_TYPE_CLASS:
1019 case MONO_TYPE_ARRAY:
1020 case MONO_TYPE_SZARRAY:
1025 case MONO_TYPE_BOOLEAN:
1028 case MONO_TYPE_CHAR:
1037 case MONO_TYPE_VALUETYPE:
1038 is_ref = cf->type->byref;
1041 g_error ("type 0x%x not handled in "
1042 "ves_icall_Monofield_GetValue", cf->type->type);
1046 if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1048 vtable = mono_class_vtable (domain, field->klass);
1053 mono_field_static_get_value (vtable, cf, &o);
1055 mono_field_get_value (obj, cf, &o);
1060 /* boxed value type */
1061 klass = mono_class_from_mono_type (cf->type);
1062 o = mono_object_new (domain, klass);
1063 v = ((gchar *) o) + sizeof (MonoObject);
1065 mono_field_static_get_value (vtable, cf, v);
1067 mono_field_get_value (obj, cf, v);
1074 ves_icall_FieldInfo_SetValueInternal (MonoReflectionField *field, MonoObject *obj, MonoObject *value)
1076 MONO_ARCH_SAVE_REGS;
1078 MonoClassField *cf = field->field;
1081 v = (gchar *) value;
1082 if (!cf->type->byref) {
1083 switch (cf->type->type) {
1086 case MONO_TYPE_BOOLEAN:
1089 case MONO_TYPE_CHAR:
1098 case MONO_TYPE_VALUETYPE:
1099 v += sizeof (MonoObject);
1101 case MONO_TYPE_STRING:
1102 case MONO_TYPE_OBJECT:
1103 case MONO_TYPE_CLASS:
1104 case MONO_TYPE_ARRAY:
1105 case MONO_TYPE_SZARRAY:
1109 g_error ("type 0x%x not handled in "
1110 "ves_icall_FieldInfo_SetValueInternal", cf->type->type);
1115 if (cf->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1116 MonoVTable *vtable = mono_class_vtable (mono_object_domain (field), field->klass);
1117 mono_field_static_set_value (vtable, cf, v);
1119 mono_field_set_value (obj, cf, v);
1124 ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info)
1126 MONO_ARCH_SAVE_REGS;
1128 MonoDomain *domain = mono_object_domain (property);
1130 info->parent = mono_type_get_object (domain, &property->klass->byval_arg);
1131 info->name = mono_string_new (domain, property->property->name);
1132 info->attrs = property->property->attrs;
1133 info->get = property->property->get ? mono_method_get_object (domain, property->property->get, NULL): NULL;
1134 info->set = property->property->set ? mono_method_get_object (domain, property->property->set, NULL): NULL;
1136 * There may be other methods defined for properties, though, it seems they are not exposed
1137 * in the reflection API
1142 ves_icall_get_event_info (MonoReflectionEvent *event, MonoEventInfo *info)
1144 MONO_ARCH_SAVE_REGS;
1146 MonoDomain *domain = mono_object_domain (event);
1148 info->parent = mono_type_get_object (domain, &event->klass->byval_arg);
1149 info->name = mono_string_new (domain, event->event->name);
1150 info->attrs = event->event->attrs;
1151 info->add_method = event->event->add ? mono_method_get_object (domain, event->event->add, NULL): NULL;
1152 info->remove_method = event->event->remove ? mono_method_get_object (domain, event->event->remove, NULL): NULL;
1153 info->raise_method = event->event->raise ? mono_method_get_object (domain, event->event->raise, NULL): NULL;
1157 ves_icall_Type_GetInterfaces (MonoReflectionType* type)
1159 MONO_ARCH_SAVE_REGS;
1161 MonoDomain *domain = mono_object_domain (type);
1164 MonoClass *class = mono_class_from_mono_type (type->type);
1168 for (parent = class; parent; parent = parent->parent) {
1169 ninterf += parent->interface_count;
1171 intf = mono_array_new (domain, mono_defaults.monotype_class, ninterf);
1173 for (parent = class; parent; parent = parent->parent) {
1174 for (i = 0; i < parent->interface_count; ++i) {
1175 mono_array_set (intf, gpointer, ninterf, mono_type_get_object (domain, &parent->interfaces [i]->byval_arg));
1182 static MonoReflectionType*
1183 ves_icall_MonoType_GetElementType (MonoReflectionType *type)
1185 MONO_ARCH_SAVE_REGS;
1187 MonoClass *class = mono_class_from_mono_type (type->type);
1188 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
1189 return mono_type_get_object (mono_object_domain (type), class->enum_basetype);
1190 else if (class->element_class)
1191 return mono_type_get_object (mono_object_domain (type), &class->element_class->byval_arg);
1196 static MonoReflectionType*
1197 ves_icall_get_type_parent (MonoReflectionType *type)
1199 MONO_ARCH_SAVE_REGS;
1201 MonoClass *class = mono_class_from_mono_type (type->type);
1202 return class->parent ? mono_type_get_object (mono_object_domain (type), &class->parent->byval_arg): NULL;
1206 ves_icall_type_ispointer (MonoReflectionType *type)
1208 MONO_ARCH_SAVE_REGS;
1210 return type->type->type == MONO_TYPE_PTR;
1214 ves_icall_type_isbyref (MonoReflectionType *type)
1216 MONO_ARCH_SAVE_REGS;
1218 return type->type->byref;
1221 static MonoReflectionModule*
1222 ves_icall_MonoType_get_Module (MonoReflectionType *type)
1224 MONO_ARCH_SAVE_REGS;
1226 MonoClass *class = mono_class_from_mono_type (type->type);
1227 return mono_module_get_object (mono_object_domain (type), class->image);
1231 ves_icall_get_type_info (MonoType *type, MonoTypeInfo *info)
1233 MONO_ARCH_SAVE_REGS;
1235 MonoDomain *domain = mono_domain_get ();
1236 MonoClass *class = mono_class_from_mono_type (type);
1238 info->nested_in = class->nested_in ? mono_type_get_object (domain, &class->nested_in->byval_arg): NULL;
1239 info->name = mono_string_new (domain, class->name);
1240 info->name_space = mono_string_new (domain, class->name_space);
1241 info->rank = class->rank;
1242 info->assembly = mono_assembly_get_object (domain, class->image->assembly);
1243 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
1244 info->etype = mono_type_get_object (domain, class->enum_basetype);
1245 else if (class->element_class)
1246 info->etype = mono_type_get_object (domain, &class->element_class->byval_arg);
1250 info->isprimitive = (type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8);
1254 ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params)
1256 MONO_ARCH_SAVE_REGS;
1259 * Invoke from reflection is supposed to always be a virtual call (the API
1260 * is stupid), mono_runtime_invoke_*() calls the provided method, allowing
1261 * greater flexibility.
1263 MonoMethod *m = method->method;
1265 m = mono_object_get_virtual_method (this, m);
1267 return mono_runtime_invoke_array (m, this, params, NULL);
1271 ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoArray *params, MonoArray **outArgs)
1273 MONO_ARCH_SAVE_REGS;
1275 MonoDomain *domain = mono_object_domain (method);
1276 MonoMethod *m = method->method;
1277 MonoMethodSignature *sig = m->signature;
1278 MonoArray *out_args;
1280 int i, j, outarg_count = 0;
1282 if (m->klass == mono_defaults.object_class) {
1284 if (!strcmp (m->name, "FieldGetter")) {
1285 MonoClass *k = this->vtable->klass;
1286 MonoString *name = mono_array_get (params, MonoString *, 1);
1289 str = mono_string_to_utf8 (name);
1291 for (i = 0; i < k->field.count; i++) {
1292 if (!strcmp (k->fields [i].name, str)) {
1293 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
1294 if (field_klass->valuetype)
1295 result = mono_value_box (domain, field_klass,
1296 (char *)this + k->fields [i].offset);
1298 result = *((gpointer *)((char *)this + k->fields [i].offset));
1301 out_args = mono_array_new (domain, mono_defaults.object_class, 1);
1302 *outArgs = out_args;
1303 mono_array_set (out_args, gpointer, 0, result);
1310 g_assert_not_reached ();
1312 } else if (!strcmp (m->name, "FieldSetter")) {
1313 MonoClass *k = this->vtable->klass;
1314 MonoString *name = mono_array_get (params, MonoString *, 1);
1318 str = mono_string_to_utf8 (name);
1320 for (i = 0; i < k->field.count; i++) {
1321 if (!strcmp (k->fields [i].name, str)) {
1322 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
1323 MonoObject *val = mono_array_get (params, gpointer, 2);
1325 if (field_klass->valuetype) {
1326 size = mono_type_size (k->fields [i].type, &align);
1327 memcpy ((char *)this + k->fields [i].offset,
1328 ((char *)val) + sizeof (MonoObject), size);
1330 *((gpointer *)this + k->fields [i].offset) = val;
1339 g_assert_not_reached ();
1344 for (i = 0; i < mono_array_length (params); i++) {
1345 if (sig->params [i]->byref)
1349 out_args = mono_array_new (domain, mono_defaults.object_class, outarg_count);
1351 for (i = 0, j = 0; i < mono_array_length (params); i++) {
1352 if (sig->params [i]->byref) {
1354 arg = mono_array_get (params, gpointer, i);
1355 mono_array_set (out_args, gpointer, j, arg);
1360 /* fixme: handle constructors? */
1361 if (!strcmp (method->method->name, ".ctor"))
1362 g_assert_not_reached ();
1364 result = mono_runtime_invoke_array (method->method, this, params, NULL);
1366 *outArgs = out_args;
1372 ves_icall_System_Enum_ToObject (MonoReflectionType *type, MonoObject *obj)
1374 MONO_ARCH_SAVE_REGS;
1377 MonoClass *enumc, *objc;
1381 MONO_CHECK_ARG_NULL (type);
1382 MONO_CHECK_ARG_NULL (obj);
1384 domain = mono_object_domain (type);
1385 enumc = mono_class_from_mono_type (type->type);
1386 objc = obj->vtable->klass;
1388 MONO_CHECK_ARG (obj, enumc->enumtype == TRUE);
1389 MONO_CHECK_ARG (obj, (objc->enumtype) || (objc->byval_arg.type >= MONO_TYPE_I1 &&
1390 objc->byval_arg.type <= MONO_TYPE_U8));
1392 s1 = mono_class_value_size (enumc, NULL);
1393 s2 = mono_class_value_size (objc, NULL);
1395 res = mono_object_new (domain, enumc);
1397 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1398 memcpy ((char *)res + sizeof (MonoObject), (char *)obj + sizeof (MonoObject), MIN (s1, s2));
1400 memcpy ((char *)res + sizeof (MonoObject) + (s1 > s2 ? s1 - s2 : 0),
1401 (char *)obj + sizeof (MonoObject) + (s2 > s1 ? s2 - s1 : 0),
1408 ves_icall_System_Enum_get_value (MonoObject *this)
1410 MONO_ARCH_SAVE_REGS;
1421 g_assert (this->vtable->klass->enumtype);
1423 enumc = mono_class_from_mono_type (this->vtable->klass->enum_basetype);
1424 res = mono_object_new (mono_object_domain (this), enumc);
1425 dst = (char *)res + sizeof (MonoObject);
1426 src = (char *)this + sizeof (MonoObject);
1427 size = mono_class_value_size (enumc, NULL);
1429 memcpy (dst, src, size);
1435 ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
1437 MONO_ARCH_SAVE_REGS;
1439 MonoDomain *domain = mono_object_domain (type);
1440 MonoClass *enumc = mono_class_from_mono_type (type->type);
1441 guint i, j, nvalues, crow;
1442 MonoClassField *field;
1444 info->utype = mono_type_get_object (domain, enumc->enum_basetype);
1445 nvalues = enumc->field.count - 1;
1446 info->names = mono_array_new (domain, mono_defaults.string_class, nvalues);
1447 info->values = mono_array_new (domain, enumc, nvalues);
1449 for (i = 0, j = 0; i < enumc->field.count; ++i) {
1450 field = &enumc->fields [i];
1451 if (strcmp ("value__", field->name) == 0)
1453 mono_array_set (info->names, gpointer, j, mono_string_new (domain, field->name));
1455 crow = mono_metadata_get_constant_index (enumc->image, MONO_TOKEN_FIELD_DEF | (i+enumc->field.first+1));
1456 crow = mono_metadata_decode_row_col (&enumc->image->tables [MONO_TABLE_CONSTANT], crow-1, MONO_CONSTANT_VALUE);
1457 /* 1 is the length of the blob */
1458 field->data = 1 + mono_metadata_blob_heap (enumc->image, crow);
1460 switch (enumc->enum_basetype->type) {
1463 mono_array_set (info->values, gchar, j, *field->data);
1465 case MONO_TYPE_CHAR:
1468 mono_array_set (info->values, gint16, j, read16 (field->data));
1472 mono_array_set (info->values, gint32, j, read32 (field->data));
1476 mono_array_set (info->values, gint64, j, read64 (field->data));
1479 g_error ("Implement type 0x%02x in get_enum_info", enumc->enum_basetype->type);
1486 BFLAGS_IgnoreCase = 1,
1487 BFLAGS_DeclaredOnly = 2,
1488 BFLAGS_Instance = 4,
1490 BFLAGS_Public = 0x10,
1491 BFLAGS_NonPublic = 0x20,
1492 BFLAGS_InvokeMethod = 0x100,
1493 BFLAGS_CreateInstance = 0x200,
1494 BFLAGS_GetField = 0x400,
1495 BFLAGS_SetField = 0x800,
1496 BFLAGS_GetProperty = 0x1000,
1497 BFLAGS_SetProperty = 0x2000,
1498 BFLAGS_ExactBinding = 0x10000,
1499 BFLAGS_SuppressChangeType = 0x20000,
1500 BFLAGS_OptionalParamBinding = 0x40000
1503 static MonoFieldInfo *
1504 ves_icall_Type_GetField (MonoReflectionType *type, MonoString *name, guint32 bflags)
1506 MONO_ARCH_SAVE_REGS;
1509 MonoClass *startklass, *klass;
1511 MonoClassField *field;
1513 domain = ((MonoObject *)type)->vtable->domain;
1514 klass = startklass = mono_class_from_mono_type (type->type);
1520 for (i = 0; i < klass->field.count; ++i) {
1522 field = &klass->fields [i];
1523 if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
1524 if (bflags & BFLAGS_Public)
1527 if (bflags & BFLAGS_NonPublic)
1533 if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1534 if (bflags & BFLAGS_Static)
1537 if (bflags & BFLAGS_Instance)
1544 utf8_name = mono_string_to_utf8 (name);
1546 if (strcmp (field->name, utf8_name)) {
1552 return (MonoFieldInfo *)mono_field_get_object (domain, klass, field);
1554 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1561 ves_icall_Type_GetFields (MonoReflectionType *type, guint32 bflags)
1563 MONO_ARCH_SAVE_REGS;
1566 GSList *l = NULL, *tmp;
1567 MonoClass *startklass, *klass;
1571 MonoClassField *field;
1573 domain = ((MonoObject *)type)->vtable->domain;
1574 klass = startklass = mono_class_from_mono_type (type->type);
1577 for (i = 0; i < klass->field.count; ++i) {
1579 field = &klass->fields [i];
1580 if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
1581 if (bflags & BFLAGS_Public)
1584 if (bflags & BFLAGS_NonPublic)
1590 if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1591 if (bflags & BFLAGS_Static)
1594 if (bflags & BFLAGS_Instance)
1600 member = (MonoObject*)mono_field_get_object (domain, klass, field);
1601 l = g_slist_prepend (l, member);
1603 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1605 len = g_slist_length (l);
1606 res = mono_array_new (domain, mono_defaults.field_info_class, len);
1608 tmp = g_slist_reverse (l);
1609 for (; tmp; tmp = tmp->next, ++i)
1610 mono_array_set (res, gpointer, i, tmp->data);
1616 ves_icall_Type_GetMethods (MonoReflectionType *type, guint32 bflags)
1618 MONO_ARCH_SAVE_REGS;
1621 GSList *l = NULL, *tmp;
1622 static MonoClass *System_Reflection_MethodInfo;
1623 MonoClass *startklass, *klass;
1628 GHashTable *method_slots = g_hash_table_new (NULL, NULL);
1630 domain = ((MonoObject *)type)->vtable->domain;
1631 klass = startklass = mono_class_from_mono_type (type->type);
1635 for (i = 0; i < klass->method.count; ++i) {
1637 method = klass->methods [i];
1638 if (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0)
1640 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1641 if (bflags & BFLAGS_Public)
1644 if (bflags & BFLAGS_NonPublic)
1650 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1651 if (bflags & BFLAGS_Static)
1654 if (bflags & BFLAGS_Instance)
1661 if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
1663 g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), method);
1664 member = (MonoObject*)mono_method_get_object (domain, method, startklass);
1666 l = g_slist_prepend (l, member);
1669 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1671 if (!System_Reflection_MethodInfo)
1672 System_Reflection_MethodInfo = mono_class_from_name (
1673 mono_defaults.corlib, "System.Reflection", "MethodInfo");
1674 res = mono_array_new (domain, System_Reflection_MethodInfo, len);
1677 for (; tmp; tmp = tmp->next, ++i)
1678 mono_array_set (res, gpointer, i, tmp->data);
1680 g_hash_table_destroy (method_slots);
1685 ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
1687 MONO_ARCH_SAVE_REGS;
1690 GSList *l = NULL, *tmp;
1691 static MonoClass *System_Reflection_ConstructorInfo;
1692 MonoClass *startklass, *klass;
1698 domain = ((MonoObject *)type)->vtable->domain;
1699 klass = startklass = mono_class_from_mono_type (type->type);
1701 for (i = 0; i < klass->method.count; ++i) {
1703 method = klass->methods [i];
1704 if (strcmp (method->name, ".ctor") && strcmp (method->name, ".cctor"))
1706 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1707 if (bflags & BFLAGS_Public)
1710 if (bflags & BFLAGS_NonPublic)
1716 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1717 if (bflags & BFLAGS_Static)
1720 if (bflags & BFLAGS_Instance)
1726 member = (MonoObject*)mono_method_get_object (domain, method, startklass);
1728 l = g_slist_prepend (l, member);
1730 len = g_slist_length (l);
1731 if (!System_Reflection_ConstructorInfo)
1732 System_Reflection_ConstructorInfo = mono_class_from_name (
1733 mono_defaults.corlib, "System.Reflection", "ConstructorInfo");
1734 res = mono_array_new (domain, System_Reflection_ConstructorInfo, len);
1736 tmp = g_slist_reverse (l);
1737 for (; tmp; tmp = tmp->next, ++i)
1738 mono_array_set (res, gpointer, i, tmp->data);
1744 ves_icall_Type_GetProperties (MonoReflectionType *type, guint32 bflags)
1746 MONO_ARCH_SAVE_REGS;
1749 GSList *l = NULL, *tmp;
1750 static MonoClass *System_Reflection_PropertyInfo;
1751 MonoClass *startklass, *klass;
1757 GHashTable *method_slots = g_hash_table_new (NULL, NULL);
1759 domain = ((MonoObject *)type)->vtable->domain;
1760 klass = startklass = mono_class_from_mono_type (type->type);
1763 for (i = 0; i < klass->property.count; ++i) {
1764 prop = &klass->properties [i];
1769 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1770 if (bflags & BFLAGS_Public)
1773 if (bflags & BFLAGS_NonPublic)
1779 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1780 if (bflags & BFLAGS_Static)
1783 if (bflags & BFLAGS_Instance)
1791 if (g_hash_table_lookup (method_slots, GUINT_TO_POINTER (method->slot)))
1793 g_hash_table_insert (method_slots, GUINT_TO_POINTER (method->slot), prop);
1795 l = g_slist_prepend (l, mono_property_get_object (domain, klass, prop));
1798 if ((!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)))
1800 if (!System_Reflection_PropertyInfo)
1801 System_Reflection_PropertyInfo = mono_class_from_name (
1802 mono_defaults.corlib, "System.Reflection", "PropertyInfo");
1803 res = mono_array_new (domain, System_Reflection_PropertyInfo, len);
1806 for (; tmp; tmp = tmp->next, ++i)
1807 mono_array_set (res, gpointer, i, tmp->data);
1809 g_hash_table_destroy (method_slots);
1813 static MonoReflectionEvent *
1814 ves_icall_MonoType_GetEvent (MonoReflectionType *type, MonoString *name, guint32 bflags)
1816 MONO_ARCH_SAVE_REGS;
1825 event_name = mono_string_to_utf8 (name);
1826 klass = mono_class_from_mono_type (type->type);
1827 domain = mono_object_domain (type);
1830 for (i = 0; i < klass->event.count; i++) {
1831 event = &klass->events [i];
1832 if (strcmp (event->name, event_name))
1835 method = event->add;
1837 method = event->remove;
1839 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1840 if (!(bflags & BFLAGS_Public))
1843 if (!(bflags & BFLAGS_NonPublic))
1847 g_free (event_name);
1848 return mono_event_get_object (domain, klass, event);
1851 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1854 g_free (event_name);
1859 ves_icall_Type_GetEvents (MonoReflectionType *type, guint32 bflags)
1861 MONO_ARCH_SAVE_REGS;
1864 GSList *l = NULL, *tmp;
1865 static MonoClass *System_Reflection_EventInfo;
1866 MonoClass *startklass, *klass;
1872 domain = ((MonoObject *)type)->vtable->domain;
1873 klass = startklass = mono_class_from_mono_type (type->type);
1876 for (i = 0; i < klass->event.count; ++i) {
1877 event = &klass->events [i];
1879 method = event->add;
1881 method = event->remove;
1882 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1883 if (bflags & BFLAGS_Public)
1886 if (bflags & BFLAGS_NonPublic)
1892 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1893 if (bflags & BFLAGS_Static)
1896 if (bflags & BFLAGS_Instance)
1903 l = g_slist_prepend (l, mono_event_get_object (domain, klass, event));
1905 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1907 len = g_slist_length (l);
1908 if (!System_Reflection_EventInfo)
1909 System_Reflection_EventInfo = mono_class_from_name (
1910 mono_defaults.corlib, "System.Reflection", "EventInfo");
1911 res = mono_array_new (domain, System_Reflection_EventInfo, len);
1914 for (; tmp; tmp = tmp->next, ++i)
1915 mono_array_set (res, gpointer, i, tmp->data);
1921 ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags)
1923 MONO_ARCH_SAVE_REGS;
1926 GSList *l = NULL, *tmp;
1928 MonoClass *startklass, *klass;
1934 domain = ((MonoObject *)type)->vtable->domain;
1935 klass = startklass = mono_class_from_mono_type (type->type);
1937 for (tmpn = klass->nested_classes; tmpn; tmpn = tmpn->next) {
1939 nested = tmpn->data;
1940 if ((nested->flags & TYPE_ATTRIBUTE_VISIBILITY_MASK) == TYPE_ATTRIBUTE_NESTED_PUBLIC) {
1941 if (bflags & BFLAGS_Public)
1944 if (bflags & BFLAGS_NonPublic)
1949 member = (MonoObject*)mono_type_get_object (domain, &nested->byval_arg);
1950 l = g_slist_prepend (l, member);
1952 len = g_slist_length (l);
1953 res = mono_array_new (domain, mono_defaults.monotype_class, len);
1955 tmp = g_slist_reverse (l);
1956 for (; tmp; tmp = tmp->next, ++i)
1957 mono_array_set (res, gpointer, i, tmp->data);
1962 static MonoReflectionType*
1963 ves_icall_System_Reflection_Assembly_InternalGetType (MonoReflectionAssembly *assembly, MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase)
1965 MONO_ARCH_SAVE_REGS;
1969 MonoTypeNameParse info;
1971 str = mono_string_to_utf8 (name);
1972 /*g_print ("requested type %s in %s\n", str, assembly->assembly->aname.name);*/
1973 if (!mono_reflection_parse_type (str, &info)) {
1975 g_list_free (info.modifiers);
1976 g_list_free (info.nested);
1977 if (throwOnError) /* uhm: this is a parse error, though... */
1978 mono_raise_exception (mono_get_exception_type_load ());
1979 /*g_print ("failed parse\n");*/
1983 type = mono_reflection_get_type (assembly->assembly->image, &info, ignoreCase);
1985 g_list_free (info.modifiers);
1986 g_list_free (info.nested);
1989 mono_raise_exception (mono_get_exception_type_load ());
1990 /* g_print ("failed find\n"); */
1993 /* g_print ("got it\n"); */
1994 return mono_type_get_object (mono_object_domain (assembly), type);
1999 ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly *assembly)
2001 MONO_ARCH_SAVE_REGS;
2003 MonoDomain *domain = mono_object_domain (assembly);
2005 char *name = g_strconcat (
2006 "file://", assembly->assembly->image->name, NULL);
2008 res = mono_string_new (domain, name);
2014 ves_icall_System_Reflection_Assembly_get_location (MonoReflectionAssembly *assembly)
2016 MONO_ARCH_SAVE_REGS;
2018 MonoDomain *domain = mono_object_domain (assembly);
2020 char *name = g_strconcat (
2021 assembly->assembly->basedir,
2022 assembly->assembly->image->module_name, NULL);
2024 res = mono_string_new (domain, name);
2029 static MonoReflectionMethod*
2030 ves_icall_System_Reflection_Assembly_get_EntryPoint (MonoReflectionAssembly *assembly)
2032 MONO_ARCH_SAVE_REGS;
2034 guint32 token = mono_image_get_entry_point (assembly->assembly->image);
2037 return mono_method_get_object (mono_object_domain (assembly), mono_get_method (assembly->assembly->image, token, NULL), NULL);
2041 ves_icall_System_Reflection_Assembly_GetManifestResourceNames (MonoReflectionAssembly *assembly)
2043 MONO_ARCH_SAVE_REGS;
2045 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
2046 MonoArray *result = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, table->rows);
2050 for (i = 0; i < table->rows; ++i) {
2051 val = mono_metadata_string_heap (assembly->assembly->image, mono_metadata_decode_row_col (table, i, MONO_MANIFEST_NAME));
2052 mono_array_set (result, gpointer, i, mono_string_new (mono_object_domain (assembly), val));
2058 ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAssembly *assembly)
2060 MONO_ARCH_SAVE_REGS;
2062 static MonoClass *System_Reflection_AssemblyName;
2067 if (!System_Reflection_AssemblyName)
2068 System_Reflection_AssemblyName = mono_class_from_name (
2069 mono_defaults.corlib, "System.Reflection", "AssemblyName");
2071 for (ptr = assembly->assembly->image->references; ptr && *ptr; ptr++)
2074 result = mono_array_new (mono_object_domain (assembly), System_Reflection_AssemblyName, count);
2076 for (i = 0; i < count; i++) {
2077 MonoAssembly *assem = assembly->assembly->image->references [i];
2078 MonoReflectionAssemblyName *aname;
2080 aname = (MonoReflectionAssemblyName *) mono_object_new (
2081 mono_object_domain (assembly), System_Reflection_AssemblyName);
2083 if (strcmp (assem->aname.name, "corlib") == 0)
2084 aname->name = mono_string_new (mono_object_domain (assembly), "mscorlib");
2086 aname->name = mono_string_new (mono_object_domain (assembly), assem->aname.name);
2087 aname->major = assem->aname.major;
2089 mono_array_set (result, gpointer, i, aname);
2094 /* move this in some file in mono/util/ */
2096 g_concat_dir_and_file (const char *dir, const char *file)
2098 g_return_val_if_fail (dir != NULL, NULL);
2099 g_return_val_if_fail (file != NULL, NULL);
2102 * If the directory name doesn't have a / on the end, we need
2103 * to add one so we get a proper path to the file
2105 if (dir [strlen(dir) - 1] != G_DIR_SEPARATOR)
2106 return g_strconcat (dir, G_DIR_SEPARATOR_S, file, NULL);
2108 return g_strconcat (dir, file, NULL);
2112 ves_icall_System_Reflection_Assembly_GetManifestResourceInternal (MonoReflectionAssembly *assembly, MonoString *name)
2114 MONO_ARCH_SAVE_REGS;
2116 char *n = mono_string_to_utf8 (name);
2117 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_MANIFESTRESOURCE];
2119 guint32 cols [MONO_MANIFEST_SIZE];
2123 for (i = 0; i < table->rows; ++i) {
2124 mono_metadata_decode_row (table, i, cols, MONO_MANIFEST_SIZE);
2125 val = mono_metadata_string_heap (assembly->assembly->image, cols [MONO_MANIFEST_NAME]);
2126 if (strcmp (val, n) == 0)
2130 if (i == table->rows)
2133 if (!cols [MONO_MANIFEST_IMPLEMENTATION]) {
2136 val = mono_image_get_resource (assembly->assembly->image, cols [MONO_MANIFEST_OFFSET], &size);
2139 data = mono_array_new (mono_object_domain (assembly), mono_defaults.byte_class, size);
2140 memcpy (mono_array_addr (data, char, 0), val, size);
2141 return (MonoObject*)data;
2143 switch (cols [MONO_MANIFEST_IMPLEMENTATION] & IMPLEMENTATION_MASK) {
2144 case IMPLEMENTATION_FILE:
2145 i = cols [MONO_MANIFEST_IMPLEMENTATION] >> IMPLEMENTATION_BITS;
2146 table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
2147 i = mono_metadata_decode_row_col (table, i - 1, MONO_FILE_NAME);
2148 val = mono_metadata_string_heap (assembly->assembly->image, i);
2149 n = g_concat_dir_and_file (assembly->assembly->basedir, val);
2150 result = (MonoObject*)mono_string_new (mono_object_domain (assembly), n);
2151 /* check hash if needed */
2154 case IMPLEMENTATION_ASSEMBLYREF:
2155 case IMPLEMENTATION_EXP_TYPE:
2163 ves_icall_System_Reflection_Assembly_GetFilesInternal (MonoReflectionAssembly *assembly, MonoString *name)
2165 MONO_ARCH_SAVE_REGS;
2167 MonoTableInfo *table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
2173 /* check hash if needed */
2175 n = mono_string_to_utf8 (name);
2176 for (i = 0; i < table->rows; ++i) {
2177 val = mono_metadata_string_heap (assembly->assembly->image, mono_metadata_decode_row_col (table, i, MONO_FILE_NAME));
2178 if (strcmp (val, n) == 0) {
2181 n = g_concat_dir_and_file (assembly->assembly->basedir, val);
2182 fn = mono_string_new (mono_object_domain (assembly), n);
2184 return (MonoObject*)fn;
2191 for (i = 0; i < table->rows; ++i) {
2192 result = mono_array_new (mono_object_domain (assembly), mono_defaults.string_class, table->rows);
2193 val = mono_metadata_string_heap (assembly->assembly->image, mono_metadata_decode_row_col (table, i, MONO_FILE_NAME));
2194 n = g_concat_dir_and_file (assembly->assembly->basedir, val);
2195 mono_array_set (result, gpointer, i, mono_string_new (mono_object_domain (assembly), n));
2198 return (MonoObject*)result;
2201 static MonoReflectionMethod*
2202 ves_icall_GetCurrentMethod (void)
2204 MONO_ARCH_SAVE_REGS;
2206 MonoMethod *m = mono_method_get_last_managed ();
2207 return mono_method_get_object (mono_domain_get (), m, NULL);
2210 static MonoReflectionAssembly*
2211 ves_icall_System_Reflection_Assembly_GetExecutingAssembly (void)
2213 MONO_ARCH_SAVE_REGS;
2215 MonoMethod *m = mono_method_get_last_managed ();
2216 return mono_assembly_get_object (mono_domain_get (), m->klass->image->assembly);
2221 get_caller (MonoMethod *m, gint32 no, gint32 ilo, gpointer data)
2223 MonoMethod **dest = data;
2235 static MonoReflectionAssembly*
2236 ves_icall_System_Reflection_Assembly_GetEntryAssembly (void)
2238 MONO_ARCH_SAVE_REGS;
2240 MonoDomain* domain = mono_domain_get ();
2241 g_assert (domain->entry_assembly);
2242 return mono_assembly_get_object (domain, domain->entry_assembly);
2246 static MonoReflectionAssembly*
2247 ves_icall_System_Reflection_Assembly_GetCallingAssembly (void)
2249 MONO_ARCH_SAVE_REGS;
2251 MonoMethod *m = mono_method_get_last_managed ();
2252 MonoMethod *dest = m;
2253 mono_stack_walk (get_caller, &dest);
2256 return mono_assembly_get_object (mono_domain_get (), dest->klass->image->assembly);
2260 ves_icall_System_MonoType_getFullName (MonoReflectionType *object)
2262 MONO_ARCH_SAVE_REGS;
2264 MonoDomain *domain = mono_object_domain (object);
2268 name = mono_type_get_name (object->type);
2269 res = mono_string_new (domain, name);
2276 ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, MonoReflectionAssemblyName *aname)
2278 MONO_ARCH_SAVE_REGS;
2280 MonoAssemblyName *name = &assembly->assembly->aname;
2282 if (strcmp (name->name, "corlib") == 0)
2283 aname->name = mono_string_new (mono_object_domain (assembly), "mscorlib");
2285 aname->name = mono_string_new (mono_object_domain (assembly), name->name);
2286 aname->major = name->major;
2290 ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly)
2292 MONO_ARCH_SAVE_REGS;
2294 MonoDomain *domain = mono_object_domain (assembly);
2297 MonoTableInfo *tdef = &assembly->assembly->image->tables [MONO_TABLE_TYPEDEF];
2299 guint32 attrs, visibility;
2301 /* we start the count from 1 because we skip the special type <Module> */
2304 for (i = 1; i < tdef->rows; ++i) {
2305 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
2306 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
2307 if (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)
2311 count = tdef->rows - 1;
2313 res = mono_array_new (domain, mono_defaults.monotype_class, count);
2315 for (i = 1; i < tdef->rows; ++i) {
2316 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
2317 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
2318 if (!exportedOnly || (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)) {
2319 klass = mono_class_get (assembly->assembly->image, (i + 1) | MONO_TOKEN_TYPE_DEF);
2320 mono_array_set (res, gpointer, count, mono_type_get_object (domain, &klass->byval_arg));
2328 static MonoReflectionType*
2329 ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, MonoString *smodifiers)
2331 MONO_ARCH_SAVE_REGS;
2334 int isbyref = 0, rank;
2335 char *str = mono_string_to_utf8 (smodifiers);
2338 klass = mono_class_from_mono_type (tb->type.type);
2340 /* logic taken from mono_reflection_parse_type(): keep in sync */
2344 if (isbyref) { /* only one level allowed by the spec */
2351 return mono_type_get_object (mono_object_domain (tb), &klass->this_arg);
2354 klass = mono_ptr_class_get (&klass->byval_arg);
2355 mono_class_init (klass);
2366 else if (*p != '*') { /* '*' means unknown lower bound */
2377 klass = mono_array_class_get (&klass->byval_arg, rank);
2378 mono_class_init (klass);
2385 return mono_type_get_object (mono_object_domain (tb), &klass->byval_arg);
2389 ves_icall_System_Delegate_CreateDelegate_internal (MonoReflectionType *type, MonoObject *target,
2390 MonoReflectionMethod *info)
2392 MONO_ARCH_SAVE_REGS;
2394 MonoClass *delegate_class = mono_class_from_mono_type (type->type);
2395 MonoObject *delegate;
2398 mono_assert (delegate_class->parent == mono_defaults.multicastdelegate_class);
2400 delegate = mono_object_new (mono_object_domain (type), delegate_class);
2402 func = mono_compile_method (info->method);
2404 mono_delegate_ctor (delegate, target, func);
2410 * Magic number to convert a time which is relative to
2411 * Jan 1, 1970 into a value which is relative to Jan 1, 0001.
2413 #define EPOCH_ADJUST ((gint64)62135596800L)
2416 ves_icall_System_DateTime_GetNow (void)
2418 MONO_ARCH_SAVE_REGS;
2420 #ifdef PLATFORM_WIN32
2425 SystemTimeToFileTime (&st, &ft);
2426 return (gint64)504911232000000000L + ((((gint64)ft.dwHighDateTime)<<32) | ft.dwLowDateTime);
2428 /* FIXME: put this in io-layer and call it GetLocalTime */
2432 if (gettimeofday (&tv, NULL) == 0) {
2433 res = (((gint64)tv.tv_sec + EPOCH_ADJUST)* 1000000 + tv.tv_usec)*10;
2436 /* fixme: raise exception */
2442 * This is heavily based on zdump.c from glibc 2.2.
2444 * * data[0]: start of daylight saving time (in DateTime ticks).
2445 * * data[1]: end of daylight saving time (in DateTime ticks).
2446 * * data[2]: utcoffset (in TimeSpan ticks).
2447 * * data[3]: additional offset when daylight saving (in TimeSpan ticks).
2448 * * name[0]: name of this timezone when not daylight saving.
2449 * * name[1]: name of this timezone when daylight saving.
2451 * FIXME: This only works with "standard" Unix dates (years between 1900 and 2100) while
2452 * the class library allows years between 1 and 9999.
2454 * Returns true on success and zero on failure.
2457 ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names)
2459 MONO_ARCH_SAVE_REGS;
2461 #ifndef PLATFORM_WIN32
2462 MonoDomain *domain = mono_domain_get ();
2463 struct tm start, tt;
2467 int is_daylight = 0, day;
2469 memset (&start, 0, sizeof (start));
2472 start.tm_year = year-1900;
2474 t = mktime (&start);
2475 #if defined (HAVE_TIMEZONE)
2476 #define gmt_offset(x) (-1 * (((timezone / 60 / 60) - daylight) * 100))
2477 #elif defined (HAVE_TM_GMTOFF)
2478 #define gmt_offset(x) x.tm_gmtoff
2480 #error Neither HAVE_TIMEZONE nor HAVE_TM_GMTOFF defined. Rerun autoheader, autoconf, etc.
2483 gmtoff = gmt_offset (start);
2485 MONO_CHECK_ARG_NULL (data);
2486 MONO_CHECK_ARG_NULL (names);
2488 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
2489 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
2491 /* For each day of the year, calculate the tm_gmtoff. */
2492 for (day = 0; day < 365; day++) {
2495 tt = *localtime (&t);
2497 /* Daylight saving starts or ends here. */
2498 if (gmt_offset (tt) != gmtoff) {
2503 /* Try to find the exact hour when daylight saving starts/ends. */
2507 tt1 = *localtime (&t1);
2508 } while (gmt_offset (tt1) != gmtoff);
2510 /* Try to find the exact minute when daylight saving starts/ends. */
2513 tt1 = *localtime (&t1);
2514 } while (gmt_offset (tt1) == gmtoff);
2516 strftime (tzone, 10, "%Z", &tt);
2518 /* Write data, if we're already in daylight saving, we're done. */
2520 mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tzone));
2521 mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
2524 mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tzone));
2525 mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
2529 /* This is only set once when we enter daylight saving. */
2530 mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L);
2531 mono_array_set ((*data), gint64, 3, (gint64)(gmt_offset (tt) - gmtoff) * 10000000L);
2533 gmtoff = gmt_offset (tt);
2536 gmtoff = gmt_offset (tt);
2540 MonoDomain *domain = mono_domain_get ();
2541 TIME_ZONE_INFORMATION tz_info;
2545 GetTimeZoneInformation (&tz_info);
2547 MONO_CHECK_ARG_NULL (data);
2548 MONO_CHECK_ARG_NULL (names);
2550 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
2551 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
2553 for (i = 0; i < 32; ++i)
2554 if (!tz_info.DaylightName [i])
2556 mono_array_set ((*names), gpointer, 1, mono_string_new_utf16 (domain, tz_info.DaylightName, i));
2557 for (i = 0; i < 32; ++i)
2558 if (!tz_info.StandardName [i])
2560 mono_array_set ((*names), gpointer, 0, mono_string_new_utf16 (domain, tz_info.StandardName, i));
2562 SystemTimeToFileTime (&tz_info.StandardDate, &ft);
2563 mono_array_set ((*data), gint64, 1, ((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime);
2564 SystemTimeToFileTime (&tz_info.DaylightDate, &ft);
2565 mono_array_set ((*data), gint64, 0, ((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime);
2566 mono_array_set ((*data), gint64, 3, tz_info.Bias + tz_info.StandardBias);
2567 mono_array_set ((*data), gint64, 2, tz_info.Bias + tz_info.DaylightBias);
2574 ves_icall_System_Object_obj_address (MonoObject *this)
2576 MONO_ARCH_SAVE_REGS;
2584 ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array)
2586 MONO_ARCH_SAVE_REGS;
2593 klass = array->obj.vtable->klass;
2594 etype = klass->element_class->byval_arg.type;
2595 if (etype < MONO_TYPE_BOOLEAN || etype > MONO_TYPE_R8)
2598 if (array->bounds == NULL)
2599 length = array->max_length;
2602 for (i = 0; i < klass->rank; ++ i)
2603 length += array->bounds [i].length;
2606 esize = mono_array_element_size (klass);
2607 return length * esize;
2611 ves_icall_System_Buffer_GetByteInternal (MonoArray *array, gint32 idx)
2613 MONO_ARCH_SAVE_REGS;
2615 return mono_array_get (array, gint8, idx);
2619 ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 value)
2621 MONO_ARCH_SAVE_REGS;
2623 mono_array_set (array, gint8, idx, value);
2627 ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count)
2629 MONO_ARCH_SAVE_REGS;
2631 char *src_buf, *dest_buf;
2633 src_buf = (gint8 *)src->vector + src_offset;
2634 dest_buf = (gint8 *)dest->vector + dest_offset;
2636 memcpy (dest_buf, src_buf, count);
2640 ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this)
2642 MONO_ARCH_SAVE_REGS;
2644 MonoDomain *domain = mono_object_domain (this);
2646 MonoRealProxy *rp = ((MonoRealProxy *)this);
2650 res = mono_object_new (domain, mono_defaults.transparent_proxy_class);
2652 ((MonoTransparentProxy *)res)->rp = rp;
2653 type = ((MonoReflectionType *)rp->class_to_proxy)->type;
2654 klass = mono_class_from_mono_type (type);
2656 ((MonoTransparentProxy *)res)->klass = klass;
2658 res->vtable = mono_class_proxy_vtable (domain, klass);
2663 /* System.Environment */
2666 ves_icall_System_Environment_get_MachineName (void)
2668 MONO_ARCH_SAVE_REGS;
2670 #if defined (PLATFORM_WIN32)
2675 len = MAX_COMPUTERNAME_LENGTH + 1;
2676 buf = g_new (gunichar2, len);
2679 if (GetComputerName (buf, (PDWORD) &len))
2680 result = mono_string_new_utf16 (mono_domain_get (), buf, len);
2690 buf = g_new (gchar, len);
2693 if (gethostname (buf, len) != 0)
2694 result = mono_string_new (mono_domain_get (), buf);
2702 ves_icall_System_Environment_get_Platform (void)
2704 MONO_ARCH_SAVE_REGS;
2706 #if defined (PLATFORM_WIN32)
2716 ves_icall_System_Environment_get_NewLine (void)
2718 MONO_ARCH_SAVE_REGS;
2720 #if defined (PLATFORM_WIN32)
2721 return mono_string_new (mono_domain_get (), "\r\n");
2723 return mono_string_new (mono_domain_get (), "\n");
2728 ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
2730 MONO_ARCH_SAVE_REGS;
2738 utf8_name = mono_string_to_utf8 (name); /* FIXME: this should be ascii */
2739 value = g_getenv (utf8_name);
2745 return mono_string_new (mono_domain_get (), value);
2749 * There is no standard way to get at environ.
2751 extern char **environ;
2754 ves_icall_System_Environment_GetEnvironmentVariableNames (void)
2756 MONO_ARCH_SAVE_REGS;
2765 for (e = environ; *e != 0; ++ e)
2768 domain = mono_domain_get ();
2769 names = mono_array_new (domain, mono_defaults.string_class, n);
2772 for (e = environ; *e != 0; ++ e) {
2773 parts = g_strsplit (*e, "=", 2);
2775 str = mono_string_new (domain, *parts);
2776 mono_array_set (names, MonoString *, n, str);
2788 * Returns the number of milliseconds elapsed since the system started.
2791 ves_icall_System_Environment_get_TickCount (void)
2793 MONO_ARCH_SAVE_REGS;
2795 #if defined (PLATFORM_WIN32)
2796 return GetTickCount();
2802 res = (gint32) gettimeofday (&tv, &tz);
2805 res = (gint32) ((tv.tv_sec & 0xFFFFF) * 1000 + (tv.tv_usec / 1000));
2812 ves_icall_System_Environment_Exit (int result)
2814 MONO_ARCH_SAVE_REGS;
2816 /* we may need to do some cleanup here... */
2821 ves_icall_System_Text_Encoding_InternalCodePage (void)
2823 MONO_ARCH_SAVE_REGS;
2826 g_get_charset (&cset);
2827 /* g_print ("charset: %s\n", cset); */
2828 /* handle some common aliases */
2831 if (strcmp (cset, "ANSI_X3.4-1968") == 0)
2835 return mono_string_new (mono_domain_get (), cset);
2839 ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this,
2840 MonoReflectionMethod *method,
2841 MonoArray *out_args)
2843 MONO_ARCH_SAVE_REGS;
2845 mono_message_init (mono_object_domain (this), this, method, out_args);
2849 ves_icall_IsTransparentProxy (MonoObject *proxy)
2851 MONO_ARCH_SAVE_REGS;
2856 if (proxy->vtable->klass == mono_defaults.transparent_proxy_class)
2863 ves_icall_System_Runtime_Serialization_FormatterServices_GetUninitializedObject_Internal (MonoReflectionType *type)
2865 MONO_ARCH_SAVE_REGS;
2871 domain = mono_object_domain (type);
2872 klass = mono_class_from_mono_type (type->type);
2874 if (klass->rank >= 1) {
2875 g_assert (klass->rank == 1);
2876 obj = (MonoObject *) mono_array_new (domain, klass->element_class, 0);
2878 obj = mono_object_new (domain, klass);
2885 ves_icall_System_IO_get_temp_path (void)
2887 MONO_ARCH_SAVE_REGS;
2889 return mono_string_new (mono_domain_get (), g_get_tmp_dir ());
2893 ves_icall_RuntimeMethod_GetFunctionPointer (MonoMethod *method)
2895 MONO_ARCH_SAVE_REGS;
2897 return mono_compile_method (method);
2901 ves_icall_System_Configuration_DefaultConfig_get_machine_config_path (void)
2903 MONO_ARCH_SAVE_REGS;
2905 static MonoString *mcpath;
2911 path = g_build_path (G_DIR_SEPARATOR_S, MONO_CFG_DIR, "mono", "machine.config", NULL);
2913 #if defined (PLATFORM_WIN32)
2914 /* Avoid mixing '/' and '\\' */
2917 for (i = strlen (path) - 1; i >= 0; i--)
2918 if (path [i] == '/')
2922 mcpath = mono_string_new (mono_domain_get (), path);
2930 static gconstpointer icall_map [] = {
2934 "System.Array::GetValue", ves_icall_System_Array_GetValue,
2935 "System.Array::SetValue", ves_icall_System_Array_SetValue,
2936 "System.Array::GetValueImpl", ves_icall_System_Array_GetValueImpl,
2937 "System.Array::SetValueImpl", ves_icall_System_Array_SetValueImpl,
2938 "System.Array::GetRank", ves_icall_System_Array_GetRank,
2939 "System.Array::GetLength", ves_icall_System_Array_GetLength,
2940 "System.Array::GetLowerBound", ves_icall_System_Array_GetLowerBound,
2941 "System.Array::CreateInstanceImpl", ves_icall_System_Array_CreateInstanceImpl,
2942 "System.Array::FastCopy", ves_icall_System_Array_FastCopy,
2943 "System.Array::Clone", mono_array_clone,
2948 "System.Object::MemberwiseClone", ves_icall_System_Object_MemberwiseClone,
2949 "System.Object::GetType", ves_icall_System_Object_GetType,
2950 "System.Object::GetHashCode", ves_icall_System_Object_GetHashCode,
2951 "System.Object::obj_address", ves_icall_System_Object_obj_address,
2956 "System.ValueType::GetHashCode", ves_icall_System_ValueType_GetHashCode,
2957 "System.ValueType::Equals", ves_icall_System_ValueType_Equals,
2963 "System.String::.ctor(char*)", ves_icall_System_String_ctor_charp,
2964 "System.String::.ctor(char*,int,int)", ves_icall_System_String_ctor_charp_int_int,
2965 "System.String::.ctor(sbyte*)", ves_icall_System_String_ctor_sbytep,
2966 "System.String::.ctor(sbyte*,int,int)", ves_icall_System_String_ctor_sbytep_int_int,
2967 "System.String::.ctor(sbyte*,int,int,System.Text.Encoding)", ves_icall_System_String_ctor_encoding,
2968 "System.String::.ctor(char[])", ves_icall_System_String_ctor_chara,
2969 "System.String::.ctor(char[],int,int)", ves_icall_System_String_ctor_chara_int_int,
2970 "System.String::.ctor(char,int)", ves_icall_System_String_ctor_char_int,
2971 "System.String::InternalEquals", ves_icall_System_String_InternalEquals,
2972 "System.String::InternalJoin", ves_icall_System_String_InternalJoin,
2973 "System.String::InternalInsert", ves_icall_System_String_InternalInsert,
2974 "System.String::InternalReplace(char,char)", ves_icall_System_String_InternalReplace_Char,
2975 "System.String::InternalReplace(string,string)", ves_icall_System_String_InternalReplace_Str,
2976 "System.String::InternalRemove", ves_icall_System_String_InternalRemove,
2977 "System.String::InternalCopyTo", ves_icall_System_String_InternalCopyTo,
2978 "System.String::InternalSplit", ves_icall_System_String_InternalSplit,
2979 "System.String::InternalTrim", ves_icall_System_String_InternalTrim,
2980 "System.String::InternalIndexOf(char,int,int)", ves_icall_System_String_InternalIndexOf_Char,
2981 "System.String::InternalIndexOf(string,int,int)", ves_icall_System_String_InternalIndexOf_Str,
2982 "System.String::InternalIndexOfAny", ves_icall_System_String_InternalIndexOfAny,
2983 "System.String::InternalLastIndexOf(char,int,int)", ves_icall_System_String_InternalLastIndexOf_Char,
2984 "System.String::InternalLastIndexOf(string,int,int)", ves_icall_System_String_InternalLastIndexOf_Str,
2985 "System.String::InternalLastIndexOfAny", ves_icall_System_String_InternalLastIndexOfAny,
2986 "System.String::InternalPad", ves_icall_System_String_InternalPad,
2987 "System.String::InternalToLower", ves_icall_System_String_InternalToLower,
2988 "System.String::InternalToUpper", ves_icall_System_String_InternalToUpper,
2989 "System.String::InternalAllocateStr", ves_icall_System_String_InternalAllocateStr,
2990 "System.String::InternalStrcpy(string,int,string)", ves_icall_System_String_InternalStrcpy_Str,
2991 "System.String::InternalStrcpy(string,int,string,int,int)", ves_icall_System_String_InternalStrcpy_StrN,
2992 "System.String::InternalIntern", ves_icall_System_String_InternalIntern,
2993 "System.String::InternalIsInterned", ves_icall_System_String_InternalIsInterned,
2994 "System.String::InternalCompare(string,int,string,int,int,bool)", ves_icall_System_String_InternalCompareStr_N,
2995 "System.String::GetHashCode", ves_icall_System_String_GetHashCode,
2996 "System.String::get_Chars", ves_icall_System_String_get_Chars,
3001 "System.AppDomain::createDomain", ves_icall_System_AppDomain_createDomain,
3002 "System.AppDomain::getCurDomain", ves_icall_System_AppDomain_getCurDomain,
3003 "System.AppDomain::GetData", ves_icall_System_AppDomain_GetData,
3004 "System.AppDomain::SetData", ves_icall_System_AppDomain_SetData,
3005 "System.AppDomain::getSetup", ves_icall_System_AppDomain_getSetup,
3006 "System.AppDomain::getFriendlyName", ves_icall_System_AppDomain_getFriendlyName,
3007 "System.AppDomain::GetAssemblies", ves_icall_System_AppDomain_GetAssemblies,
3008 "System.AppDomain::LoadAssembly", ves_icall_System_AppDomain_LoadAssembly,
3009 "System.AppDomain::Unload", ves_icall_System_AppDomain_Unload,
3010 "System.AppDomain::ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly,
3013 * System.AppDomainSetup
3015 "System.AppDomainSetup::InitAppDomainSetup", ves_icall_System_AppDomainSetup_InitAppDomainSetup,
3020 "System.Double::ToStringImpl", mono_double_ToStringImpl,
3021 "System.Double::ParseImpl", mono_double_ParseImpl,
3026 "System.Single::ToStringImpl", mono_float_ToStringImpl,
3031 "System.Decimal::decimal2UInt64", mono_decimal2UInt64,
3032 "System.Decimal::decimal2Int64", mono_decimal2Int64,
3033 "System.Decimal::double2decimal", mono_double2decimal, /* FIXME: wrong signature. */
3034 "System.Decimal::decimalIncr", mono_decimalIncr,
3035 "System.Decimal::decimalSetExponent", mono_decimalSetExponent,
3036 "System.Decimal::decimal2double", mono_decimal2double,
3037 "System.Decimal::decimalFloorAndTrunc", mono_decimalFloorAndTrunc,
3038 "System.Decimal::decimalRound", mono_decimalRound,
3039 "System.Decimal::decimalMult", mono_decimalMult,
3040 "System.Decimal::decimalDiv", mono_decimalDiv,
3041 "System.Decimal::decimalIntDiv", mono_decimalIntDiv,
3042 "System.Decimal::decimalCompare", mono_decimalCompare,
3043 "System.Decimal::string2decimal", mono_string2decimal,
3044 "System.Decimal::decimal2string", mono_decimal2string,
3049 "System.Reflection.Emit.ModuleBuilder::create_modified_type", ves_icall_ModuleBuilder_create_modified_type,
3054 "System.Reflection.Emit.AssemblyBuilder::getDataChunk", ves_icall_AssemblyBuilder_getDataChunk,
3055 "System.Reflection.Emit.AssemblyBuilder::getUSIndex", mono_image_insert_string,
3056 "System.Reflection.Emit.AssemblyBuilder::getToken", ves_icall_AssemblyBuilder_getToken,
3057 "System.Reflection.Emit.AssemblyBuilder::basic_init", mono_image_basic_init,
3062 "System.Reflection.MonoMethodInfo::get_method_info", ves_icall_get_method_info,
3063 "System.Reflection.MonoMethodInfo::get_parameter_info", ves_icall_get_parameter_info,
3064 "System.Reflection.MonoFieldInfo::get_field_info", ves_icall_get_field_info,
3065 "System.Reflection.MonoPropertyInfo::get_property_info", ves_icall_get_property_info,
3066 "System.Reflection.MonoEventInfo::get_event_info", ves_icall_get_event_info,
3067 "System.Reflection.MonoMethod::InternalInvoke", ves_icall_InternalInvoke,
3068 "System.Reflection.MonoCMethod::InternalInvoke", ves_icall_InternalInvoke,
3069 "System.Reflection.MethodBase::GetCurrentMethod", ves_icall_GetCurrentMethod,
3070 "System.MonoCustomAttrs::GetCustomAttributes", mono_reflection_get_custom_attrs,
3071 "System.Reflection.Emit.CustomAttributeBuilder::GetBlob", mono_reflection_get_custom_attrs_blob,
3072 "System.Reflection.MonoField::GetValueInternal", ves_icall_MonoField_GetValueInternal,
3073 "System.Reflection.MonoField::SetValueInternal", ves_icall_FieldInfo_SetValueInternal,
3074 "System.Reflection.Emit.SignatureHelper::get_signature_local", mono_reflection_sighelper_get_signature_local,
3075 "System.Reflection.Emit.SignatureHelper::get_signature_field", mono_reflection_sighelper_get_signature_field,
3077 "System.RuntimeMethodHandle::GetFunctionPointer", ves_icall_RuntimeMethod_GetFunctionPointer,
3081 "System.MonoEnumInfo::get_enum_info", ves_icall_get_enum_info,
3082 "System.Enum::get_value", ves_icall_System_Enum_get_value,
3083 "System.Enum::ToObject", ves_icall_System_Enum_ToObject,
3088 "System.Reflection.Emit.TypeBuilder::setup_internal_class", mono_reflection_setup_internal_class,
3089 "System.Reflection.Emit.TypeBuilder::create_internal_class", mono_reflection_create_internal_class,
3090 "System.Reflection.Emit.TypeBuilder::create_runtime_class", mono_reflection_create_runtime_class,
3099 "System.Type::internal_from_name", ves_icall_type_from_name,
3100 "System.Type::internal_from_handle", ves_icall_type_from_handle,
3101 "System.MonoType::get_attributes", ves_icall_get_attributes,
3102 "System.Type::type_is_subtype_of", ves_icall_type_is_subtype_of,
3103 "System.Type::Equals", ves_icall_type_Equals,
3104 "System.Type::GetTypeCode", ves_icall_type_GetTypeCode,
3107 * System.Runtime.CompilerServices.RuntimeHelpers
3109 "System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray,
3110 "System.Runtime.CompilerServices.RuntimeHelpers::GetOffsetToStringData", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData,
3111 "System.Runtime.CompilerServices.RuntimeHelpers::GetObjectValue", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue,
3112 "System.Runtime.CompilerServices.RuntimeHelpers::RunClassConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor,
3117 "System.Threading.Thread::Abort(object)", ves_icall_System_Threading_Thread_Abort,
3118 "System.Threading.Thread::ResetAbort", ves_icall_System_Threading_Thread_ResetAbort,
3119 "System.Threading.Thread::Thread_internal", ves_icall_System_Threading_Thread_Thread_internal,
3120 "System.Threading.Thread::Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal,
3121 "System.Threading.Thread::Start_internal", ves_icall_System_Threading_Thread_Start_internal,
3122 "System.Threading.Thread::Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal,
3123 "System.Threading.Thread::CurrentThread_internal", mono_thread_current,
3124 "System.Threading.Thread::Join_internal", ves_icall_System_Threading_Thread_Join_internal,
3125 "System.Threading.Thread::SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup,
3126 "System.Threading.Thread::SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store,
3127 "System.Threading.Thread::GetDomainID", ves_icall_System_Threading_Thread_GetDomainID,
3128 "System.Threading.Monitor::Monitor_exit", ves_icall_System_Threading_Monitor_Monitor_exit,
3129 "System.Threading.Monitor::Monitor_test_owner", ves_icall_System_Threading_Monitor_Monitor_test_owner,
3130 "System.Threading.Monitor::Monitor_test_synchronised", ves_icall_System_Threading_Monitor_Monitor_test_synchronised,
3131 "System.Threading.Monitor::Monitor_pulse", ves_icall_System_Threading_Monitor_Monitor_pulse,
3132 "System.Threading.Monitor::Monitor_pulse_all", ves_icall_System_Threading_Monitor_Monitor_pulse_all,
3133 "System.Threading.Monitor::Monitor_try_enter", ves_icall_System_Threading_Monitor_Monitor_try_enter,
3134 "System.Threading.Monitor::Monitor_wait", ves_icall_System_Threading_Monitor_Monitor_wait,
3135 "System.Threading.Mutex::CreateMutex_internal", ves_icall_System_Threading_Mutex_CreateMutex_internal,
3136 "System.Threading.Mutex::ReleaseMutex_internal", ves_icall_System_Threading_Mutex_ReleaseMutex_internal,
3137 "System.Threading.NativeEventCalls::CreateEvent_internal", ves_icall_System_Threading_Events_CreateEvent_internal,
3138 "System.Threading.NativeEventCalls::SetEvent_internal", ves_icall_System_Threading_Events_SetEvent_internal,
3139 "System.Threading.NativeEventCalls::ResetEvent_internal", ves_icall_System_Threading_Events_ResetEvent_internal,
3142 * System.Threading.WaitHandle
3144 "System.Threading.WaitHandle::WaitAll_internal", ves_icall_System_Threading_WaitHandle_WaitAll_internal,
3145 "System.Threading.WaitHandle::WaitAny_internal", ves_icall_System_Threading_WaitHandle_WaitAny_internal,
3146 "System.Threading.WaitHandle::WaitOne_internal", ves_icall_System_Threading_WaitHandle_WaitOne_internal,
3149 * System.Runtime.InteropServices.Marshal
3151 "System.Runtime.InteropServices.Marshal::ReadIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr,
3152 "System.Runtime.InteropServices.Marshal::ReadByte", ves_icall_System_Runtime_InteropServices_Marshal_ReadByte,
3153 "System.Runtime.InteropServices.Marshal::ReadInt16", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt16,
3154 "System.Runtime.InteropServices.Marshal::ReadInt32", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt32,
3155 "System.Runtime.InteropServices.Marshal::ReadInt64", ves_icall_System_Runtime_InteropServices_Marshal_ReadInt64,
3156 "System.Runtime.InteropServices.Marshal::WriteIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_WriteIntPtr,
3157 "System.Runtime.InteropServices.Marshal::WriteByte", ves_icall_System_Runtime_InteropServices_Marshal_WriteByte,
3158 "System.Runtime.InteropServices.Marshal::WriteInt16", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt16,
3159 "System.Runtime.InteropServices.Marshal::WriteInt32", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt32,
3160 "System.Runtime.InteropServices.Marshal::WriteInt64", ves_icall_System_Runtime_InteropServices_Marshal_WriteInt64,
3162 "System.Runtime.InteropServices.Marshal::PtrToStringAnsi(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi,
3163 "System.Runtime.InteropServices.Marshal::PtrToStringAnsi(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len,
3164 "System.Runtime.InteropServices.Marshal::PtrToStringAuto(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi,
3165 "System.Runtime.InteropServices.Marshal::PtrToStringAuto(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAnsi_len,
3166 "System.Runtime.InteropServices.Marshal::PtrToStringUni(intptr)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni,
3167 "System.Runtime.InteropServices.Marshal::PtrToStringUni(intptr,int)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringUni_len,
3168 "System.Runtime.InteropServices.Marshal::PtrToStringBSTR", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringBSTR,
3170 "System.Runtime.InteropServices.Marshal::GetLastWin32Error", ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error,
3171 "System.Runtime.InteropServices.Marshal::AllocHGlobal", mono_marshal_alloc,
3172 "System.Runtime.InteropServices.Marshal::FreeHGlobal", mono_marshal_free,
3173 "System.Runtime.InteropServices.Marshal::ReAllocHGlobal", mono_marshal_realloc,
3174 "System.Runtime.InteropServices.Marshal::copy_to_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_to_unmanaged,
3175 "System.Runtime.InteropServices.Marshal::copy_from_unmanaged", ves_icall_System_Runtime_InteropServices_Marshal_copy_from_unmanaged,
3176 "System.Runtime.InteropServices.Marshal::SizeOf", ves_icall_System_Runtime_InteropServices_Marshal_SizeOf,
3177 "System.Runtime.InteropServices.Marshal::StructureToPtr", ves_icall_System_Runtime_InteropServices_Marshal_StructureToPtr,
3178 "System.Runtime.InteropServices.Marshal::PtrToStructure(intptr,object)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure,
3179 "System.Runtime.InteropServices.Marshal::PtrToStructure(intptr,System.Type)", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStructure_type,
3180 "System.Runtime.InteropServices.Marshal::OffsetOf", ves_icall_System_Runtime_InteropServices_Marshal_OffsetOf,
3181 "System.Runtime.InteropServices.Marshal::StringToHGlobalAnsi", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi,
3182 "System.Runtime.InteropServices.Marshal::StringToHGlobalAuto", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalAnsi,
3183 "System.Runtime.InteropServices.Marshal::StringToHGlobalUni", ves_icall_System_Runtime_InteropServices_Marshal_StringToHGlobalUni,
3184 "System.Runtime.InteropServices.Marshal::DestroyStructure", ves_icall_System_Runtime_InteropServices_Marshal_DestroyStructure,
3187 "System.Reflection.Assembly::LoadFrom", ves_icall_System_Reflection_Assembly_LoadFrom,
3188 "System.Reflection.Assembly::InternalGetType", ves_icall_System_Reflection_Assembly_InternalGetType,
3189 "System.Reflection.Assembly::GetTypes", ves_icall_System_Reflection_Assembly_GetTypes,
3190 "System.Reflection.Assembly::FillName", ves_icall_System_Reflection_Assembly_FillName,
3191 "System.Reflection.Assembly::get_code_base", ves_icall_System_Reflection_Assembly_get_code_base,
3192 "System.Reflection.Assembly::get_location", ves_icall_System_Reflection_Assembly_get_location,
3193 "System.Reflection.Assembly::GetExecutingAssembly", ves_icall_System_Reflection_Assembly_GetExecutingAssembly,
3194 "System.Reflection.Assembly::GetEntryAssembly", ves_icall_System_Reflection_Assembly_GetEntryAssembly,
3195 "System.Reflection.Assembly::GetCallingAssembly", ves_icall_System_Reflection_Assembly_GetCallingAssembly,
3196 "System.Reflection.Assembly::get_EntryPoint", ves_icall_System_Reflection_Assembly_get_EntryPoint,
3197 "System.Reflection.Assembly::GetManifestResourceNames", ves_icall_System_Reflection_Assembly_GetManifestResourceNames,
3198 "System.Reflection.Assembly::GetManifestResourceInternal", ves_icall_System_Reflection_Assembly_GetManifestResourceInternal,
3199 "System.Reflection.Assembly::GetFilesInternal", ves_icall_System_Reflection_Assembly_GetFilesInternal,
3200 "System.Reflection.Assembly::GetReferencedAssemblies", ves_icall_System_Reflection_Assembly_GetReferencedAssemblies,
3205 "System.MonoType::getFullName", ves_icall_System_MonoType_getFullName,
3206 "System.MonoType::type_from_obj", mono_type_type_from_obj,
3207 "System.MonoType::GetElementType", ves_icall_MonoType_GetElementType,
3208 "System.MonoType::get_type_info", ves_icall_get_type_info,
3209 "System.MonoType::get_BaseType", ves_icall_get_type_parent,
3210 "System.MonoType::get_Module", ves_icall_MonoType_get_Module,
3211 "System.MonoType::IsPointerImpl", ves_icall_type_ispointer,
3212 "System.MonoType::IsByRefImpl", ves_icall_type_isbyref,
3213 "System.MonoType::GetField", ves_icall_Type_GetField,
3214 "System.MonoType::GetFields", ves_icall_Type_GetFields,
3215 "System.MonoType::GetMethods", ves_icall_Type_GetMethods,
3216 "System.MonoType::GetConstructors", ves_icall_Type_GetConstructors,
3217 "System.MonoType::GetProperties", ves_icall_Type_GetProperties,
3218 "System.MonoType::GetEvents", ves_icall_Type_GetEvents,
3219 "System.MonoType::InternalGetEvent", ves_icall_MonoType_GetEvent,
3220 "System.MonoType::GetInterfaces", ves_icall_Type_GetInterfaces,
3221 "System.MonoType::GetNestedTypes", ves_icall_Type_GetNestedTypes,
3224 * System.Net.Sockets I/O Services
3226 "System.Net.Sockets.Socket::Socket_internal", ves_icall_System_Net_Sockets_Socket_Socket_internal,
3227 "System.Net.Sockets.Socket::Close_internal", ves_icall_System_Net_Sockets_Socket_Close_internal,
3228 "System.Net.Sockets.SocketException::WSAGetLastError_internal", ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal,
3229 "System.Net.Sockets.Socket::Available_internal", ves_icall_System_Net_Sockets_Socket_Available_internal,
3230 "System.Net.Sockets.Socket::Blocking_internal", ves_icall_System_Net_Sockets_Socket_Blocking_internal,
3231 "System.Net.Sockets.Socket::Accept_internal", ves_icall_System_Net_Sockets_Socket_Accept_internal,
3232 "System.Net.Sockets.Socket::Listen_internal", ves_icall_System_Net_Sockets_Socket_Listen_internal,
3233 "System.Net.Sockets.Socket::LocalEndPoint_internal", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal,
3234 "System.Net.Sockets.Socket::RemoteEndPoint_internal", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal,
3235 "System.Net.Sockets.Socket::Bind_internal", ves_icall_System_Net_Sockets_Socket_Bind_internal,
3236 "System.Net.Sockets.Socket::Connect_internal", ves_icall_System_Net_Sockets_Socket_Connect_internal,
3237 "System.Net.Sockets.Socket::Receive_internal", ves_icall_System_Net_Sockets_Socket_Receive_internal,
3238 "System.Net.Sockets.Socket::RecvFrom_internal", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal,
3239 "System.Net.Sockets.Socket::Send_internal", ves_icall_System_Net_Sockets_Socket_Send_internal,
3240 "System.Net.Sockets.Socket::SendTo_internal", ves_icall_System_Net_Sockets_Socket_SendTo_internal,
3241 "System.Net.Sockets.Socket::Select_internal", ves_icall_System_Net_Sockets_Socket_Select_internal,
3242 "System.Net.Sockets.Socket::Shutdown_internal", ves_icall_System_Net_Sockets_Socket_Shutdown_internal,
3243 "System.Net.Sockets.Socket::GetSocketOption_obj_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal,
3244 "System.Net.Sockets.Socket::GetSocketOption_arr_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal,
3245 "System.Net.Sockets.Socket::SetSocketOption_internal", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal,
3246 "System.Net.Dns::GetHostByName_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByName_internal,
3247 "System.Net.Dns::GetHostByAddr_internal(string,string&,string[]&,string[]&)", ves_icall_System_Net_Dns_GetHostByAddr_internal,
3248 "System.Net.Dns::GetHostName_internal(string&)", ves_icall_System_Net_Dns_GetHostName_internal,
3253 "System.Char::GetNumericValue", ves_icall_System_Char_GetNumericValue,
3254 "System.Char::GetUnicodeCategory", ves_icall_System_Char_GetUnicodeCategory,
3255 "System.Char::IsControl", ves_icall_System_Char_IsControl,
3256 "System.Char::IsDigit", ves_icall_System_Char_IsDigit,
3257 "System.Char::IsLetter", ves_icall_System_Char_IsLetter,
3258 "System.Char::IsLower", ves_icall_System_Char_IsLower,
3259 "System.Char::IsUpper", ves_icall_System_Char_IsUpper,
3260 "System.Char::IsNumber", ves_icall_System_Char_IsNumber,
3261 "System.Char::IsPunctuation", ves_icall_System_Char_IsPunctuation,
3262 "System.Char::IsSeparator", ves_icall_System_Char_IsSeparator,
3263 "System.Char::IsSurrogate", ves_icall_System_Char_IsSurrogate,
3264 "System.Char::IsSymbol", ves_icall_System_Char_IsSymbol,
3265 "System.Char::IsWhiteSpace", ves_icall_System_Char_IsWhiteSpace,
3266 "System.Char::ToLower", ves_icall_System_Char_ToLower,
3267 "System.Char::ToUpper", ves_icall_System_Char_ToUpper,
3270 * System.Text.Encoding
3272 "System.Text.Encoding::InternalCodePage", ves_icall_System_Text_Encoding_InternalCodePage,
3274 "System.DateTime::GetNow", ves_icall_System_DateTime_GetNow,
3275 "System.CurrentTimeZone::GetTimeZoneData", ves_icall_System_CurrentTimeZone_GetTimeZoneData,
3280 "System.GC::InternalCollect", ves_icall_System_GC_InternalCollect,
3281 "System.GC::GetTotalMemory", ves_icall_System_GC_GetTotalMemory,
3282 "System.GC::KeepAlive", ves_icall_System_GC_KeepAlive,
3283 "System.GC::ReRegisterForFinalize", ves_icall_System_GC_ReRegisterForFinalize,
3284 "System.GC::SuppressFinalize", ves_icall_System_GC_SuppressFinalize,
3285 "System.GC::WaitForPendingFinalizers", ves_icall_System_GC_WaitForPendingFinalizers,
3286 "System.Runtime.InteropServices.GCHandle::GetTarget", ves_icall_System_GCHandle_GetTarget,
3287 "System.Runtime.InteropServices.GCHandle::GetTargetHandle", ves_icall_System_GCHandle_GetTargetHandle,
3288 "System.Runtime.InteropServices.GCHandle::FreeHandle", ves_icall_System_GCHandle_FreeHandle,
3289 "System.Runtime.InteropServices.GCHandle::GetAddrOfPinnedObject", ves_icall_System_GCHandle_GetAddrOfPinnedObject,
3292 * System.Security.Cryptography calls
3295 "System.Security.Cryptography.RNGCryptoServiceProvider::GetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_GetBytes,
3296 "System.Security.Cryptography.RNGCryptoServiceProvider::GetNonZeroBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_GetNonZeroBytes,
3301 "System.Buffer::ByteLengthInternal", ves_icall_System_Buffer_ByteLengthInternal,
3302 "System.Buffer::GetByteInternal", ves_icall_System_Buffer_GetByteInternal,
3303 "System.Buffer::SetByteInternal", ves_icall_System_Buffer_SetByteInternal,
3304 "System.Buffer::BlockCopyInternal", ves_icall_System_Buffer_BlockCopyInternal,
3309 "System.IO.MonoIO::CreateDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CreateDirectory,
3310 "System.IO.MonoIO::RemoveDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_RemoveDirectory,
3311 "System.IO.MonoIO::FindFirstFile(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindFirstFile,
3312 "System.IO.MonoIO::FindNextFile(intptr,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindNextFile,
3313 "System.IO.MonoIO::FindClose(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindClose,
3314 "System.IO.MonoIO::GetCurrentDirectory(System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetCurrentDirectory,
3315 "System.IO.MonoIO::SetCurrentDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetCurrentDirectory,
3316 "System.IO.MonoIO::MoveFile(string,string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_MoveFile,
3317 "System.IO.MonoIO::CopyFile(string,string,bool,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CopyFile,
3318 "System.IO.MonoIO::DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile,
3319 "System.IO.MonoIO::GetFileAttributes(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileAttributes,
3320 "System.IO.MonoIO::SetFileAttributes(string,System.IO.FileAttributes,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileAttributes,
3321 "System.IO.MonoIO::GetFileType(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileType,
3322 "System.IO.MonoIO::GetFileStat(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileStat,
3323 "System.IO.MonoIO::Open(string,System.IO.FileMode,System.IO.FileAccess,System.IO.FileShare,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Open,
3324 "System.IO.MonoIO::Close(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Close,
3325 "System.IO.MonoIO::Read(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Read,
3326 "System.IO.MonoIO::Write(intptr,byte[],int,int,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Write,
3327 "System.IO.MonoIO::Seek(intptr,long,System.IO.SeekOrigin,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Seek,
3328 "System.IO.MonoIO::GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength,
3329 "System.IO.MonoIO::SetLength(intptr,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetLength,
3330 "System.IO.MonoIO::SetFileTime(intptr,long,long,long,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_SetFileTime,
3331 "System.IO.MonoIO::Flush(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Flush,
3332 "System.IO.MonoIO::get_ConsoleOutput", ves_icall_System_IO_MonoIO_get_ConsoleOutput,
3333 "System.IO.MonoIO::get_ConsoleInput", ves_icall_System_IO_MonoIO_get_ConsoleInput,
3334 "System.IO.MonoIO::get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError,
3335 "System.IO.MonoIO::CreatePipe(intptr&,intptr&)", ves_icall_System_IO_MonoIO_CreatePipe,
3336 "System.IO.MonoIO::get_VolumeSeparatorChar", ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar,
3337 "System.IO.MonoIO::get_DirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar,
3338 "System.IO.MonoIO::get_AltDirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar,
3339 "System.IO.MonoIO::get_PathSeparator", ves_icall_System_IO_MonoIO_get_PathSeparator,
3340 "System.IO.MonoIO::get_InvalidPathChars", ves_icall_System_IO_MonoIO_get_InvalidPathChars,
3345 "System.Math::Sin", ves_icall_System_Math_Sin,
3346 "System.Math::Cos", ves_icall_System_Math_Cos,
3347 "System.Math::Tan", ves_icall_System_Math_Tan,
3348 "System.Math::Sinh", ves_icall_System_Math_Sinh,
3349 "System.Math::Cosh", ves_icall_System_Math_Cosh,
3350 "System.Math::Tanh", ves_icall_System_Math_Tanh,
3351 "System.Math::Acos", ves_icall_System_Math_Acos,
3352 "System.Math::Asin", ves_icall_System_Math_Asin,
3353 "System.Math::Atan", ves_icall_System_Math_Atan,
3354 "System.Math::Atan2", ves_icall_System_Math_Atan2,
3355 "System.Math::Exp", ves_icall_System_Math_Exp,
3356 "System.Math::Log", ves_icall_System_Math_Log,
3357 "System.Math::Log10", ves_icall_System_Math_Log10,
3358 "System.Math::PowImpl", ves_icall_System_Math_Pow,
3359 "System.Math::Sqrt", ves_icall_System_Math_Sqrt,
3362 * System.Environment
3364 "System.Environment::get_MachineName", ves_icall_System_Environment_get_MachineName,
3365 "System.Environment::get_NewLine", ves_icall_System_Environment_get_NewLine,
3366 "System.Environment::GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable,
3367 "System.Environment::GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames,
3368 "System.Environment::GetCommandLineArgs", mono_runtime_get_main_args,
3369 "System.Environment::get_TickCount", ves_icall_System_Environment_get_TickCount,
3370 "System.Environment::Exit", ves_icall_System_Environment_Exit,
3371 "System.Environment::get_Platform", ves_icall_System_Environment_get_Platform,
3374 * System.Runtime.Remoting
3376 "System.Runtime.Remoting.RemotingServices::InternalExecute",
3377 ves_icall_InternalExecute,
3378 "System.Runtime.Remoting.RemotingServices::IsTransparentProxy",
3379 ves_icall_IsTransparentProxy,
3382 * System.Runtime.Remoting.Messaging
3384 "System.Runtime.Remoting.Messaging.MonoMethodMessage::InitMessage",
3385 ves_icall_MonoMethodMessage_InitMessage,
3388 * System.Runtime.Remoting.Proxies
3390 "System.Runtime.Remoting.Proxies.RealProxy::GetTransparentProxy",
3391 ves_icall_Remoting_RealProxy_GetTransparentProxy,
3394 * System.Threading.Interlocked
3396 "System.Threading.Interlocked::Increment(int&)", ves_icall_System_Threading_Interlocked_Increment_Int,
3397 "System.Threading.Interlocked::Increment(long&)", ves_icall_System_Threading_Interlocked_Increment_Long,
3398 "System.Threading.Interlocked::Decrement(int&)", ves_icall_System_Threading_Interlocked_Decrement_Int,
3399 "System.Threading.Interlocked::Decrement(long&)", ves_icall_System_Threading_Interlocked_Decrement_Long,
3400 "System.Threading.Interlocked::CompareExchange(int&,int,int)", ves_icall_System_Threading_Interlocked_CompareExchange_Int,
3401 "System.Threading.Interlocked::CompareExchange(object&,object,object)", ves_icall_System_Threading_Interlocked_CompareExchange_Object,
3402 "System.Threading.Interlocked::CompareExchange(single&,single,single)", ves_icall_System_Threading_Interlocked_CompareExchange_Single,
3403 "System.Threading.Interlocked::Exchange(int&,int)", ves_icall_System_Threading_Interlocked_Exchange_Int,
3404 "System.Threading.Interlocked::Exchange(object&,object)", ves_icall_System_Threading_Interlocked_Exchange_Object,
3405 "System.Threading.Interlocked::Exchange(single&,single)", ves_icall_System_Threading_Interlocked_Exchange_Single,
3408 * System.Diagnostics.Process
3410 "System.Diagnostics.Process::GetProcess_internal(int)", ves_icall_System_Diagnostics_Process_GetProcess_internal,
3411 "System.Diagnostics.Process::GetProcesses_internal()", ves_icall_System_Diagnostics_Process_GetProcesses_internal,
3412 "System.Diagnostics.Process::GetPid_internal()", ves_icall_System_Diagnostics_Process_GetPid_internal,
3413 "System.Diagnostics.Process::Process_free_internal(intptr)", ves_icall_System_Diagnostics_Process_Process_free_internal,
3414 "System.Diagnostics.Process::GetModules_internal()", ves_icall_System_Diagnostics_Process_GetModules_internal,
3415 "System.Diagnostics.Process::Start_internal(string,string,intptr,intptr,intptr,ProcInfo&)", ves_icall_System_Diagnostics_Process_Start_internal,
3416 "System.Diagnostics.Process::WaitForExit_internal(intptr,int)", ves_icall_System_Diagnostics_Process_WaitForExit_internal,
3417 "System.Diagnostics.Process::ExitTime_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitTime_internal,
3418 "System.Diagnostics.Process::StartTime_internal(intptr)", ves_icall_System_Diagnostics_Process_StartTime_internal,
3419 "System.Diagnostics.Process::ExitCode_internal(intptr)", ves_icall_System_Diagnostics_Process_ExitCode_internal,
3420 "System.Diagnostics.Process::ProcessName_internal(intptr)", ves_icall_System_Diagnostics_Process_ProcessName_internal,
3421 "System.Diagnostics.Process::GetWorkingSet_internal(intptr,int&,int&)", ves_icall_System_Diagnostics_Process_GetWorkingSet_internal,
3422 "System.Diagnostics.Process::SetWorkingSet_internal(intptr,int,int,bool)", ves_icall_System_Diagnostics_Process_SetWorkingSet_internal,
3423 "System.Diagnostics.FileVersionInfo::GetVersionInfo_internal(string)", ves_icall_System_Diagnostics_FileVersionInfo_GetVersionInfo_internal,
3428 "System.Delegate::CreateDelegate_internal", ves_icall_System_Delegate_CreateDelegate_internal,
3431 * System.Runtime.Serialization
3433 "System.Runtime.Serialization.FormatterServices::GetUninitializedObjectInternal",
3434 ves_icall_System_Runtime_Serialization_FormatterServices_GetUninitializedObject_Internal,
3439 "System.IO.Path::get_temp_path", ves_icall_System_IO_get_temp_path,
3442 * Private icalls for the Mono Debugger
3444 "System.Reflection.Assembly::MonoDebugger_GetMethod",
3445 ves_icall_MonoDebugger_GetMethod,
3447 "System.Reflection.Assembly::MonoDebugger_GetLocalTypeFromSignature",
3448 ves_icall_MonoDebugger_GetLocalTypeFromSignature,
3450 "System.Reflection.Assembly::MonoDebugger_GetType",
3451 ves_icall_MonoDebugger_GetType,
3454 * System.Configuration
3456 "System.Configuration.DefaultConfig::get_machine_config_path",
3457 ves_icall_System_Configuration_DefaultConfig_get_machine_config_path,
3460 * add other internal calls here
3466 mono_init_icall (void)
3471 while ((name = icall_map [i])) {
3472 mono_add_internal_call (name, icall_map [i+1]);