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/gc.h>
35 #include <mono/metadata/rand.h>
36 #include <mono/metadata/sysmath.h>
37 #include <mono/metadata/debug-symfile.h>
38 #include <mono/metadata/string-icalls.h>
39 #include <mono/io-layer/io-layer.h>
41 #if defined (PLATFORM_WIN32)
47 mono_double_ToStringImpl (double value)
49 /* FIXME: Handle formats, etc. */
51 retVal = g_strdup_printf ("%f", value);
52 return mono_string_new (mono_domain_get (), retVal);
56 mono_float_ToStringImpl (float value)
58 /* FIXME: Handle formats, etc. */
60 retVal = g_strdup_printf ("%f", value);
61 return mono_string_new (mono_domain_get (), retVal);
65 ves_icall_System_Array_GetValueImpl (MonoObject *this, guint32 pos)
72 ao = (MonoArray *)this;
73 ac = (MonoClass *)ao->obj.vtable->klass;
75 esize = mono_array_element_size (ac);
76 ea = (gpointer*)((char*)ao->vector + (pos * esize));
78 if (ac->element_class->valuetype)
79 return mono_value_box (this->vtable->domain, ac->element_class, ea);
85 ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs)
91 MONO_CHECK_ARG_NULL (idxs);
93 io = (MonoArray *)idxs;
94 ic = (MonoClass *)io->obj.vtable->klass;
96 ao = (MonoArray *)this;
97 ac = (MonoClass *)ao->obj.vtable->klass;
99 g_assert (ic->rank == 1);
100 if (io->bounds != NULL || io->max_length != ac->rank)
101 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
103 ind = (guint32 *)io->vector;
105 if (ao->bounds == NULL) {
106 if (*ind < 0 || *ind >= ao->max_length)
107 mono_raise_exception (mono_get_exception_index_out_of_range ());
109 return ves_icall_System_Array_GetValueImpl (this, *ind);
112 for (i = 0; i < ac->rank; i++)
113 if ((ind [i] < ao->bounds [i].lower_bound) ||
114 (ind [i] >= ao->bounds [i].length + ao->bounds [i].lower_bound))
115 mono_raise_exception (mono_get_exception_index_out_of_range ());
117 pos = ind [0] - ao->bounds [0].lower_bound;
118 for (i = 1; i < ac->rank; i++)
119 pos = pos*ao->bounds [i].length + ind [i] -
120 ao->bounds [i].lower_bound;
122 return ves_icall_System_Array_GetValueImpl (this, pos);
126 ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 pos)
128 MonoClass *ac, *vc, *ec;
137 vc = value->vtable->klass;
141 ac = this->obj.vtable->klass;
142 ec = ac->element_class;
144 esize = mono_array_element_size (ac);
145 ea = (gpointer*)((char*)this->vector + (pos * esize));
146 va = (gpointer*)((char*)value + sizeof (MonoObject));
149 memset (ea, 0, esize);
153 #define NO_WIDENING_CONVERSION G_STMT_START{\
154 mono_raise_exception (mono_get_exception_argument ( \
155 "value", "not a widening conversion")); \
158 #define CHECK_WIDENING_CONVERSION(extra) G_STMT_START{\
159 if (esize < vsize + ## extra) \
160 mono_raise_exception (mono_get_exception_argument ( \
161 "value", "not a widening conversion")); \
164 #define INVALID_CAST G_STMT_START{\
165 mono_raise_exception (mono_get_exception_invalid_cast ()); \
168 /* Check element (destination) type. */
169 switch (ec->byval_arg.type) {
170 case MONO_TYPE_STRING:
171 switch (vc->byval_arg.type) {
172 case MONO_TYPE_STRING:
178 case MONO_TYPE_BOOLEAN:
179 switch (vc->byval_arg.type) {
180 case MONO_TYPE_BOOLEAN:
193 NO_WIDENING_CONVERSION;
200 if (!ec->valuetype) {
201 *ea = (gpointer)value;
205 if (mono_object_isinst (value, ec)) {
206 memcpy (ea, (char *)value + sizeof (MonoObject), esize);
213 vsize = mono_class_instance_size (vc) - sizeof (MonoObject);
216 g_message (G_STRLOC ": %d (%d) <= %d (%d)",
217 ec->byval_arg.type, esize,
218 vc->byval_arg.type, vsize);
221 #define ASSIGN_UNSIGNED(etype) G_STMT_START{\
222 switch (vc->byval_arg.type) { \
227 case MONO_TYPE_CHAR: \
228 CHECK_WIDENING_CONVERSION(0); \
229 *(## etype *) ea = (## etype) u64; \
231 /* You can't assign a signed value to an unsigned array. */ \
236 /* You can't assign a floating point number to an integer array. */ \
239 NO_WIDENING_CONVERSION; \
243 #define ASSIGN_SIGNED(etype) G_STMT_START{\
244 switch (vc->byval_arg.type) { \
249 CHECK_WIDENING_CONVERSION(0); \
250 *(## etype *) ea = (## etype) i64; \
252 /* You can assign an unsigned value to a signed array if the array's */ \
253 /* element size is larger than the value size. */ \
258 case MONO_TYPE_CHAR: \
259 CHECK_WIDENING_CONVERSION(1); \
260 *(## etype *) ea = (## etype) u64; \
262 /* You can't assign a floating point number to an integer array. */ \
265 NO_WIDENING_CONVERSION; \
269 #define ASSIGN_REAL(etype) G_STMT_START{\
270 switch (vc->byval_arg.type) { \
273 CHECK_WIDENING_CONVERSION(0); \
274 *(## etype *) ea = (## etype) r64; \
276 /* All integer values fit into a floating point array, so we don't */ \
277 /* need to CHECK_WIDENING_CONVERSION here. */ \
282 *(## etype *) ea = (## etype) i64; \
288 case MONO_TYPE_CHAR: \
289 *(## etype *) ea = (## etype) u64; \
294 switch (vc->byval_arg.type) {
296 u64 = *(guint8 *) va;
299 u64 = *(guint16 *) va;
302 u64 = *(guint32 *) va;
305 u64 = *(guint64 *) va;
311 i64 = *(gint16 *) va;
314 i64 = *(gint32 *) va;
317 i64 = *(gint64 *) va;
320 r64 = *(gfloat *) va;
323 r64 = *(gdouble *) va;
326 u64 = *(guint16 *) va;
328 case MONO_TYPE_BOOLEAN:
329 /* Boolean is only compatible with itself. */
330 switch (ec->byval_arg.type) {
342 NO_WIDENING_CONVERSION;
349 /* If we can't do a direct copy, let's try a widening conversion. */
350 switch (ec->byval_arg.type) {
352 ASSIGN_UNSIGNED (guint16);
354 ASSIGN_UNSIGNED (guint8);
356 ASSIGN_UNSIGNED (guint16);
358 ASSIGN_UNSIGNED (guint32);
360 ASSIGN_UNSIGNED (guint64);
362 ASSIGN_SIGNED (gint8);
364 ASSIGN_SIGNED (gint16);
366 ASSIGN_SIGNED (gint32);
368 ASSIGN_SIGNED (gint64);
370 ASSIGN_REAL (gfloat);
372 ASSIGN_REAL (gdouble);
376 /* Not reached, INVALID_CAST does not return. Just to avoid a compiler warning ... */
380 #undef NO_WIDENING_CONVERSION
381 #undef CHECK_WIDENING_CONVERSION
382 #undef ASSIGN_UNSIGNED
388 ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value,
394 MONO_CHECK_ARG_NULL (idxs);
396 ic = idxs->obj.vtable->klass;
397 ac = this->obj.vtable->klass;
399 g_assert (ic->rank == 1);
400 if (idxs->bounds != NULL || idxs->max_length != ac->rank)
401 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
403 ind = (guint32 *)idxs->vector;
405 if (this->bounds == NULL) {
406 if (*ind < 0 || *ind >= this->max_length)
407 mono_raise_exception (mono_get_exception_index_out_of_range ());
409 ves_icall_System_Array_SetValueImpl (this, value, *ind);
413 for (i = 0; i < ac->rank; i++)
414 if ((ind [i] < this->bounds [i].lower_bound) ||
415 (ind [i] >= this->bounds [i].length + this->bounds [i].lower_bound))
416 mono_raise_exception (mono_get_exception_index_out_of_range ());
418 pos = ind [0] - this->bounds [0].lower_bound;
419 for (i = 1; i < ac->rank; i++)
420 pos = pos * this->bounds [i].length + ind [i] -
421 this->bounds [i].lower_bound;
423 ves_icall_System_Array_SetValueImpl (this, value, pos);
427 ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *lengths, MonoArray *bounds)
433 MONO_CHECK_ARG_NULL (type);
434 MONO_CHECK_ARG_NULL (lengths);
436 MONO_CHECK_ARG (lengths, mono_array_length (lengths) > 0);
438 MONO_CHECK_ARG (bounds, mono_array_length (lengths) == mono_array_length (bounds));
440 for (i = 0; i < mono_array_length (lengths); i++)
441 if (mono_array_get (lengths, gint32, i) < 0)
442 mono_raise_exception (mono_get_exception_argument_out_of_range (NULL));
444 aklass = mono_array_class_get (type->type, mono_array_length (lengths));
446 sizes = alloca (aklass->rank * sizeof(guint32) * 2);
447 for (i = 0; i < aklass->rank; ++i) {
448 sizes [i] = mono_array_get (lengths, gint32, i);
450 sizes [i + aklass->rank] = mono_array_get (bounds, gint32, i);
452 sizes [i + aklass->rank] = 0;
455 array = mono_array_new_full (mono_domain_get (), aklass, sizes, sizes + aklass->rank);
461 ves_icall_System_Array_GetRank (MonoObject *this)
463 return this->vtable->klass->rank;
467 ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension)
469 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
470 if ((dimension < 0) || (dimension >= rank))
471 mono_raise_exception (mono_get_exception_index_out_of_range ());
473 if (this->bounds == NULL)
474 return this->max_length;
476 return this->bounds [dimension].length;
480 ves_icall_System_Array_GetLowerBound (MonoArray *this, gint32 dimension)
482 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
483 if ((dimension < 0) || (dimension >= rank))
484 mono_raise_exception (mono_get_exception_index_out_of_range ());
486 if (this->bounds == NULL)
489 return this->bounds [dimension].lower_bound;
493 ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* dest, int dest_idx, int length)
495 int element_size = mono_array_element_size (source->obj.vtable->klass);
496 void * dest_addr = mono_array_addr_with_size (dest, element_size, dest_idx);
497 void * source_addr = mono_array_addr_with_size (source, element_size, source_idx);
499 g_assert (dest_idx + length <= mono_array_length (dest));
500 g_assert (source_idx + length <= mono_array_length (source));
501 memmove (dest_addr, source_addr, element_size * length);
505 ves_icall_InitializeArray (MonoArray *array, MonoClassField *field_handle)
507 MonoClass *klass = array->obj.vtable->klass;
508 guint32 size = mono_array_element_size (klass);
511 if (array->bounds == NULL)
512 size *= array->max_length;
514 for (i = 0; i < klass->rank; ++i)
515 size *= array->bounds [i].length;
517 memcpy (mono_array_addr (array, char, 0), field_handle->data, size);
519 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
523 guint ## n *data = (guint ## n *) mono_array_addr (array, char, 0); \
525 for (i = 0; i < size; i += n/8, data++) { \
526 tmp = read ## n (data); \
531 printf ("Initialize array with elements of %s type\n", klass->element_class->name);
533 switch (klass->element_class->byval_arg.type) {
553 ves_icall_System_Object_MemberwiseClone (MonoObject *this)
555 return mono_object_clone (this);
559 ves_icall_System_Object_GetHashCode (MonoObject *this)
561 return *((gint32 *)this - 1);
565 * A hash function for value types. I have no idea if this is a good hash
566 * function (its similar to g_str_hash).
569 ves_icall_System_ValueType_GetHashCode (MonoObject *this)
575 MONO_CHECK_ARG_NULL (this);
577 size = this->vtable->klass->instance_size - sizeof (MonoObject);
579 p = (const char *)this + sizeof (MonoObject);
581 for (i = 0; i < size; i++) {
582 h = (h << 5) - h + *p;
590 ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that)
595 MONO_CHECK_ARG_NULL (that);
597 if (this->vtable != that->vtable)
600 size = this->vtable->klass->instance_size - sizeof (MonoObject);
602 p = (const char *)this + sizeof (MonoObject);
603 s = (const char *)that + sizeof (MonoObject);
605 return memcmp (p, s, size)? FALSE: TRUE;
608 static MonoReflectionType *
609 ves_icall_System_Object_GetType (MonoObject *obj)
611 return mono_type_get_object (mono_domain_get (), &obj->vtable->klass->byval_arg);
615 mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
617 mtype->type = &obj->vtable->klass->byval_arg;
618 g_assert (mtype->type->type);
622 ves_icall_AssemblyBuilder_getToken (MonoReflectionAssemblyBuilder *assb, MonoObject *obj)
624 return mono_image_create_token (assb->dynamic_assembly, obj);
628 ves_icall_AssemblyBuilder_getPEHeader (MonoReflectionAssemblyBuilder *assb, MonoArray *buf, gint32 *data_size)
631 MonoDynamicAssembly *ass = assb->dynamic_assembly;
633 hsize = mono_image_get_header (assb, (char*)buf->vector, mono_array_length (buf));
636 count = ass->code.index + ass->meta_size;
645 ves_icall_AssemblyBuilder_getDataChunk (MonoReflectionAssemblyBuilder *assb, MonoArray *buf)
647 int count, real_data;
648 MonoDynamicAssembly *ass = assb->dynamic_assembly;
649 char *p = mono_array_addr (buf, char, 0);
651 count = real_data = ass->code.index + ass->meta_size;
654 if (count > mono_array_length (buf))
658 memcpy (p, ass->code.data, ass->code.index);
659 p += ass->code.index;
660 memcpy (p, ass->assembly.image->raw_metadata, ass->meta_size);
662 /* null-pad section */
663 memset (p, 0, count);
665 return real_data + count;
668 static MonoReflectionType*
669 ves_icall_type_from_name (MonoString *name)
671 MonoDomain *domain = mono_domain_get ();
674 MonoTypeNameParse info;
677 str = mono_string_to_utf8 (name);
678 /*g_print ("requested type %s\n", str);*/
679 if (!mono_reflection_parse_type (str, &info)) {
681 g_list_free (info.modifiers);
686 image = mono_image_loaded (info.assembly);
687 /* do we need to load if it's not already loaded? */
690 g_list_free (info.modifiers);
694 image = mono_defaults.corlib;
696 type = mono_reflection_get_type (image, &info, FALSE);
698 g_list_free (info.modifiers);
701 /*g_print ("got it\n");*/
702 return mono_type_get_object (domain, type);
705 static MonoReflectionType*
706 ves_icall_type_from_handle (MonoType *handle)
708 MonoDomain *domain = mono_domain_get ();
709 MonoClass *klass = mono_class_from_mono_type (handle);
711 mono_class_init (klass);
712 return mono_type_get_object (domain, handle);
716 ves_icall_type_Equals (MonoReflectionType *type, MonoReflectionType *c)
718 if (type->type && c->type)
719 return mono_metadata_type_equal (type->type, c->type);
720 g_print ("type equals\n");
725 ves_icall_type_is_subtype_of (MonoReflectionType *type, MonoReflectionType *c, MonoBoolean check_interfaces)
731 g_assert (type != NULL);
733 domain = ((MonoObject *)type)->vtable->domain;
735 if (!c) /* FIXME: dont know what do do here */
738 klass = mono_class_from_mono_type (type->type);
739 klassc = mono_class_from_mono_type (c->type);
741 /* cut&paste from mono_object_isinst (): keep in sync */
742 if (check_interfaces && (klassc->flags & TYPE_ATTRIBUTE_INTERFACE) && !(klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
743 MonoVTable *klass_vt = mono_class_vtable (domain, klass);
744 if ((klassc->interface_id <= klass->max_interface_id) &&
745 klass_vt->interface_offsets [klassc->interface_id])
747 } else if (check_interfaces && (klassc->flags & TYPE_ATTRIBUTE_INTERFACE) && (klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
750 for (i = 0; i < klass->interface_count; i ++) {
751 MonoClass *ic = klass->interfaces [i];
757 * klass->baseval is 0 for interfaces
759 if (klass->baseval && ((klass->baseval - klassc->baseval) <= klassc->diffval))
766 ves_icall_get_attributes (MonoReflectionType *type)
768 MonoClass *klass = mono_class_from_mono_type (type->type);
774 ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info)
776 MonoDomain *domain = mono_domain_get ();
778 info->parent = mono_type_get_object (domain, &method->klass->byval_arg);
779 info->ret = mono_type_get_object (domain, method->signature->ret);
780 info->attrs = method->flags;
781 info->implattrs = method->iflags;
785 ves_icall_get_parameter_info (MonoMethod *method)
787 MonoDomain *domain = mono_domain_get ();
789 static MonoClass *System_Reflection_ParameterInfo;
790 MonoReflectionParameter** args;
793 args = mono_param_get_objects (domain, method);
794 if (!System_Reflection_ParameterInfo)
795 System_Reflection_ParameterInfo = mono_class_from_name (
796 mono_defaults.corlib, "System.Reflection", "ParameterInfo");
797 res = mono_array_new (domain, System_Reflection_ParameterInfo, method->signature->param_count);
798 for (i = 0; i < method->signature->param_count; ++i) {
799 mono_array_set (res, gpointer, i, args [i]);
805 ves_icall_get_field_info (MonoReflectionField *field, MonoFieldInfo *info)
807 MonoDomain *domain = mono_domain_get ();
809 info->parent = mono_type_get_object (domain, &field->klass->byval_arg);
810 info->type = mono_type_get_object (domain, field->field->type);
811 info->name = mono_string_new (domain, field->field->name);
812 info->attrs = field->field->type->attrs;
816 ves_icall_MonoField_GetValue (MonoReflectionField *field, MonoObject *obj) {
819 MonoType *ftype = field->field->type;
820 int type = ftype->type;
824 mono_class_init (field->klass);
825 if (ftype->attrs & FIELD_ATTRIBUTE_STATIC) {
827 vtable = mono_class_vtable (mono_domain_get (), field->klass);
828 p = (char*)(vtable->data) + field->field->offset;
830 p = (char*)obj + field->field->offset;
834 case MONO_TYPE_OBJECT:
835 case MONO_TYPE_STRING:
836 case MONO_TYPE_SZARRAY:
837 case MONO_TYPE_ARRAY:
838 return *(MonoObject**)p;
840 klass = mono_class_from_mono_type (ftype);
841 res = mono_object_new (mono_domain_get (), klass);
842 r = (char*)res + sizeof (MonoObject);
843 memcpy (r, p, mono_class_value_size (klass, &align));
849 ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info)
851 MonoDomain *domain = mono_domain_get ();
853 info->parent = mono_type_get_object (domain, &property->klass->byval_arg);
854 info->name = mono_string_new (domain, property->property->name);
855 info->attrs = property->property->attrs;
856 info->get = property->property->get ? mono_method_get_object (domain, property->property->get): NULL;
857 info->set = property->property->set ? mono_method_get_object (domain, property->property->set): NULL;
859 * There may be other methods defined for properties, though, it seems they are not exposed
860 * in the reflection API
865 ves_icall_Type_GetInterfaces (MonoReflectionType* type)
867 MonoDomain *domain = mono_domain_get ();
870 MonoClass *class = mono_class_from_mono_type (type->type);
874 for (parent = class; parent; parent = parent->parent) {
875 ninterf += parent->interface_count;
877 intf = mono_array_new (domain, mono_defaults.monotype_class, ninterf);
879 for (parent = class; parent; parent = parent->parent) {
880 for (i = 0; i < parent->interface_count; ++i) {
881 mono_array_set (intf, gpointer, ninterf, mono_type_get_object (domain, &parent->interfaces [i]->byval_arg));
888 static MonoReflectionType*
889 ves_icall_MonoType_GetElementType (MonoReflectionType *type)
891 MonoClass *class = mono_class_from_mono_type (type->type);
892 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
893 return mono_type_get_object (mono_object_domain (type), class->enum_basetype);
894 else if (class->element_class)
895 return mono_type_get_object (mono_object_domain (type), &class->element_class->byval_arg);
901 ves_icall_get_type_info (MonoType *type, MonoTypeInfo *info)
903 MonoDomain *domain = mono_domain_get ();
904 MonoClass *class = mono_class_from_mono_type (type);
906 info->parent = class->parent ? mono_type_get_object (domain, &class->parent->byval_arg): NULL;
907 info->name = mono_string_new (domain, class->name);
908 info->name_space = mono_string_new (domain, class->name_space);
909 info->attrs = class->flags;
910 info->rank = class->rank;
911 info->assembly = mono_assembly_get_object (domain, class->image->assembly);
912 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
913 info->etype = mono_type_get_object (domain, class->enum_basetype);
914 else if (class->element_class)
915 info->etype = mono_type_get_object (domain, &class->element_class->byval_arg);
919 info->isbyref = type->byref;
920 info->ispointer = type->type == MONO_TYPE_PTR;
921 info->isprimitive = (type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8);
925 ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params)
927 return mono_runtime_invoke_array (method->method, this, params);
931 ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoArray *params, MonoArray **outArgs)
933 MonoDomain *domain = mono_domain_get ();
934 MonoMethod *m = method->method;
935 MonoMethodSignature *sig = m->signature;
938 int i, j, outarg_count = 0;
940 if (m->klass == mono_defaults.object_class) {
942 if (!strcmp (m->name, "FieldGetter")) {
943 MonoClass *k = this->vtable->klass;
944 MonoString *name = mono_array_get (params, MonoString *, 1);
947 str = mono_string_to_utf8 (name);
949 for (i = 0; i < k->field.count; i++) {
950 if (!strcmp (k->fields [i].name, str)) {
951 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
952 if (field_klass->valuetype)
953 result = mono_value_box (domain, field_klass,
954 (char *)this + k->fields [i].offset);
956 result = *((gpointer *)((char *)this + k->fields [i].offset));
959 out_args = mono_array_new (domain, mono_defaults.object_class, 1);
961 mono_array_set (out_args, gpointer, 0, result);
968 g_assert_not_reached ();
970 } else if (!strcmp (m->name, "FieldSetter")) {
971 MonoClass *k = this->vtable->klass;
972 MonoString *name = mono_array_get (params, MonoString *, 1);
976 str = mono_string_to_utf8 (name);
978 for (i = 0; i < k->field.count; i++) {
979 if (!strcmp (k->fields [i].name, str)) {
980 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
981 MonoObject *val = mono_array_get (params, gpointer, 2);
983 if (field_klass->valuetype) {
984 size = mono_type_size (k->fields [i].type, &align);
985 memcpy ((char *)this + k->fields [i].offset,
986 ((char *)val) + sizeof (MonoObject), size);
988 *((gpointer *)this + k->fields [i].offset) = val;
997 g_assert_not_reached ();
1002 for (i = 0; i < mono_array_length (params); i++) {
1003 if (sig->params [i]->byref)
1007 out_args = mono_array_new (domain, mono_defaults.object_class, outarg_count);
1009 for (i = 0, j = 0; i < mono_array_length (params); i++) {
1010 if (sig->params [i]->byref) {
1012 arg = mono_array_get (params, gpointer, i);
1013 mono_array_set (out_args, gpointer, j, arg);
1018 /* fixme: handle constructors? */
1019 if (!strcmp (method->method->name, ".ctor"))
1020 g_assert_not_reached ();
1022 result = mono_runtime_invoke_array (method->method, this, params);
1024 *outArgs = out_args;
1030 ves_icall_System_Enum_ToObject (MonoReflectionType *type, MonoObject *obj)
1032 MonoDomain *domain = mono_domain_get ();
1033 MonoClass *enumc, *objc;
1037 MONO_CHECK_ARG_NULL (type);
1038 MONO_CHECK_ARG_NULL (obj);
1040 enumc = mono_class_from_mono_type (type->type);
1041 objc = obj->vtable->klass;
1043 MONO_CHECK_ARG (obj, enumc->enumtype == TRUE);
1044 MONO_CHECK_ARG (obj, (objc->enumtype) || (objc->byval_arg.type >= MONO_TYPE_I1 &&
1045 objc->byval_arg.type <= MONO_TYPE_U8));
1047 s1 = mono_class_value_size (enumc, NULL);
1048 s2 = mono_class_value_size (objc, NULL);
1050 res = mono_object_new (domain, enumc);
1052 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1053 memcpy ((char *)res + sizeof (MonoObject), (char *)obj + sizeof (MonoObject), MIN (s1, s2));
1055 memcpy ((char *)res + sizeof (MonoObject) + (s1 > s2 ? s1 - s2 : 0),
1056 (char *)obj + sizeof (MonoObject) + (s2 > s1 ? s2 - s1 : 0),
1063 ves_icall_System_Enum_get_value (MonoObject *this)
1065 MonoDomain *domain = mono_domain_get ();
1075 g_assert (this->vtable->klass->enumtype);
1077 enumc = mono_class_from_mono_type (this->vtable->klass->enum_basetype);
1078 res = mono_object_new (domain, enumc);
1079 dst = (char *)res + sizeof (MonoObject);
1080 src = (char *)this + sizeof (MonoObject);
1081 size = mono_class_value_size (enumc, NULL);
1083 memcpy (dst, src, size);
1089 ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
1091 MonoDomain *domain = mono_domain_get ();
1092 MonoClass *enumc = mono_class_from_mono_type (type->type);
1093 guint i, j, nvalues, crow;
1094 MonoClassField *field;
1096 info->utype = mono_type_get_object (domain, enumc->enum_basetype);
1097 nvalues = enumc->field.count - 1;
1098 info->names = mono_array_new (domain, mono_defaults.string_class, nvalues);
1099 info->values = mono_array_new (domain, enumc, nvalues);
1101 for (i = 0, j = 0; i < enumc->field.count; ++i) {
1102 field = &enumc->fields [i];
1103 if (strcmp ("value__", field->name) == 0)
1105 mono_array_set (info->names, gpointer, j, mono_string_new (domain, field->name));
1107 crow = mono_metadata_get_constant_index (enumc->image, MONO_TOKEN_FIELD_DEF | (i+enumc->field.first+1));
1108 crow = mono_metadata_decode_row_col (&enumc->image->tables [MONO_TABLE_CONSTANT], crow-1, MONO_CONSTANT_VALUE);
1109 /* 1 is the length of the blob */
1110 field->data = 1 + mono_metadata_blob_heap (enumc->image, crow);
1112 switch (enumc->enum_basetype->type) {
1115 mono_array_set (info->values, gchar, j, *field->data);
1117 case MONO_TYPE_CHAR:
1120 mono_array_set (info->values, gint16, j, read16 (field->data));
1124 mono_array_set (info->values, gint32, j, read32 (field->data));
1128 mono_array_set (info->values, gint64, j, read64 (field->data));
1131 g_error ("Implement type 0x%02x in get_enum_info", enumc->enum_basetype->type);
1138 search_method (MonoReflectionType *type, const char *name, guint32 flags, MonoArray *args)
1140 MonoClass *klass, *start_class;
1142 MonoReflectionType *paramt;
1145 start_class = klass = mono_class_from_mono_type (type->type);
1147 for (i = 0; i < klass->method.count; ++i) {
1148 m = klass->methods [i];
1149 if (!((m->flags & flags) == flags))
1151 if (strcmp(m->name, name))
1153 if (m->signature->param_count != mono_array_length (args))
1155 for (j = 0; j < m->signature->param_count; ++j) {
1156 paramt = mono_array_get (args, MonoReflectionType*, j);
1157 if (!mono_metadata_type_equal (paramt->type, m->signature->params [j]))
1160 if (j == m->signature->param_count)
1163 klass = klass->parent;
1165 g_print ("Method %s.%s::%s (%d) not found\n", start_class->name_space, start_class->name, name, mono_array_length (args));
1169 static MonoReflectionMethod*
1170 ves_icall_get_constructor (MonoReflectionType *type, MonoArray *args)
1172 MonoDomain *domain = mono_domain_get ();
1175 m = search_method (type, ".ctor", METHOD_ATTRIBUTE_RT_SPECIAL_NAME, args);
1177 return mono_method_get_object (domain, m);
1181 static MonoReflectionMethod*
1182 ves_icall_get_method (MonoReflectionType *type, MonoString *name, MonoArray *args)
1184 MonoDomain *domain = mono_domain_get ();
1186 char *n = mono_string_to_utf8 (name);
1188 m = search_method (type, n, 0, args);
1191 return mono_method_get_object (domain, m);
1195 static MonoProperty*
1196 search_property (MonoClass *klass, char* name, MonoArray *args) {
1200 /* FIXME: handle args */
1201 for (i = 0; i < klass->property.count; ++i) {
1202 p = &klass->properties [i];
1203 if (strcmp (p->name, name) == 0)
1209 static MonoReflectionProperty*
1210 ves_icall_get_property (MonoReflectionType *type, MonoString *name, MonoArray *args)
1212 MonoDomain *domain = mono_domain_get ();
1214 MonoClass *class = mono_class_from_mono_type (type->type);
1215 char *n = mono_string_to_utf8 (name);
1217 p = search_property (class, n, args);
1220 return mono_property_get_object (domain, class, p);
1225 BFLAGS_IgnoreCase = 1,
1226 BFLAGS_DeclaredOnly = 2,
1227 BFLAGS_Instance = 4,
1229 BFLAGS_Public = 0x10,
1230 BFLAGS_NonPublic = 0x20,
1231 BFLAGS_InvokeMethod = 0x100,
1232 BFLAGS_CreateInstance = 0x200,
1233 BFLAGS_GetField = 0x400,
1234 BFLAGS_SetField = 0x800,
1235 BFLAGS_GetProperty = 0x1000,
1236 BFLAGS_SetProperty = 0x2000,
1237 BFLAGS_ExactBinding = 0x10000,
1238 BFLAGS_SuppressChangeType = 0x20000,
1239 BFLAGS_OptionalParamBinding = 0x40000
1243 ves_icall_Type_GetFields (MonoReflectionType *type, guint32 bflags)
1246 GSList *l = NULL, *tmp;
1247 static MonoClass *System_Reflection_FieldInfo;
1248 MonoClass *startklass, *klass;
1252 MonoClassField *field;
1254 domain = ((MonoObject *)type)->vtable->domain;
1255 klass = startklass = mono_class_from_mono_type (type->type);
1258 for (i = 0; i < klass->field.count; ++i) {
1260 field = &klass->fields [i];
1261 if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
1262 if (bflags & BFLAGS_Public)
1265 if (bflags & BFLAGS_NonPublic)
1271 if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1272 if (bflags & BFLAGS_Static)
1275 if (bflags & BFLAGS_Instance)
1281 member = (MonoObject*)mono_field_get_object (domain, klass, field);
1282 l = g_slist_prepend (l, member);
1284 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1286 len = g_slist_length (l);
1287 if (!System_Reflection_FieldInfo)
1288 System_Reflection_FieldInfo = mono_class_from_name (
1289 mono_defaults.corlib, "System.Reflection", "FieldInfo");
1290 res = mono_array_new (domain, System_Reflection_FieldInfo, len);
1292 tmp = g_slist_reverse (l);
1293 for (; tmp; tmp = tmp->next, ++i)
1294 mono_array_set (res, gpointer, i, tmp->data);
1300 ves_icall_Type_GetMethods (MonoReflectionType *type, guint32 bflags)
1303 GSList *l = NULL, *tmp;
1304 static MonoClass *System_Reflection_MethodInfo;
1305 MonoClass *startklass, *klass;
1311 domain = ((MonoObject *)type)->vtable->domain;
1312 klass = startklass = mono_class_from_mono_type (type->type);
1315 for (i = 0; i < klass->method.count; ++i) {
1317 method = klass->methods [i];
1318 if (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0)
1320 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1321 if (bflags & BFLAGS_Public)
1324 if (bflags & BFLAGS_NonPublic)
1330 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1331 if (bflags & BFLAGS_Static)
1334 if (bflags & BFLAGS_Instance)
1341 member = (MonoObject*)mono_method_get_object (domain, method);
1343 l = g_slist_prepend (l, member);
1345 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1347 len = g_slist_length (l);
1348 if (!System_Reflection_MethodInfo)
1349 System_Reflection_MethodInfo = mono_class_from_name (
1350 mono_defaults.corlib, "System.Reflection", "MethodInfo");
1351 res = mono_array_new (domain, System_Reflection_MethodInfo, len);
1354 for (; tmp; tmp = tmp->next, ++i)
1355 mono_array_set (res, gpointer, i, tmp->data);
1362 ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
1365 GSList *l = NULL, *tmp;
1366 static MonoClass *System_Reflection_ConstructorInfo;
1367 MonoClass *startklass, *klass;
1373 domain = ((MonoObject *)type)->vtable->domain;
1374 klass = startklass = mono_class_from_mono_type (type->type);
1377 for (i = 0; i < klass->method.count; ++i) {
1379 method = klass->methods [i];
1380 if (strcmp (method->name, ".ctor") && strcmp (method->name, ".cctor"))
1382 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1383 if (bflags & BFLAGS_Public)
1386 if (bflags & BFLAGS_NonPublic)
1392 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1393 if (bflags & BFLAGS_Static)
1396 if (bflags & BFLAGS_Instance)
1402 member = (MonoObject*)mono_method_get_object (domain, method);
1404 l = g_slist_prepend (l, member);
1406 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1408 len = g_slist_length (l);
1409 if (!System_Reflection_ConstructorInfo)
1410 System_Reflection_ConstructorInfo = mono_class_from_name (
1411 mono_defaults.corlib, "System.Reflection", "ConstructorInfo");
1412 res = mono_array_new (domain, System_Reflection_ConstructorInfo, len);
1415 for (; tmp; tmp = tmp->next, ++i)
1416 mono_array_set (res, gpointer, i, tmp->data);
1422 ves_icall_Type_GetProperties (MonoReflectionType *type, guint32 bflags)
1425 GSList *l = NULL, *tmp;
1426 static MonoClass *System_Reflection_PropertyInfo;
1427 MonoClass *startklass, *klass;
1433 domain = ((MonoObject *)type)->vtable->domain;
1434 klass = startklass = mono_class_from_mono_type (type->type);
1437 for (i = 0; i < klass->property.count; ++i) {
1438 prop = &klass->properties [i];
1443 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1444 if (bflags & BFLAGS_Public)
1447 if (bflags & BFLAGS_NonPublic)
1453 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1454 if (bflags & BFLAGS_Static)
1457 if (bflags & BFLAGS_Instance)
1464 l = g_slist_prepend (l, mono_property_get_object (domain, klass, prop));
1466 if (!l && (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)))
1468 len = g_slist_length (l);
1469 if (!System_Reflection_PropertyInfo)
1470 System_Reflection_PropertyInfo = mono_class_from_name (
1471 mono_defaults.corlib, "System.Reflection", "PropertyInfo");
1472 res = mono_array_new (domain, System_Reflection_PropertyInfo, len);
1475 for (; tmp; tmp = tmp->next, ++i)
1476 mono_array_set (res, gpointer, i, tmp->data);
1482 ves_icall_Type_GetEvents (MonoReflectionType *type, guint32 bflags)
1485 GSList *l = NULL, *tmp;
1486 static MonoClass *System_Reflection_EventInfo;
1487 MonoClass *startklass, *klass;
1493 domain = ((MonoObject *)type)->vtable->domain;
1494 klass = startklass = mono_class_from_mono_type (type->type);
1497 for (i = 0; i < klass->event.count; ++i) {
1498 event = &klass->events [i];
1500 method = event->add;
1502 method = event->remove;
1503 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1504 if (bflags & BFLAGS_Public)
1507 if (bflags & BFLAGS_NonPublic)
1513 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1514 if (bflags & BFLAGS_Static)
1517 if (bflags & BFLAGS_Instance)
1524 l = g_slist_prepend (l, mono_event_get_object (domain, klass, event));
1526 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1528 len = g_slist_length (l);
1529 if (!System_Reflection_EventInfo)
1530 System_Reflection_EventInfo = mono_class_from_name (
1531 mono_defaults.corlib, "System.Reflection", "EventInfo");
1532 res = mono_array_new (domain, System_Reflection_EventInfo, len);
1535 for (; tmp; tmp = tmp->next, ++i)
1536 mono_array_set (res, gpointer, i, tmp->data);
1542 ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags)
1545 GSList *l = NULL, *tmp;
1547 MonoClass *startklass, *klass;
1553 domain = ((MonoObject *)type)->vtable->domain;
1554 klass = startklass = mono_class_from_mono_type (type->type);
1556 for (tmpn = klass->nested_classes; tmpn; tmpn = tmpn->next) {
1558 nested = tmpn->data;
1559 if ((nested->flags & TYPE_ATTRIBUTE_VISIBILITY_MASK) == TYPE_ATTRIBUTE_NESTED_PUBLIC) {
1560 if (bflags & BFLAGS_Public)
1563 if (bflags & BFLAGS_NonPublic)
1568 member = (MonoObject*)mono_type_get_object (domain, &nested->byval_arg);
1569 l = g_slist_prepend (l, member);
1571 len = g_slist_length (l);
1572 res = mono_array_new (domain, mono_defaults.monotype_class, len);
1574 tmp = g_slist_reverse (l);
1575 for (; tmp; tmp = tmp->next, ++i)
1576 mono_array_set (res, gpointer, i, tmp->data);
1582 ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr (gpointer ptr)
1584 return (gpointer)(*(int *)ptr);
1588 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAuto (gpointer ptr)
1590 MonoDomain *domain = mono_domain_get ();
1592 return mono_string_new (domain, (char *)ptr);
1595 static guint32 ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error(void)
1597 return(GetLastError());
1600 static MonoReflectionType*
1601 ves_icall_System_Reflection_Assembly_GetType (MonoReflectionAssembly *assembly, MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase)
1603 MonoDomain *domain = mono_domain_get ();
1606 MonoTypeNameParse info;
1608 str = mono_string_to_utf8 (name);
1609 /*g_print ("requested type %s in %s\n", str, assembly->assembly->name);*/
1610 if (!mono_reflection_parse_type (str, &info)) {
1612 g_list_free (info.modifiers);
1613 if (throwOnError) /* uhm: this is a parse error, though... */
1614 mono_raise_exception (mono_get_exception_type_load ());
1615 /*g_print ("failed parse\n");*/
1619 type = mono_reflection_get_type (assembly->assembly->image, &info, ignoreCase);
1621 g_list_free (info.modifiers);
1624 mono_raise_exception (mono_get_exception_type_load ());
1625 /* g_print ("failed find\n"); */
1628 /* g_print ("got it\n"); */
1629 return mono_type_get_object (domain, type);
1634 ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly *assembly)
1636 MonoDomain *domain = mono_domain_get ();
1638 char *name = g_strconcat (
1639 "file://", assembly->assembly->image->name, NULL);
1641 res = mono_string_new (domain, name);
1647 ves_icall_System_MonoType_getFullName (MonoReflectionType *object)
1649 MonoDomain *domain = mono_domain_get ();
1653 name = mono_type_get_name (object->type);
1654 res = mono_string_new (domain, name);
1661 ves_icall_System_Reflection_Assembly_FillName (MonoReflectionAssembly *assembly, MonoReflectionAssemblyName *aname)
1663 MonoAssemblyName *name = &assembly->assembly->aname;
1665 if (strcmp (name->name, "corlib") == 0)
1666 aname->name = mono_string_new (mono_object_domain (assembly), "mscorlib");
1668 aname->name = mono_string_new (mono_object_domain (assembly), name->name);
1669 aname->major = name->major;
1673 ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly)
1675 MonoDomain *domain = mono_domain_get ();
1678 MonoTableInfo *tdef = &assembly->assembly->image->tables [MONO_TABLE_TYPEDEF];
1680 guint32 attrs, visibility;
1684 for (i = 0; i < tdef->rows; ++i) {
1685 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
1686 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
1687 if (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)
1693 res = mono_array_new (domain, mono_defaults.monotype_class, count);
1695 for (i = 0; i < tdef->rows; ++i) {
1696 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
1697 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
1698 if (!exportedOnly || (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)) {
1699 klass = mono_class_get (assembly->assembly->image, (i + 1) | MONO_TOKEN_TYPE_DEF);
1700 mono_array_set (res, gpointer, count, mono_type_get_object (domain, &klass->byval_arg));
1708 static MonoReflectionType*
1709 ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, MonoString *smodifiers)
1712 int isbyref = 0, rank;
1713 char *str = mono_string_to_utf8 (smodifiers);
1716 klass = mono_class_from_mono_type (tb->type.type);
1718 /* logic taken from mono_reflection_parse_type(): keep in sync */
1722 if (isbyref) { /* only one level allowed by the spec */
1729 return mono_type_get_object (mono_domain_get (), &klass->this_arg);
1732 klass = mono_ptr_class_get (&klass->byval_arg);
1733 mono_class_init (klass);
1744 else if (*p != '*') { /* '*' means unknown lower bound */
1755 klass = mono_array_class_get (&klass->byval_arg, rank);
1756 mono_class_init (klass);
1763 return mono_type_get_object (mono_domain_get (), &klass->byval_arg);
1767 * Magic number to convert a time which is relative to
1768 * Jan 1, 1970 into a value which is relative to Jan 1, 0001.
1770 #define EPOCH_ADJUST ((gint64)62135596800L)
1773 ves_icall_System_DateTime_GetNow (void)
1775 #ifdef PLATFORM_WIN32
1780 SystemTimeToFileTime (&st, &ft);
1781 return (gint64)504911232000000000L + (((gint64)ft.dwHighDateTime)<<32) | ft.dwLowDateTime;
1783 /* FIXME: put this in io-layer and call it GetLocalTime */
1787 if (gettimeofday (&tv, NULL) == 0) {
1788 res = (((gint64)tv.tv_sec + EPOCH_ADJUST)* 1000000 + tv.tv_usec)*10;
1791 /* fixme: raise exception */
1797 * This is heavily based on zdump.c from glibc 2.2.
1799 * * data[0]: start of daylight saving time (in DateTime ticks).
1800 * * data[1]: end of daylight saving time (in DateTime ticks).
1801 * * data[2]: utcoffset (in TimeSpan ticks).
1802 * * data[3]: additional offset when daylight saving (in TimeSpan ticks).
1803 * * name[0]: name of this timezone when not daylight saving.
1804 * * name[1]: name of this timezone when daylight saving.
1806 * FIXME: This only works with "standard" Unix dates (years between 1900 and 2100) while
1807 * the class library allows years between 1 and 9999.
1809 * Returns true on success and zero on failure.
1812 ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names)
1814 #ifndef PLATFORM_WIN32
1815 MonoDomain *domain = mono_domain_get ();
1816 struct tm start, tt;
1820 int is_daylight = 0, day;
1822 memset (&start, 0, sizeof (start));
1825 start.tm_year = year-1900;
1827 t = mktime (&start);
1828 #if defined (HAVE_TIMEZONE)
1829 #define gmt_offset(x) (-1 * (((timezone / 60 / 60) - daylight) * 100))
1830 #elif defined (HAVE_TM_GMTOFF)
1831 #define gmt_offset(x) x.tm_gmtoff
1833 #error Neither HAVE_TIMEZONE nor HAVE_TM_GMTOFF defined. Rerun autoheader, autoconf, etc.
1836 gmtoff = gmt_offset (start);
1838 MONO_CHECK_ARG_NULL (data);
1839 MONO_CHECK_ARG_NULL (names);
1841 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
1842 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
1844 /* For each day of the year, calculate the tm_gmtoff. */
1845 for (day = 0; day < 365; day++) {
1848 tt = *localtime (&t);
1850 /* Daylight saving starts or ends here. */
1851 if (gmt_offset (tt) != gmtoff) {
1856 /* Try to find the exact hour when daylight saving starts/ends. */
1860 tt1 = *localtime (&t1);
1861 } while (gmt_offset (tt1) != gmtoff);
1863 /* Try to find the exact minute when daylight saving starts/ends. */
1866 tt1 = *localtime (&t1);
1867 } while (gmt_offset (tt1) == gmtoff);
1869 strftime (tzone, 10, "%Z", &tt);
1871 /* Write data, if we're already in daylight saving, we're done. */
1873 mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tzone));
1874 mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
1877 mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tzone));
1878 mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
1882 /* This is only set once when we enter daylight saving. */
1883 mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L);
1884 mono_array_set ((*data), gint64, 3, (gint64)(gmt_offset (tt) - gmtoff) * 10000000L);
1886 gmtoff = gmt_offset (tt);
1889 gmtoff = gmt_offset (tt);
1893 MonoDomain *domain = mono_domain_get ();
1894 TIME_ZONE_INFORMATION tz_info;
1898 GetTimeZoneInformation (&tz_info);
1900 MONO_CHECK_ARG_NULL (data);
1901 MONO_CHECK_ARG_NULL (names);
1903 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
1904 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
1906 for (i = 0; i < 32; ++i)
1907 if (!tz_info.DaylightName [i])
1909 mono_array_set ((*names), gpointer, 1, mono_string_new_utf16 (domain, tz_info.DaylightName, i));
1910 for (i = 0; i < 32; ++i)
1911 if (!tz_info.StandardName [i])
1913 mono_array_set ((*names), gpointer, 0, mono_string_new_utf16 (domain, tz_info.StandardName, i));
1915 SystemTimeToFileTime (&tz_info.StandardDate, &ft);
1916 mono_array_set ((*data), gint64, 1, ((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime);
1917 SystemTimeToFileTime (&tz_info.DaylightDate, &ft);
1918 mono_array_set ((*data), gint64, 0, ((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime);
1919 mono_array_set ((*data), gint64, 3, tz_info.Bias + tz_info.StandardBias);
1920 mono_array_set ((*data), gint64, 2, tz_info.Bias + tz_info.DaylightBias);
1927 ves_icall_System_Object_obj_address (MonoObject *this) {
1934 ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array) {
1940 klass = array->obj.vtable->klass;
1941 etype = klass->element_class->byval_arg.type;
1942 if (etype < MONO_TYPE_BOOLEAN || etype > MONO_TYPE_R8)
1945 if (array->bounds == NULL)
1946 length = array->max_length;
1949 for (i = 0; i < klass->rank; ++ i)
1950 length += array->bounds [i].length;
1953 esize = mono_array_element_size (klass);
1954 return length * esize;
1958 ves_icall_System_Buffer_GetByteInternal (MonoArray *array, gint32 idx) {
1959 return mono_array_get (array, gint8, idx);
1963 ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 value) {
1964 mono_array_set (array, gint8, idx, value);
1968 ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count) {
1969 char *src_buf, *dest_buf;
1971 src_buf = (gint8 *)src->vector + src_offset;
1972 dest_buf = (gint8 *)dest->vector + dest_offset;
1974 memcpy (dest_buf, src_buf, count);
1978 ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this)
1980 MonoDomain *domain = mono_domain_get ();
1982 MonoRealProxy *rp = ((MonoRealProxy *)this);
1986 res = mono_object_new (domain, mono_defaults.transparent_proxy_class);
1988 ((MonoTransparentProxy *)res)->rp = rp;
1989 type = ((MonoReflectionType *)rp->class_to_proxy)->type;
1990 klass = mono_class_from_mono_type (type);
1992 ((MonoTransparentProxy *)res)->klass = klass;
1994 res->vtable = mono_class_proxy_vtable (domain, klass);
1999 /* System.Environment */
2002 ves_icall_System_Environment_get_MachineName (void)
2004 #if defined (PLATFORM_WIN32)
2009 len = MAX_COMPUTERNAME_LENGTH + 1;
2010 buf = g_new (gunichar2, len);
2013 if (GetComputerName (buf, &len))
2014 result = mono_string_new_utf16 (mono_domain_get (), buf, len);
2024 buf = g_new (gchar, len);
2027 if (gethostname (buf, len) != 0)
2028 result = mono_string_new (mono_domain_get (), buf);
2036 ves_icall_System_Environment_get_NewLine (void)
2038 #if defined (PLATFORM_WIN32)
2039 return mono_string_new (mono_domain_get (), "\r\n");
2041 return mono_string_new (mono_domain_get (), "\n");
2046 ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
2054 utf8_name = mono_string_to_utf8 (name); /* FIXME: this should be ascii */
2055 value = g_getenv (utf8_name);
2061 return mono_string_new (mono_domain_get (), value);
2065 * There is no standard way to get at environ.
2067 extern char **environ;
2070 ves_icall_System_Environment_GetEnvironmentVariableNames (void)
2079 for (e = environ; *e != 0; ++ e)
2082 domain = mono_domain_get ();
2083 names = mono_array_new (domain, mono_defaults.string_class, n);
2086 for (e = environ; *e != 0; ++ e) {
2087 parts = g_strsplit (*e, "=", 2);
2089 str = mono_string_new (domain, *parts);
2090 mono_array_set (names, MonoString *, n, str);
2102 ves_icall_System_Environment_Exit (int result)
2104 /* we may need to do some cleanup here... */
2109 ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this,
2110 MonoReflectionMethod *method,
2111 MonoArray *out_args)
2113 MonoDomain *domain = mono_domain_get ();
2115 mono_message_init (domain, this, method, out_args);
2119 ves_icall_IsTransparentProxy (MonoObject *proxy)
2124 if (proxy->vtable->klass == mono_defaults.transparent_proxy_class)
2133 static gconstpointer icall_map [] = {
2137 "System.Array::GetValue", ves_icall_System_Array_GetValue,
2138 "System.Array::SetValue", ves_icall_System_Array_SetValue,
2139 "System.Array::GetValueImpl", ves_icall_System_Array_GetValueImpl,
2140 "System.Array::SetValueImpl", ves_icall_System_Array_SetValueImpl,
2141 "System.Array::GetRank", ves_icall_System_Array_GetRank,
2142 "System.Array::GetLength", ves_icall_System_Array_GetLength,
2143 "System.Array::GetLowerBound", ves_icall_System_Array_GetLowerBound,
2144 "System.Array::CreateInstanceImpl", ves_icall_System_Array_CreateInstanceImpl,
2145 "System.Array::FastCopy", ves_icall_System_Array_FastCopy,
2146 "System.Array::Clone", mono_array_clone,
2151 "System.Object::MemberwiseClone", ves_icall_System_Object_MemberwiseClone,
2152 "System.Object::GetType", ves_icall_System_Object_GetType,
2153 "System.Object::GetHashCode", ves_icall_System_Object_GetHashCode,
2154 "System.Object::obj_address", ves_icall_System_Object_obj_address,
2159 "System.ValueType::GetHashCode", ves_icall_System_ValueType_GetHashCode,
2160 "System.ValueType::Equals", ves_icall_System_ValueType_Equals,
2166 "System.String::.ctor(char*)", ves_icall_System_String_ctor_charp,
2167 "System.String::.ctor(char*,uint,uint)", ves_icall_System_String_ctor_charp_int_int,
2168 "System.String::.ctor(sbyte*)", ves_icall_System_String_ctor_sbytep,
2169 "System.String::.ctor(sbyte*,uint,uint)", ves_icall_System_String_ctor_sbytep_int_int,
2170 "System.String::.ctor(sbyte*,uint,uint,System.Text.Encoding)", ves_icall_System_String_ctor_encoding,
2171 "System.String::.ctor(char[])", ves_icall_System_String_ctor_chara,
2172 "System.String::.ctor(char[],uint,uint)", ves_icall_System_String_ctor_chara_int_int,
2173 "System.String::.ctor(char,uint)", ves_icall_System_String_ctor_char_int,
2174 "System.String::InternalEquals", ves_icall_System_String_InternalEquals,
2175 "System.String::InternalJoin", ves_icall_System_String_InternalJoin,
2176 "System.String::InternalInsert", ves_icall_System_String_InternalInsert,
2177 "System.String::InternalReplace(char,char)", ves_icall_System_String_InternalReplace_Char,
2178 "System.String::InternalReplace(string,string)", ves_icall_System_String_InternalReplace_Str,
2179 "System.String::InternalRemove", ves_icall_System_String_InternalRemove,
2180 "System.String::InternalCopyTo", ves_icall_System_String_InternalCopyTo,
2181 "System.String::InternalSplit", ves_icall_System_String_InternalSplit,
2182 "System.String::InternalTrim", ves_icall_System_String_InternalTrim,
2183 "System.String::InternalIndexOf(char,uint,uint)", ves_icall_System_String_InternalIndexOf_Char,
2184 "System.String::InternalIndexOf(string,uint,uint)", ves_icall_System_String_InternalIndexOf_Str,
2185 "System.String::InternalIndexOfAny", ves_icall_System_String_InternalIndexOfAny,
2186 "System.String::InternalLastIndexOf(char,uint,uint)", ves_icall_System_String_InternalLastIndexOf_Char,
2187 "System.String::InternalLastIndexOf(string,uint,uint)", ves_icall_System_String_InternalLastIndexOf_Str,
2188 "System.String::InternalLastIndexOfAny", ves_icall_System_String_InternalLastIndexOfAny,
2189 "System.String::InternalPad", ves_icall_System_String_InternalPad,
2190 "System.String::InternalToLower", ves_icall_System_String_InternalToLower,
2191 "System.String::InternalToUpper", ves_icall_System_String_InternalToUpper,
2192 "System.String::InternalAllocateStr", ves_icall_System_String_InternalAllocateStr,
2193 "System.String::InternalStrcpy(string,uint,string)", ves_icall_System_String_InternalStrcpy_Str,
2194 "System.String::InternalStrcpy(string,uint,string,uint,uint)", ves_icall_System_String_InternalStrcpy_StrN,
2195 "System.String::InternalIntern", ves_icall_System_String_InternalIntern,
2196 "System.String::InternalIsInterned", ves_icall_System_String_InternalIsInterned,
2197 "System.String::InternalCompare(string,uint,string,uint,uint,bool)", ves_icall_System_String_InternalCompareStr_N,
2198 "System.String::GetHashCode", ves_icall_System_String_GetHashCode,
2199 "System.String::get_Chars", ves_icall_System_String_get_Chars,
2204 "System.AppDomain::createDomain", ves_icall_System_AppDomain_createDomain,
2205 "System.AppDomain::getCurDomain", ves_icall_System_AppDomain_getCurDomain,
2206 "System.AppDomain::GetData", ves_icall_System_AppDomain_GetData,
2207 "System.AppDomain::SetData", ves_icall_System_AppDomain_SetData,
2208 "System.AppDomain::getSetup", ves_icall_System_AppDomain_getSetup,
2209 "System.AppDomain::getFriendlyName", ves_icall_System_AppDomain_getFriendlyName,
2210 "System.AppDomain::GetAssemblies", ves_icall_System_AppDomain_GetAssemblies,
2211 "System.AppDomain::LoadAssembly", ves_icall_System_AppDomain_LoadAssembly,
2212 "System.AppDomain::Unload", ves_icall_System_AppDomain_Unload,
2213 "System.AppDomain::ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly,
2216 * System.AppDomainSetup
2218 "System.AppDomainSetup::InitAppDomainSetup", ves_icall_System_AppDomainSetup_InitAppDomainSetup,
2223 "System.Double::ToStringImpl", mono_double_ToStringImpl,
2228 "System.Single::ToStringImpl", mono_float_ToStringImpl,
2233 "System.Decimal::decimal2UInt64", mono_decimal2UInt64,
2234 "System.Decimal::decimal2Int64", mono_decimal2Int64,
2235 "System.Decimal::double2decimal", mono_double2decimal, /* FIXME: wrong signature. */
2236 "System.Decimal::decimalIncr", mono_decimalIncr,
2237 "System.Decimal::decimalSetExponent", mono_decimalSetExponent,
2238 "System.Decimal::decimal2double", mono_decimal2double,
2239 "System.Decimal::decimalFloorAndTrunc", mono_decimalFloorAndTrunc,
2240 "System.Decimal::decimalRound", mono_decimalRound,
2241 "System.Decimal::decimalMult", mono_decimalMult,
2242 "System.Decimal::decimalDiv", mono_decimalDiv,
2243 "System.Decimal::decimalIntDiv", mono_decimalIntDiv,
2244 "System.Decimal::decimalCompare", mono_decimalCompare,
2245 "System.Decimal::string2decimal", mono_string2decimal,
2246 "System.Decimal::decimal2string", mono_decimal2string,
2251 "System.Reflection.Emit.ModuleBuilder::create_modified_type", ves_icall_ModuleBuilder_create_modified_type,
2256 "System.Reflection.Emit.AssemblyBuilder::getDataChunk", ves_icall_AssemblyBuilder_getDataChunk,
2257 "System.Reflection.Emit.AssemblyBuilder::getPEHeader", ves_icall_AssemblyBuilder_getPEHeader,
2258 "System.Reflection.Emit.AssemblyBuilder::getUSIndex", mono_image_insert_string,
2259 "System.Reflection.Emit.AssemblyBuilder::getToken", ves_icall_AssemblyBuilder_getToken,
2260 "System.Reflection.Emit.AssemblyBuilder::basic_init", mono_image_basic_init,
2265 "System.Reflection.MonoMethodInfo::get_method_info", ves_icall_get_method_info,
2266 "System.Reflection.MonoMethodInfo::get_parameter_info", ves_icall_get_parameter_info,
2267 "System.Reflection.MonoFieldInfo::get_field_info", ves_icall_get_field_info,
2268 "System.Reflection.MonoPropertyInfo::get_property_info", ves_icall_get_property_info,
2269 "System.Reflection.MonoMethod::InternalInvoke", ves_icall_InternalInvoke,
2270 "System.Reflection.MonoCMethod::InternalInvoke", ves_icall_InternalInvoke,
2271 "System.MonoCustomAttrs::GetCustomAttributes", mono_reflection_get_custom_attrs,
2272 "System.Reflection.Emit.CustomAttributeBuilder::GetBlob", mono_reflection_get_custom_attrs_blob,
2273 "System.Reflection.MonoField::GetValue", ves_icall_MonoField_GetValue,
2274 "System.Reflection.Emit.SignatureHelper::get_signature_local", mono_reflection_sighelper_get_signature_local,
2275 "System.Reflection.Emit.SignatureHelper::get_signature_field", mono_reflection_sighelper_get_signature_field,
2280 "System.MonoEnumInfo::get_enum_info", ves_icall_get_enum_info,
2281 "System.Enum::get_value", ves_icall_System_Enum_get_value,
2282 "System.Enum::ToObject", ves_icall_System_Enum_ToObject,
2287 "System.Reflection.Emit.TypeBuilder::setup_internal_class", mono_reflection_setup_internal_class,
2297 "System.Type::internal_from_name", ves_icall_type_from_name,
2298 "System.Type::internal_from_handle", ves_icall_type_from_handle,
2299 "System.Type::get_constructor", ves_icall_get_constructor,
2300 "System.Type::get_property", ves_icall_get_property,
2301 "System.Type::get_method", ves_icall_get_method,
2302 "System.MonoType::get_attributes", ves_icall_get_attributes,
2303 "System.Type::type_is_subtype_of", ves_icall_type_is_subtype_of,
2304 "System.Type::Equals", ves_icall_type_Equals,
2307 * System.Runtime.CompilerServices.RuntimeHelpers
2309 "System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray", ves_icall_InitializeArray,
2314 "System.Threading.Thread::Thread_internal", ves_icall_System_Threading_Thread_Thread_internal,
2315 "System.Threading.Thread::Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal,
2316 "System.Threading.Thread::Start_internal", ves_icall_System_Threading_Thread_Start_internal,
2317 "System.Threading.Thread::Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal,
2318 "System.Threading.Thread::CurrentThread_internal", ves_icall_System_Threading_Thread_CurrentThread_internal,
2319 "System.Threading.Thread::CurrentThreadDomain_internal", ves_icall_System_Threading_Thread_CurrentThreadDomain_internal,
2320 "System.Threading.Thread::Join_internal", ves_icall_System_Threading_Thread_Join_internal,
2321 "System.Threading.Thread::SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup,
2322 "System.Threading.Thread::SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store,
2323 "System.Threading.Monitor::Monitor_exit", ves_icall_System_Threading_Monitor_Monitor_exit,
2324 "System.Threading.Monitor::Monitor_test_owner", ves_icall_System_Threading_Monitor_Monitor_test_owner,
2325 "System.Threading.Monitor::Monitor_test_synchronised", ves_icall_System_Threading_Monitor_Monitor_test_synchronised,
2326 "System.Threading.Monitor::Monitor_pulse", ves_icall_System_Threading_Monitor_Monitor_pulse,
2327 "System.Threading.Monitor::Monitor_pulse_all", ves_icall_System_Threading_Monitor_Monitor_pulse_all,
2328 "System.Threading.Monitor::Monitor_try_enter", ves_icall_System_Threading_Monitor_Monitor_try_enter,
2329 "System.Threading.Monitor::Monitor_wait", ves_icall_System_Threading_Monitor_Monitor_wait,
2330 "System.Threading.Mutex::CreateMutex_internal", ves_icall_System_Threading_Mutex_CreateMutex_internal,
2331 "System.Threading.Mutex::ReleaseMutex_internal", ves_icall_System_Threading_Mutex_ReleaseMutex_internal,
2332 "System.Threading.NativeEventCalls::CreateEvent_internal", ves_icall_System_Threading_Events_CreateEvent_internal,
2333 "System.Threading.NativeEventCalls::SetEvent_internal", ves_icall_System_Threading_Events_SetEvent_internal,
2334 "System.Threading.NativeEventCalls::ResetEvent_internal", ves_icall_System_Threading_Events_ResetEvent_internal,
2337 * System.Threading.WaitHandle
2339 "System.Threading.WaitHandle::WaitAll_internal", ves_icall_System_Threading_WaitHandle_WaitAll_internal,
2340 "System.Threading.WaitHandle::WaitAny_internal", ves_icall_System_Threading_WaitHandle_WaitAny_internal,
2341 "System.Threading.WaitHandle::WaitOne_internal", ves_icall_System_Threading_WaitHandle_WaitOne_internal,
2343 "System.Runtime.InteropServices.Marshal::ReadIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr,
2344 "System.Runtime.InteropServices.Marshal::PtrToStringAuto", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAuto,
2345 "System.Runtime.InteropServices.Marshal::GetLastWin32Error", ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error,
2347 "System.Reflection.Assembly::LoadFrom", ves_icall_System_Reflection_Assembly_LoadFrom,
2348 "System.Reflection.Assembly::GetType", ves_icall_System_Reflection_Assembly_GetType,
2349 "System.Reflection.Assembly::GetTypes", ves_icall_System_Reflection_Assembly_GetTypes,
2350 "System.Reflection.Assembly::FillName", ves_icall_System_Reflection_Assembly_FillName,
2351 "System.Reflection.Assembly::get_code_base", ves_icall_System_Reflection_Assembly_get_code_base,
2356 "System.MonoType::getFullName", ves_icall_System_MonoType_getFullName,
2357 "System.MonoType::type_from_obj", mono_type_type_from_obj,
2358 "System.MonoType::GetElementType", ves_icall_MonoType_GetElementType,
2359 "System.MonoType::get_type_info", ves_icall_get_type_info,
2360 "System.MonoType::GetFields", ves_icall_Type_GetFields,
2361 "System.MonoType::GetMethods", ves_icall_Type_GetMethods,
2362 "System.MonoType::GetConstructors", ves_icall_Type_GetConstructors,
2363 "System.MonoType::GetProperties", ves_icall_Type_GetProperties,
2364 "System.MonoType::GetEvents", ves_icall_Type_GetEvents,
2365 "System.MonoType::GetInterfaces", ves_icall_Type_GetInterfaces,
2366 "System.MonoType::GetNestedTypes", ves_icall_Type_GetNestedTypes,
2369 * System.Net.Sockets I/O Services
2371 "System.Net.Sockets.Socket::Socket_internal", ves_icall_System_Net_Sockets_Socket_Socket_internal,
2372 "System.Net.Sockets.Socket::Close_internal", ves_icall_System_Net_Sockets_Socket_Close_internal,
2373 "System.Net.Sockets.SocketException::WSAGetLastError_internal", ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal,
2374 "System.Net.Sockets.Socket::Available_internal", ves_icall_System_Net_Sockets_Socket_Available_internal,
2375 "System.Net.Sockets.Socket::Blocking_internal", ves_icall_System_Net_Sockets_Socket_Blocking_internal,
2376 "System.Net.Sockets.Socket::Accept_internal", ves_icall_System_Net_Sockets_Socket_Accept_internal,
2377 "System.Net.Sockets.Socket::Listen_internal", ves_icall_System_Net_Sockets_Socket_Listen_internal,
2378 "System.Net.Sockets.Socket::LocalEndPoint_internal", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal,
2379 "System.Net.Sockets.Socket::RemoteEndPoint_internal", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal,
2380 "System.Net.Sockets.Socket::Bind_internal", ves_icall_System_Net_Sockets_Socket_Bind_internal,
2381 "System.Net.Sockets.Socket::Connect_internal", ves_icall_System_Net_Sockets_Socket_Connect_internal,
2382 "System.Net.Sockets.Socket::Receive_internal", ves_icall_System_Net_Sockets_Socket_Receive_internal,
2383 "System.Net.Sockets.Socket::RecvFrom_internal", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal,
2384 "System.Net.Sockets.Socket::Send_internal", ves_icall_System_Net_Sockets_Socket_Send_internal,
2385 "System.Net.Sockets.Socket::SendTo_internal", ves_icall_System_Net_Sockets_Socket_SendTo_internal,
2386 "System.Net.Sockets.Socket::Select_internal", ves_icall_System_Net_Sockets_Socket_Select_internal,
2387 "System.Net.Sockets.Socket::Shutdown_internal", ves_icall_System_Net_Sockets_Socket_Shutdown_internal,
2388 "System.Net.Sockets.Socket::GetSocketOption_obj_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal,
2389 "System.Net.Sockets.Socket::GetSocketOption_arr_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal,
2390 "System.Net.Sockets.Socket::SetSocketOption_internal", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal,
2391 "System.Net.Dns::GetHostByName_internal", ves_icall_System_Net_Dns_GetHostByName_internal,
2392 "System.Net.Dns::GetHostByAddr_internal", ves_icall_System_Net_Dns_GetHostByAddr_internal,
2397 "System.Char::GetNumericValue", ves_icall_System_Char_GetNumericValue,
2398 "System.Char::GetUnicodeCategory", ves_icall_System_Char_GetUnicodeCategory,
2399 "System.Char::IsControl", ves_icall_System_Char_IsControl,
2400 "System.Char::IsDigit", ves_icall_System_Char_IsDigit,
2401 "System.Char::IsLetter", ves_icall_System_Char_IsLetter,
2402 "System.Char::IsLower", ves_icall_System_Char_IsLower,
2403 "System.Char::IsUpper", ves_icall_System_Char_IsUpper,
2404 "System.Char::IsNumber", ves_icall_System_Char_IsNumber,
2405 "System.Char::IsPunctuation", ves_icall_System_Char_IsPunctuation,
2406 "System.Char::IsSeparator", ves_icall_System_Char_IsSeparator,
2407 "System.Char::IsSurrogate", ves_icall_System_Char_IsSurrogate,
2408 "System.Char::IsSymbol", ves_icall_System_Char_IsSymbol,
2409 "System.Char::IsWhiteSpace", ves_icall_System_Char_IsWhiteSpace,
2410 "System.Char::ToLower", ves_icall_System_Char_ToLower,
2411 "System.Char::ToUpper", ves_icall_System_Char_ToUpper,
2413 "System.Text.Encoding::IConvNewEncoder", ves_icall_iconv_new_encoder,
2414 "System.Text.Encoding::IConvNewDecoder", ves_icall_iconv_new_decoder,
2415 "System.Text.Encoding::IConvReset", ves_icall_iconv_reset,
2416 "System.Text.Encoding::IConvGetByteCount", ves_icall_iconv_get_byte_count,
2417 "System.Text.Encoding::IConvGetBytes", ves_icall_iconv_get_bytes,
2418 "System.Text.Encoding::IConvGetCharCount", ves_icall_iconv_get_char_count,
2419 "System.Text.Encoding::IConvGetChars", ves_icall_iconv_get_chars,
2421 "System.DateTime::GetNow", ves_icall_System_DateTime_GetNow,
2422 "System.CurrentTimeZone::GetTimeZoneData", ves_icall_System_CurrentTimeZone_GetTimeZoneData,
2427 "System.GC::InternalCollect", ves_icall_System_GC_InternalCollect,
2428 "System.GC::GetTotalMemory", ves_icall_System_GC_GetTotalMemory,
2429 "System.GC::KeepAlive", ves_icall_System_GC_KeepAlive,
2430 "System.GC::ReRegisterForFinalize", ves_icall_System_GC_ReRegisterForFinalize,
2431 "System.GC::SuppressFinalize", ves_icall_System_GC_SuppressFinalize,
2432 "System.GC::WaitForPendingFinalizers", ves_icall_System_GC_WaitForPendingFinalizers,
2435 * System.Security.Cryptography calls
2438 "System.Security.Cryptography.RNGCryptoServiceProvider::GetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_GetBytes,
2439 "System.Security.Cryptography.RNGCryptoServiceProvider::GetNonZeroBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_GetNonZeroBytes,
2444 "System.Buffer::ByteLengthInternal", ves_icall_System_Buffer_ByteLengthInternal,
2445 "System.Buffer::GetByteInternal", ves_icall_System_Buffer_GetByteInternal,
2446 "System.Buffer::SetByteInternal", ves_icall_System_Buffer_SetByteInternal,
2447 "System.Buffer::BlockCopyInternal", ves_icall_System_Buffer_BlockCopyInternal,
2452 "System.IO.MonoIO::GetLastError", ves_icall_System_IO_MonoIO_GetLastError,
2453 "System.IO.MonoIO::CreateDirectory", ves_icall_System_IO_MonoIO_CreateDirectory,
2454 "System.IO.MonoIO::RemoveDirectory", ves_icall_System_IO_MonoIO_RemoveDirectory,
2455 "System.IO.MonoIO::FindFirstFile", ves_icall_System_IO_MonoIO_FindFirstFile,
2456 "System.IO.MonoIO::FindNextFile", ves_icall_System_IO_MonoIO_FindNextFile,
2457 "System.IO.MonoIO::FindClose", ves_icall_System_IO_MonoIO_FindClose,
2458 "System.IO.MonoIO::GetCurrentDirectory", ves_icall_System_IO_MonoIO_GetCurrentDirectory,
2459 "System.IO.MonoIO::SetCurrentDirectory", ves_icall_System_IO_MonoIO_SetCurrentDirectory,
2460 "System.IO.MonoIO::MoveFile", ves_icall_System_IO_MonoIO_MoveFile,
2461 "System.IO.MonoIO::CopyFile", ves_icall_System_IO_MonoIO_CopyFile,
2462 "System.IO.MonoIO::DeleteFile", ves_icall_System_IO_MonoIO_DeleteFile,
2463 "System.IO.MonoIO::GetFileAttributes", ves_icall_System_IO_MonoIO_GetFileAttributes,
2464 "System.IO.MonoIO::SetFileAttributes", ves_icall_System_IO_MonoIO_SetFileAttributes,
2465 "System.IO.MonoIO::GetFileStat", ves_icall_System_IO_MonoIO_GetFileStat,
2466 "System.IO.MonoIO::Open", ves_icall_System_IO_MonoIO_Open,
2467 "System.IO.MonoIO::Close", ves_icall_System_IO_MonoIO_Close,
2468 "System.IO.MonoIO::Read", ves_icall_System_IO_MonoIO_Read,
2469 "System.IO.MonoIO::Write", ves_icall_System_IO_MonoIO_Write,
2470 "System.IO.MonoIO::Seek", ves_icall_System_IO_MonoIO_Seek,
2471 "System.IO.MonoIO::GetLength", ves_icall_System_IO_MonoIO_GetLength,
2472 "System.IO.MonoIO::SetLength", ves_icall_System_IO_MonoIO_SetLength,
2473 "System.IO.MonoIO::SetFileTime", ves_icall_System_IO_MonoIO_SetFileTime,
2474 "System.IO.MonoIO::Flush", ves_icall_System_IO_MonoIO_Flush,
2475 "System.IO.MonoIO::get_ConsoleOutput", ves_icall_System_IO_MonoIO_get_ConsoleOutput,
2476 "System.IO.MonoIO::get_ConsoleInput", ves_icall_System_IO_MonoIO_get_ConsoleInput,
2477 "System.IO.MonoIO::get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError,
2478 "System.IO.MonoIO::get_VolumeSeparatorChar", ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar,
2479 "System.IO.MonoIO::get_DirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar,
2480 "System.IO.MonoIO::get_AltDirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar,
2481 "System.IO.MonoIO::get_PathSeparator", ves_icall_System_IO_MonoIO_get_PathSeparator,
2482 "System.IO.MonoIO::get_InvalidPathChars", ves_icall_System_IO_MonoIO_get_InvalidPathChars,
2487 "System.Math::Sin", ves_icall_System_Math_Sin,
2488 "System.Math::Cos", ves_icall_System_Math_Cos,
2489 "System.Math::Tan", ves_icall_System_Math_Tan,
2490 "System.Math::Sinh", ves_icall_System_Math_Sinh,
2491 "System.Math::Cosh", ves_icall_System_Math_Cosh,
2492 "System.Math::Tanh", ves_icall_System_Math_Tanh,
2493 "System.Math::Acos", ves_icall_System_Math_Acos,
2494 "System.Math::Asin", ves_icall_System_Math_Asin,
2495 "System.Math::Atan", ves_icall_System_Math_Atan,
2496 "System.Math::Atan2", ves_icall_System_Math_Atan2,
2497 "System.Math::Exp", ves_icall_System_Math_Exp,
2498 "System.Math::Log", ves_icall_System_Math_Log,
2499 "System.Math::Log10", ves_icall_System_Math_Log10,
2500 "System.Math::Pow", ves_icall_System_Math_Pow,
2501 "System.Math::Sqrt", ves_icall_System_Math_Sqrt,
2504 * System.Environment
2506 "System.Environment::get_MachineName", ves_icall_System_Environment_get_MachineName,
2507 "System.Environment::get_NewLine", ves_icall_System_Environment_get_NewLine,
2508 "System.Environment::GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable,
2509 "System.Environment::GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames,
2510 "System.Environment::GetCommandLineArgs", mono_runtime_get_main_args,
2511 "System.Environment::Exit", ves_icall_System_Environment_Exit,
2514 * Mono.CSharp.Debugger
2516 "Mono.CSharp.Debugger.MonoSymbolWriter::get_local_type_from_sig",
2517 ves_icall_Debugger_MonoSymbolWriter_get_local_type_from_sig,
2518 "Mono.CSharp.Debugger.MonoSymbolWriter::get_method",
2519 ves_icall_Debugger_MonoSymbolWriter_method_from_token,
2520 "Mono.CSharp.Debugger.DwarfFileWriter::get_type_token",
2521 ves_icall_Debugger_DwarfFileWriter_get_type_token,
2525 * System.Runtime.Remoting
2527 "System.Runtime.Remoting.RemotingServices::InternalExecute",
2528 ves_icall_InternalExecute,
2529 "System.Runtime.Remoting.RemotingServices::IsTransparentProxy",
2530 ves_icall_IsTransparentProxy,
2533 * System.Runtime.Remoting.Messaging
2535 "System.Runtime.Remoting.Messaging.MonoMethodMessage::InitMessage",
2536 ves_icall_MonoMethodMessage_InitMessage,
2539 * System.Runtime.Remoting.Proxies
2541 "System.Runtime.Remoting.Proxies.RealProxy::GetTransparentProxy",
2542 ves_icall_Remoting_RealProxy_GetTransparentProxy,
2545 * System.Threading.Interlocked
2547 "System.Threading.Interlocked::Increment(uint&)", ves_icall_System_Threading_Interlocked_Increment_Int,
2548 "System.Threading.Interlocked::Increment(long&)", ves_icall_System_Threading_Interlocked_Increment_Long,
2549 "System.Threading.Interlocked::Decrement(uint&)", ves_icall_System_Threading_Interlocked_Decrement_Int,
2550 "System.Threading.Interlocked::Decrement(long&)", ves_icall_System_Threading_Interlocked_Decrement_Long,
2551 "System.Threading.Interlocked::CompareExchange(uint&,uint,uint)", ves_icall_System_Threading_Interlocked_CompareExchange_Int,
2552 "System.Threading.Interlocked::CompareExchange(object&,object,object)", ves_icall_System_Threading_Interlocked_CompareExchange_Object,
2553 "System.Threading.Interlocked::CompareExchange(single&,single,single)", ves_icall_System_Threading_Interlocked_CompareExchange_Single,
2554 "System.Threading.Interlocked::Exchange(uint&,uint)", ves_icall_System_Threading_Interlocked_Exchange_Int,
2555 "System.Threading.Interlocked::Exchange(object&,object)", ves_icall_System_Threading_Interlocked_Exchange_Object,
2556 "System.Threading.Interlocked::Exchange(single&,single)", ves_icall_System_Threading_Interlocked_Exchange_Single,
2559 * add other internal calls here
2565 mono_init_icall (void)
2570 while ((name = icall_map [i])) {
2571 mono_add_internal_call (name, icall_map [i+1]);