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 ves_icall_System_Array_GetValueImpl (MonoObject *this, guint32 pos)
63 ao = (MonoArray *)this;
64 ac = (MonoClass *)ao->obj.vtable->klass;
66 esize = mono_array_element_size (ac);
67 ea = (gpointer*)((char*)ao->vector + (pos * esize));
69 if (ac->element_class->valuetype)
70 return mono_value_box (this->vtable->domain, ac->element_class, ea);
76 ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs)
82 MONO_CHECK_ARG_NULL (idxs);
84 io = (MonoArray *)idxs;
85 ic = (MonoClass *)io->obj.vtable->klass;
87 ao = (MonoArray *)this;
88 ac = (MonoClass *)ao->obj.vtable->klass;
90 g_assert (ic->rank == 1);
91 if (io->bounds != NULL || io->max_length != ac->rank)
92 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
94 ind = (guint32 *)io->vector;
96 if (ao->bounds == NULL) {
97 if (*ind < 0 || *ind >= ao->max_length)
98 mono_raise_exception (mono_get_exception_index_out_of_range ());
100 return ves_icall_System_Array_GetValueImpl (this, *ind);
103 for (i = 0; i < ac->rank; i++)
104 if ((ind [i] < ao->bounds [i].lower_bound) ||
105 (ind [i] >= ao->bounds [i].length + ao->bounds [i].lower_bound))
106 mono_raise_exception (mono_get_exception_index_out_of_range ());
108 pos = ind [0] - ao->bounds [0].lower_bound;
109 for (i = 1; i < ac->rank; i++)
110 pos = pos*ao->bounds [i].length + ind [i] -
111 ao->bounds [i].lower_bound;
113 return ves_icall_System_Array_GetValueImpl (this, pos);
117 ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 pos)
119 MonoClass *ac, *vc, *ec;
128 vc = value->vtable->klass;
132 ac = this->obj.vtable->klass;
133 ec = ac->element_class;
135 esize = mono_array_element_size (ac);
136 ea = (gpointer*)((char*)this->vector + (pos * esize));
137 va = (gpointer*)((char*)value + sizeof (MonoObject));
140 memset (ea, 0, esize);
144 #define NO_WIDENING_CONVERSION G_STMT_START{\
145 mono_raise_exception (mono_get_exception_argument ( \
146 "value", "not a widening conversion")); \
149 #define CHECK_WIDENING_CONVERSION(extra) G_STMT_START{\
150 if (esize < vsize + ## extra) \
151 mono_raise_exception (mono_get_exception_argument ( \
152 "value", "not a widening conversion")); \
155 #define INVALID_CAST G_STMT_START{\
156 mono_raise_exception (mono_get_exception_invalid_cast ()); \
159 /* Check element (destination) type. */
160 switch (ec->byval_arg.type) {
161 case MONO_TYPE_STRING:
162 switch (vc->byval_arg.type) {
163 case MONO_TYPE_STRING:
169 case MONO_TYPE_BOOLEAN:
170 switch (vc->byval_arg.type) {
171 case MONO_TYPE_BOOLEAN:
184 NO_WIDENING_CONVERSION;
191 if (!ec->valuetype) {
192 *ea = (gpointer)value;
196 if (mono_object_isinst (value, ec)) {
197 memcpy (ea, (char *)value + sizeof (MonoObject), esize);
204 vsize = mono_class_instance_size (vc) - sizeof (MonoObject);
207 g_message (G_STRLOC ": %d (%d) <= %d (%d)",
208 ec->byval_arg.type, esize,
209 vc->byval_arg.type, vsize);
212 #define ASSIGN_UNSIGNED(etype) G_STMT_START{\
213 switch (vc->byval_arg.type) { \
218 case MONO_TYPE_CHAR: \
219 CHECK_WIDENING_CONVERSION(0); \
220 *(## etype *) ea = (## etype) u64; \
222 /* You can't assign a signed value to an unsigned array. */ \
227 /* You can't assign a floating point number to an integer array. */ \
230 NO_WIDENING_CONVERSION; \
234 #define ASSIGN_SIGNED(etype) G_STMT_START{\
235 switch (vc->byval_arg.type) { \
240 CHECK_WIDENING_CONVERSION(0); \
241 *(## etype *) ea = (## etype) i64; \
243 /* You can assign an unsigned value to a signed array if the array's */ \
244 /* element size is larger than the value size. */ \
249 case MONO_TYPE_CHAR: \
250 CHECK_WIDENING_CONVERSION(1); \
251 *(## etype *) ea = (## etype) u64; \
253 /* You can't assign a floating point number to an integer array. */ \
256 NO_WIDENING_CONVERSION; \
260 #define ASSIGN_REAL(etype) G_STMT_START{\
261 switch (vc->byval_arg.type) { \
264 CHECK_WIDENING_CONVERSION(0); \
265 *(## etype *) ea = (## etype) r64; \
267 /* All integer values fit into a floating point array, so we don't */ \
268 /* need to CHECK_WIDENING_CONVERSION here. */ \
273 *(## etype *) ea = (## etype) i64; \
279 case MONO_TYPE_CHAR: \
280 *(## etype *) ea = (## etype) u64; \
285 switch (vc->byval_arg.type) {
287 u64 = *(guint8 *) va;
290 u64 = *(guint16 *) va;
293 u64 = *(guint32 *) va;
296 u64 = *(guint64 *) va;
302 i64 = *(gint16 *) va;
305 i64 = *(gint32 *) va;
308 i64 = *(gint64 *) va;
311 r64 = *(gfloat *) va;
314 r64 = *(gdouble *) va;
317 u64 = *(guint16 *) va;
319 case MONO_TYPE_BOOLEAN:
320 /* Boolean is only compatible with itself. */
321 switch (ec->byval_arg.type) {
333 NO_WIDENING_CONVERSION;
340 /* If we can't do a direct copy, let's try a widening conversion. */
341 switch (ec->byval_arg.type) {
343 ASSIGN_UNSIGNED (guint16);
345 ASSIGN_UNSIGNED (guint8);
347 ASSIGN_UNSIGNED (guint16);
349 ASSIGN_UNSIGNED (guint32);
351 ASSIGN_UNSIGNED (guint64);
353 ASSIGN_SIGNED (gint8);
355 ASSIGN_SIGNED (gint16);
357 ASSIGN_SIGNED (gint32);
359 ASSIGN_SIGNED (gint64);
361 ASSIGN_REAL (gfloat);
363 ASSIGN_REAL (gdouble);
367 /* Not reached, INVALID_CAST does not return. Just to avoid a compiler warning ... */
371 #undef NO_WIDENING_CONVERSION
372 #undef CHECK_WIDENING_CONVERSION
373 #undef ASSIGN_UNSIGNED
379 ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value,
385 MONO_CHECK_ARG_NULL (idxs);
387 ic = idxs->obj.vtable->klass;
388 ac = this->obj.vtable->klass;
390 g_assert (ic->rank == 1);
391 if (idxs->bounds != NULL || idxs->max_length != ac->rank)
392 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
394 ind = (guint32 *)idxs->vector;
396 if (this->bounds == NULL) {
397 if (*ind < 0 || *ind >= this->max_length)
398 mono_raise_exception (mono_get_exception_index_out_of_range ());
400 ves_icall_System_Array_SetValueImpl (this, value, *ind);
404 for (i = 0; i < ac->rank; i++)
405 if ((ind [i] < this->bounds [i].lower_bound) ||
406 (ind [i] >= this->bounds [i].length + this->bounds [i].lower_bound))
407 mono_raise_exception (mono_get_exception_index_out_of_range ());
409 pos = ind [0] - this->bounds [0].lower_bound;
410 for (i = 1; i < ac->rank; i++)
411 pos = pos * this->bounds [i].length + ind [i] -
412 this->bounds [i].lower_bound;
414 ves_icall_System_Array_SetValueImpl (this, value, pos);
418 ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *lengths, MonoArray *bounds)
424 MONO_CHECK_ARG_NULL (type);
425 MONO_CHECK_ARG_NULL (lengths);
427 MONO_CHECK_ARG (lengths, mono_array_length (lengths) > 0);
429 MONO_CHECK_ARG (bounds, mono_array_length (lengths) == mono_array_length (bounds));
431 for (i = 0; i < mono_array_length (lengths); i++)
432 if (mono_array_get (lengths, gint32, i) < 0)
433 mono_raise_exception (mono_get_exception_argument_out_of_range (NULL));
435 aklass = mono_array_class_get (type->type, mono_array_length (lengths));
437 sizes = alloca (aklass->rank * sizeof(guint32) * 2);
438 for (i = 0; i < aklass->rank; ++i) {
439 sizes [i] = mono_array_get (lengths, gint32, i);
441 sizes [i + aklass->rank] = mono_array_get (bounds, gint32, i);
443 sizes [i + aklass->rank] = 0;
446 array = mono_array_new_full (mono_domain_get (), aklass, sizes, sizes + aklass->rank);
452 ves_icall_System_Array_GetRank (MonoObject *this)
454 return this->vtable->klass->rank;
458 ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension)
460 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
461 if ((dimension < 0) || (dimension >= rank))
462 mono_raise_exception (mono_get_exception_index_out_of_range ());
464 if (this->bounds == NULL)
465 return this->max_length;
467 return this->bounds [dimension].length;
471 ves_icall_System_Array_GetLowerBound (MonoArray *this, gint32 dimension)
473 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
474 if ((dimension < 0) || (dimension >= rank))
475 mono_raise_exception (mono_get_exception_index_out_of_range ());
477 if (this->bounds == NULL)
480 return this->bounds [dimension].lower_bound;
484 ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* dest, int dest_idx, int length)
486 int element_size = mono_array_element_size (source->obj.vtable->klass);
487 void * dest_addr = mono_array_addr_with_size (dest, element_size, dest_idx);
488 void * source_addr = mono_array_addr_with_size (source, element_size, source_idx);
490 g_assert (dest_idx + length <= mono_array_length (dest));
491 g_assert (source_idx + length <= mono_array_length (source));
492 memmove (dest_addr, source_addr, element_size * length);
496 ves_icall_InitializeArray (MonoArray *array, MonoClassField *field_handle)
498 MonoClass *klass = array->obj.vtable->klass;
499 guint32 size = mono_array_element_size (klass);
502 if (array->bounds == NULL)
503 size *= array->max_length;
505 for (i = 0; i < klass->rank; ++i)
506 size *= array->bounds [i].length;
508 memcpy (mono_array_addr (array, char, 0), field_handle->data, size);
510 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
514 guint ## n *data = (guint ## n *) mono_array_addr (array, char, 0); \
516 for (i = 0; i < size; i += n/8, data++) { \
517 tmp = read ## n (data); \
522 printf ("Initialize array with elements of %s type\n", klass->element_class->name);
524 switch (klass->element_class->byval_arg.type) {
544 ves_icall_System_Object_MemberwiseClone (MonoObject *this)
546 return mono_object_clone (this);
550 ves_icall_System_Object_GetHashCode (MonoObject *this)
552 return *((gint32 *)this - 1);
556 * A hash function for value types. I have no idea if this is a good hash
557 * function (its similar to g_str_hash).
560 ves_icall_System_ValueType_GetHashCode (MonoObject *this)
566 MONO_CHECK_ARG_NULL (this);
568 size = this->vtable->klass->instance_size - sizeof (MonoObject);
570 p = (const char *)this + sizeof (MonoObject);
572 for (i = 0; i < size; i++) {
573 h = (h << 5) - h + *p;
581 ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that)
586 MONO_CHECK_ARG_NULL (that);
588 if (this->vtable != that->vtable)
591 size = this->vtable->klass->instance_size - sizeof (MonoObject);
593 p = (const char *)this + sizeof (MonoObject);
594 s = (const char *)that + sizeof (MonoObject);
596 return memcmp (p, s, size)? FALSE: TRUE;
599 static MonoReflectionType *
600 ves_icall_System_Object_GetType (MonoObject *obj)
602 return mono_type_get_object (mono_domain_get (), &obj->vtable->klass->byval_arg);
606 mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
608 mtype->type = &obj->vtable->klass->byval_arg;
609 g_assert (mtype->type->type);
613 ves_icall_AssemblyBuilder_getToken (MonoReflectionAssemblyBuilder *assb, MonoObject *obj)
615 return mono_image_create_token (assb->dynamic_assembly, obj);
619 ves_icall_AssemblyBuilder_getPEHeader (MonoReflectionAssemblyBuilder *assb, MonoArray *buf, gint32 *data_size)
622 MonoDynamicAssembly *ass = assb->dynamic_assembly;
624 hsize = mono_image_get_header (assb, (char*)buf->vector, mono_array_length (buf));
627 count = ass->code.index + ass->meta_size;
636 ves_icall_AssemblyBuilder_getDataChunk (MonoReflectionAssemblyBuilder *assb, MonoArray *buf)
638 int count, real_data;
639 MonoDynamicAssembly *ass = assb->dynamic_assembly;
640 char *p = mono_array_addr (buf, char, 0);
642 count = real_data = ass->code.index + ass->meta_size;
645 if (count > mono_array_length (buf))
649 memcpy (p, ass->code.data, ass->code.index);
650 p += ass->code.index;
651 memcpy (p, ass->assembly.image->raw_metadata, ass->meta_size);
653 /* null-pad section */
654 memset (p, 0, count);
656 return real_data + count;
659 static MonoReflectionType*
660 ves_icall_type_from_name (MonoString *name)
662 MonoDomain *domain = mono_domain_get ();
665 MonoTypeNameParse info;
668 str = mono_string_to_utf8 (name);
669 /*g_print ("requested type %s\n", str);*/
670 if (!mono_reflection_parse_type (str, &info)) {
672 g_list_free (info.modifiers);
677 image = mono_image_loaded (info.assembly);
678 /* do we need to load if it's not already loaded? */
681 g_list_free (info.modifiers);
685 image = mono_defaults.corlib;
687 type = mono_reflection_get_type (image, &info, FALSE);
689 g_list_free (info.modifiers);
692 /*g_print ("got it\n");*/
693 return mono_type_get_object (domain, type);
696 static MonoReflectionType*
697 ves_icall_type_from_handle (MonoType *handle)
699 MonoDomain *domain = mono_domain_get ();
700 MonoClass *klass = mono_class_from_mono_type (handle);
702 mono_class_init (klass);
703 return mono_type_get_object (domain, handle);
707 ves_icall_type_Equals (MonoReflectionType *type, MonoReflectionType *c)
709 if (type->type && c->type)
710 return mono_metadata_type_equal (type->type, c->type);
711 g_print ("type equals\n");
716 ves_icall_type_is_subtype_of (MonoReflectionType *type, MonoReflectionType *c, MonoBoolean check_interfaces)
722 g_assert (type != NULL);
724 domain = ((MonoObject *)type)->vtable->domain;
726 if (!c) /* FIXME: dont know what do do here */
729 klass = mono_class_from_mono_type (type->type);
730 klassc = mono_class_from_mono_type (c->type);
732 /* cut&paste from mono_object_isinst (): keep in sync */
733 if (check_interfaces && (klassc->flags & TYPE_ATTRIBUTE_INTERFACE) && !(klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
734 MonoVTable *klass_vt = mono_class_vtable (domain, klass);
735 if ((klassc->interface_id <= klass->max_interface_id) &&
736 klass_vt->interface_offsets [klassc->interface_id])
738 } else if (check_interfaces && (klassc->flags & TYPE_ATTRIBUTE_INTERFACE) && (klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
741 for (i = 0; i < klass->interface_count; i ++) {
742 MonoClass *ic = klass->interfaces [i];
748 * klass->baseval is 0 for interfaces
750 if (klass->baseval && ((klass->baseval - klassc->baseval) <= klassc->diffval))
757 ves_icall_get_attributes (MonoReflectionType *type)
759 MonoClass *klass = mono_class_from_mono_type (type->type);
765 ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info)
767 MonoDomain *domain = mono_domain_get ();
769 info->parent = mono_type_get_object (domain, &method->klass->byval_arg);
770 info->ret = mono_type_get_object (domain, method->signature->ret);
771 info->attrs = method->flags;
772 info->implattrs = method->iflags;
776 ves_icall_get_parameter_info (MonoMethod *method)
778 MonoDomain *domain = mono_domain_get ();
780 static MonoClass *System_Reflection_ParameterInfo;
781 MonoReflectionParameter** args;
784 args = mono_param_get_objects (domain, method);
785 if (!System_Reflection_ParameterInfo)
786 System_Reflection_ParameterInfo = mono_class_from_name (
787 mono_defaults.corlib, "System.Reflection", "ParameterInfo");
788 res = mono_array_new (domain, System_Reflection_ParameterInfo, method->signature->param_count);
789 for (i = 0; i < method->signature->param_count; ++i) {
790 mono_array_set (res, gpointer, i, args [i]);
796 ves_icall_get_field_info (MonoReflectionField *field, MonoFieldInfo *info)
798 MonoDomain *domain = mono_domain_get ();
800 info->parent = mono_type_get_object (domain, &field->klass->byval_arg);
801 info->type = mono_type_get_object (domain, field->field->type);
802 info->name = mono_string_new (domain, field->field->name);
803 info->attrs = field->field->type->attrs;
807 ves_icall_MonoField_GetValue (MonoReflectionField *field, MonoObject *obj) {
810 MonoType *ftype = field->field->type;
811 int type = ftype->type;
815 mono_class_init (field->klass);
816 if (ftype->attrs & FIELD_ATTRIBUTE_STATIC) {
818 vtable = mono_class_vtable (mono_domain_get (), field->klass);
819 p = (char*)(vtable->data) + field->field->offset;
821 p = (char*)obj + field->field->offset;
825 case MONO_TYPE_OBJECT:
826 case MONO_TYPE_STRING:
827 case MONO_TYPE_SZARRAY:
828 case MONO_TYPE_ARRAY:
829 return *(MonoObject**)p;
831 klass = mono_class_from_mono_type (ftype);
832 res = mono_object_new (mono_domain_get (), klass);
833 r = (char*)res + sizeof (MonoObject);
834 memcpy (r, p, mono_class_value_size (klass, &align));
840 ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info)
842 MonoDomain *domain = mono_domain_get ();
844 info->parent = mono_type_get_object (domain, &property->klass->byval_arg);
845 info->name = mono_string_new (domain, property->property->name);
846 info->attrs = property->property->attrs;
847 info->get = property->property->get ? mono_method_get_object (domain, property->property->get): NULL;
848 info->set = property->property->set ? mono_method_get_object (domain, property->property->set): NULL;
850 * There may be other methods defined for properties, though, it seems they are not exposed
851 * in the reflection API
856 ves_icall_Type_GetInterfaces (MonoReflectionType* type)
858 MonoDomain *domain = mono_domain_get ();
861 MonoClass *class = mono_class_from_mono_type (type->type);
865 for (parent = class; parent; parent = parent->parent) {
866 ninterf += parent->interface_count;
868 intf = mono_array_new (domain, mono_defaults.monotype_class, ninterf);
870 for (parent = class; parent; parent = parent->parent) {
871 for (i = 0; i < parent->interface_count; ++i) {
872 mono_array_set (intf, gpointer, ninterf, mono_type_get_object (domain, &parent->interfaces [i]->byval_arg));
879 static MonoReflectionType*
880 ves_icall_MonoType_GetElementType (MonoReflectionType *type)
882 MonoClass *class = mono_class_from_mono_type (type->type);
883 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
884 return mono_type_get_object (mono_object_domain (type), class->enum_basetype);
885 else if (class->element_class)
886 return mono_type_get_object (mono_object_domain (type), &class->element_class->byval_arg);
892 ves_icall_get_type_info (MonoType *type, MonoTypeInfo *info)
894 MonoDomain *domain = mono_domain_get ();
895 MonoClass *class = mono_class_from_mono_type (type);
897 info->parent = class->parent ? mono_type_get_object (domain, &class->parent->byval_arg): NULL;
898 info->name = mono_string_new (domain, class->name);
899 info->name_space = mono_string_new (domain, class->name_space);
900 info->attrs = class->flags;
901 info->rank = class->rank;
902 info->assembly = mono_assembly_get_object (domain, class->image->assembly);
903 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
904 info->etype = mono_type_get_object (domain, class->enum_basetype);
905 else if (class->element_class)
906 info->etype = mono_type_get_object (domain, &class->element_class->byval_arg);
910 info->isbyref = type->byref;
911 info->ispointer = type->type == MONO_TYPE_PTR;
912 info->isprimitive = (type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8);
916 ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params)
918 return mono_runtime_invoke_array (method->method, this, params);
922 ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoArray *params, MonoArray **outArgs)
924 MonoDomain *domain = mono_domain_get ();
925 MonoMethod *m = method->method;
926 MonoMethodSignature *sig = m->signature;
929 int i, j, outarg_count = 0;
931 if (m->klass == mono_defaults.object_class) {
933 if (!strcmp (m->name, "FieldGetter")) {
934 MonoClass *k = this->vtable->klass;
935 MonoString *name = mono_array_get (params, MonoString *, 1);
938 str = mono_string_to_utf8 (name);
940 for (i = 0; i < k->field.count; i++) {
941 if (!strcmp (k->fields [i].name, str)) {
942 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
943 if (field_klass->valuetype)
944 result = mono_value_box (domain, field_klass,
945 (char *)this + k->fields [i].offset);
947 result = *((gpointer *)((char *)this + k->fields [i].offset));
950 out_args = mono_array_new (domain, mono_defaults.object_class, 1);
952 mono_array_set (out_args, gpointer, 0, result);
959 g_assert_not_reached ();
961 } else if (!strcmp (m->name, "FieldSetter")) {
962 MonoClass *k = this->vtable->klass;
963 MonoString *name = mono_array_get (params, MonoString *, 1);
967 str = mono_string_to_utf8 (name);
969 for (i = 0; i < k->field.count; i++) {
970 if (!strcmp (k->fields [i].name, str)) {
971 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
972 MonoObject *val = mono_array_get (params, gpointer, 2);
974 if (field_klass->valuetype) {
975 size = mono_type_size (k->fields [i].type, &align);
976 memcpy ((char *)this + k->fields [i].offset,
977 ((char *)val) + sizeof (MonoObject), size);
979 *((gpointer *)this + k->fields [i].offset) = val;
988 g_assert_not_reached ();
993 for (i = 0; i < mono_array_length (params); i++) {
994 if (sig->params [i]->byref)
998 out_args = mono_array_new (domain, mono_defaults.object_class, outarg_count);
1000 for (i = 0, j = 0; i < mono_array_length (params); i++) {
1001 if (sig->params [i]->byref) {
1003 arg = mono_array_get (params, gpointer, i);
1004 mono_array_set (out_args, gpointer, j, arg);
1009 /* fixme: handle constructors? */
1010 if (!strcmp (method->method->name, ".ctor"))
1011 g_assert_not_reached ();
1013 result = mono_runtime_invoke_array (method->method, this, params);
1015 *outArgs = out_args;
1021 ves_icall_System_Enum_ToObject (MonoReflectionType *type, MonoObject *obj)
1023 MonoDomain *domain = mono_domain_get ();
1024 MonoClass *enumc, *objc;
1028 MONO_CHECK_ARG_NULL (type);
1029 MONO_CHECK_ARG_NULL (obj);
1031 enumc = mono_class_from_mono_type (type->type);
1032 objc = obj->vtable->klass;
1034 MONO_CHECK_ARG (obj, enumc->enumtype == TRUE);
1035 MONO_CHECK_ARG (obj, (objc->enumtype) || (objc->byval_arg.type >= MONO_TYPE_I1 &&
1036 objc->byval_arg.type <= MONO_TYPE_U8));
1038 s1 = mono_class_value_size (enumc, NULL);
1039 s2 = mono_class_value_size (objc, NULL);
1041 res = mono_object_new (domain, enumc);
1043 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1044 memcpy ((char *)res + sizeof (MonoObject), (char *)obj + sizeof (MonoObject), MIN (s1, s2));
1046 memcpy ((char *)res + sizeof (MonoObject) + (s1 > s2 ? s1 - s2 : 0),
1047 (char *)obj + sizeof (MonoObject) + (s2 > s1 ? s2 - s1 : 0),
1054 ves_icall_System_Enum_get_value (MonoObject *this)
1056 MonoDomain *domain = mono_domain_get ();
1066 g_assert (this->vtable->klass->enumtype);
1068 enumc = mono_class_from_mono_type (this->vtable->klass->enum_basetype);
1069 res = mono_object_new (domain, enumc);
1070 dst = (char *)res + sizeof (MonoObject);
1071 src = (char *)this + sizeof (MonoObject);
1072 size = mono_class_value_size (enumc, NULL);
1074 memcpy (dst, src, size);
1080 ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
1082 MonoDomain *domain = mono_domain_get ();
1083 MonoClass *enumc = mono_class_from_mono_type (type->type);
1084 guint i, j, nvalues, crow;
1085 MonoClassField *field;
1087 info->utype = mono_type_get_object (domain, enumc->enum_basetype);
1088 nvalues = enumc->field.count - 1;
1089 info->names = mono_array_new (domain, mono_defaults.string_class, nvalues);
1090 info->values = mono_array_new (domain, enumc, nvalues);
1092 for (i = 0, j = 0; i < enumc->field.count; ++i) {
1093 field = &enumc->fields [i];
1094 if (strcmp ("value__", field->name) == 0)
1096 mono_array_set (info->names, gpointer, j, mono_string_new (domain, field->name));
1098 crow = mono_metadata_get_constant_index (enumc->image, MONO_TOKEN_FIELD_DEF | (i+enumc->field.first+1));
1099 crow = mono_metadata_decode_row_col (&enumc->image->tables [MONO_TABLE_CONSTANT], crow-1, MONO_CONSTANT_VALUE);
1100 /* 1 is the length of the blob */
1101 field->data = 1 + mono_metadata_blob_heap (enumc->image, crow);
1103 switch (enumc->enum_basetype->type) {
1106 mono_array_set (info->values, gchar, j, *field->data);
1108 case MONO_TYPE_CHAR:
1111 mono_array_set (info->values, gint16, j, read16 (field->data));
1115 mono_array_set (info->values, gint32, j, read32 (field->data));
1119 mono_array_set (info->values, gint64, j, read64 (field->data));
1122 g_error ("Implement type 0x%02x in get_enum_info", enumc->enum_basetype->type);
1129 search_method (MonoReflectionType *type, const char *name, guint32 flags, MonoArray *args)
1131 MonoClass *klass, *start_class;
1133 MonoReflectionType *paramt;
1136 start_class = klass = mono_class_from_mono_type (type->type);
1138 for (i = 0; i < klass->method.count; ++i) {
1139 m = klass->methods [i];
1140 if (!((m->flags & flags) == flags))
1142 if (strcmp(m->name, name))
1144 if (m->signature->param_count != mono_array_length (args))
1146 for (j = 0; j < m->signature->param_count; ++j) {
1147 paramt = mono_array_get (args, MonoReflectionType*, j);
1148 if (!mono_metadata_type_equal (paramt->type, m->signature->params [j]))
1151 if (j == m->signature->param_count)
1154 klass = klass->parent;
1156 g_print ("Method %s.%s::%s (%d) not found\n", start_class->name_space, start_class->name, name, mono_array_length (args));
1160 static MonoReflectionMethod*
1161 ves_icall_get_constructor (MonoReflectionType *type, MonoArray *args)
1163 MonoDomain *domain = mono_domain_get ();
1166 m = search_method (type, ".ctor", METHOD_ATTRIBUTE_RT_SPECIAL_NAME, args);
1168 return mono_method_get_object (domain, m);
1172 static MonoReflectionMethod*
1173 ves_icall_get_method (MonoReflectionType *type, MonoString *name, MonoArray *args)
1175 MonoDomain *domain = mono_domain_get ();
1177 char *n = mono_string_to_utf8 (name);
1179 m = search_method (type, n, 0, args);
1182 return mono_method_get_object (domain, m);
1186 static MonoProperty*
1187 search_property (MonoClass *klass, char* name, MonoArray *args) {
1191 /* FIXME: handle args */
1192 for (i = 0; i < klass->property.count; ++i) {
1193 p = &klass->properties [i];
1194 if (strcmp (p->name, name) == 0)
1200 static MonoReflectionProperty*
1201 ves_icall_get_property (MonoReflectionType *type, MonoString *name, MonoArray *args)
1203 MonoDomain *domain = mono_domain_get ();
1205 MonoClass *class = mono_class_from_mono_type (type->type);
1206 char *n = mono_string_to_utf8 (name);
1208 p = search_property (class, n, args);
1211 return mono_property_get_object (domain, class, p);
1216 BFLAGS_IgnoreCase = 1,
1217 BFLAGS_DeclaredOnly = 2,
1218 BFLAGS_Instance = 4,
1220 BFLAGS_Public = 0x10,
1221 BFLAGS_NonPublic = 0x20,
1222 BFLAGS_InvokeMethod = 0x100,
1223 BFLAGS_CreateInstance = 0x200,
1224 BFLAGS_GetField = 0x400,
1225 BFLAGS_SetField = 0x800,
1226 BFLAGS_GetProperty = 0x1000,
1227 BFLAGS_SetProperty = 0x2000,
1228 BFLAGS_ExactBinding = 0x10000,
1229 BFLAGS_SuppressChangeType = 0x20000,
1230 BFLAGS_OptionalParamBinding = 0x40000
1234 ves_icall_Type_GetFields (MonoReflectionType *type, guint32 bflags)
1237 GSList *l = NULL, *tmp;
1238 static MonoClass *System_Reflection_FieldInfo;
1239 MonoClass *startklass, *klass;
1243 MonoClassField *field;
1245 domain = ((MonoObject *)type)->vtable->domain;
1246 klass = startklass = mono_class_from_mono_type (type->type);
1249 for (i = 0; i < klass->field.count; ++i) {
1251 field = &klass->fields [i];
1252 if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
1253 if (bflags & BFLAGS_Public)
1256 if (bflags & BFLAGS_NonPublic)
1262 if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1263 if (bflags & BFLAGS_Static)
1266 if (bflags & BFLAGS_Instance)
1272 member = (MonoObject*)mono_field_get_object (domain, klass, field);
1273 l = g_slist_prepend (l, member);
1275 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1277 len = g_slist_length (l);
1278 if (!System_Reflection_FieldInfo)
1279 System_Reflection_FieldInfo = mono_class_from_name (
1280 mono_defaults.corlib, "System.Reflection", "FieldInfo");
1281 res = mono_array_new (domain, System_Reflection_FieldInfo, len);
1283 tmp = g_slist_reverse (l);
1284 for (; tmp; tmp = tmp->next, ++i)
1285 mono_array_set (res, gpointer, i, tmp->data);
1291 ves_icall_Type_GetMethods (MonoReflectionType *type, guint32 bflags)
1294 GSList *l = NULL, *tmp;
1295 static MonoClass *System_Reflection_MethodInfo;
1296 MonoClass *startklass, *klass;
1302 domain = ((MonoObject *)type)->vtable->domain;
1303 klass = startklass = mono_class_from_mono_type (type->type);
1306 for (i = 0; i < klass->method.count; ++i) {
1308 method = klass->methods [i];
1309 if (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0)
1311 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1312 if (bflags & BFLAGS_Public)
1315 if (bflags & BFLAGS_NonPublic)
1321 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1322 if (bflags & BFLAGS_Static)
1325 if (bflags & BFLAGS_Instance)
1332 member = (MonoObject*)mono_method_get_object (domain, method);
1334 l = g_slist_prepend (l, member);
1336 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1338 len = g_slist_length (l);
1339 if (!System_Reflection_MethodInfo)
1340 System_Reflection_MethodInfo = mono_class_from_name (
1341 mono_defaults.corlib, "System.Reflection", "MethodInfo");
1342 res = mono_array_new (domain, System_Reflection_MethodInfo, len);
1345 for (; tmp; tmp = tmp->next, ++i)
1346 mono_array_set (res, gpointer, i, tmp->data);
1353 ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
1356 GSList *l = NULL, *tmp;
1357 static MonoClass *System_Reflection_ConstructorInfo;
1358 MonoClass *startklass, *klass;
1364 domain = ((MonoObject *)type)->vtable->domain;
1365 klass = startklass = mono_class_from_mono_type (type->type);
1368 for (i = 0; i < klass->method.count; ++i) {
1370 method = klass->methods [i];
1371 if (strcmp (method->name, ".ctor") && strcmp (method->name, ".cctor"))
1373 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1374 if (bflags & BFLAGS_Public)
1377 if (bflags & BFLAGS_NonPublic)
1383 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1384 if (bflags & BFLAGS_Static)
1387 if (bflags & BFLAGS_Instance)
1393 member = (MonoObject*)mono_method_get_object (domain, method);
1395 l = g_slist_prepend (l, member);
1397 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1399 len = g_slist_length (l);
1400 if (!System_Reflection_ConstructorInfo)
1401 System_Reflection_ConstructorInfo = mono_class_from_name (
1402 mono_defaults.corlib, "System.Reflection", "ConstructorInfo");
1403 res = mono_array_new (domain, System_Reflection_ConstructorInfo, len);
1406 for (; tmp; tmp = tmp->next, ++i)
1407 mono_array_set (res, gpointer, i, tmp->data);
1413 ves_icall_Type_GetProperties (MonoReflectionType *type, guint32 bflags)
1416 GSList *l = NULL, *tmp;
1417 static MonoClass *System_Reflection_PropertyInfo;
1418 MonoClass *startklass, *klass;
1424 domain = ((MonoObject *)type)->vtable->domain;
1425 klass = startklass = mono_class_from_mono_type (type->type);
1428 for (i = 0; i < klass->property.count; ++i) {
1429 prop = &klass->properties [i];
1434 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1435 if (bflags & BFLAGS_Public)
1438 if (bflags & BFLAGS_NonPublic)
1444 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1445 if (bflags & BFLAGS_Static)
1448 if (bflags & BFLAGS_Instance)
1455 l = g_slist_prepend (l, mono_property_get_object (domain, klass, prop));
1457 if (!l && (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)))
1459 len = g_slist_length (l);
1460 if (!System_Reflection_PropertyInfo)
1461 System_Reflection_PropertyInfo = mono_class_from_name (
1462 mono_defaults.corlib, "System.Reflection", "PropertyInfo");
1463 res = mono_array_new (domain, System_Reflection_PropertyInfo, len);
1466 for (; tmp; tmp = tmp->next, ++i)
1467 mono_array_set (res, gpointer, i, tmp->data);
1473 ves_icall_Type_GetEvents (MonoReflectionType *type, guint32 bflags)
1476 GSList *l = NULL, *tmp;
1477 static MonoClass *System_Reflection_EventInfo;
1478 MonoClass *startklass, *klass;
1484 domain = ((MonoObject *)type)->vtable->domain;
1485 klass = startklass = mono_class_from_mono_type (type->type);
1488 for (i = 0; i < klass->event.count; ++i) {
1489 event = &klass->events [i];
1491 method = event->add;
1493 method = event->remove;
1494 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1495 if (bflags & BFLAGS_Public)
1498 if (bflags & BFLAGS_NonPublic)
1504 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1505 if (bflags & BFLAGS_Static)
1508 if (bflags & BFLAGS_Instance)
1515 l = g_slist_prepend (l, mono_event_get_object (domain, klass, event));
1517 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1519 len = g_slist_length (l);
1520 if (!System_Reflection_EventInfo)
1521 System_Reflection_EventInfo = mono_class_from_name (
1522 mono_defaults.corlib, "System.Reflection", "EventInfo");
1523 res = mono_array_new (domain, System_Reflection_EventInfo, len);
1526 for (; tmp; tmp = tmp->next, ++i)
1527 mono_array_set (res, gpointer, i, tmp->data);
1533 ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags)
1536 GSList *l = NULL, *tmp;
1538 MonoClass *startklass, *klass;
1544 domain = ((MonoObject *)type)->vtable->domain;
1545 klass = startklass = mono_class_from_mono_type (type->type);
1547 for (tmpn = klass->nested_classes; tmpn; tmpn = tmpn->next) {
1549 nested = tmpn->data;
1550 if ((nested->flags & TYPE_ATTRIBUTE_VISIBILITY_MASK) == TYPE_ATTRIBUTE_NESTED_PUBLIC) {
1551 if (bflags & BFLAGS_Public)
1554 if (bflags & BFLAGS_NonPublic)
1559 member = (MonoObject*)mono_type_get_object (domain, &nested->byval_arg);
1560 l = g_slist_prepend (l, member);
1562 len = g_slist_length (l);
1563 res = mono_array_new (domain, mono_defaults.monotype_class, len);
1565 tmp = g_slist_reverse (l);
1566 for (; tmp; tmp = tmp->next, ++i)
1567 mono_array_set (res, gpointer, i, tmp->data);
1573 ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr (gpointer ptr)
1575 return (gpointer)(*(int *)ptr);
1579 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAuto (gpointer ptr)
1581 MonoDomain *domain = mono_domain_get ();
1583 return mono_string_new (domain, (char *)ptr);
1586 static guint32 ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error(void)
1588 return(GetLastError());
1591 static MonoReflectionType*
1592 ves_icall_System_Reflection_Assembly_GetType (MonoReflectionAssembly *assembly, MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase)
1594 MonoDomain *domain = mono_domain_get ();
1597 MonoTypeNameParse info;
1599 str = mono_string_to_utf8 (name);
1600 /*g_print ("requested type %s in %s\n", str, assembly->assembly->name);*/
1601 if (!mono_reflection_parse_type (str, &info)) {
1603 g_list_free (info.modifiers);
1604 if (throwOnError) /* uhm: this is a parse error, though... */
1605 mono_raise_exception (mono_get_exception_type_load ());
1606 /*g_print ("failed parse\n");*/
1610 type = mono_reflection_get_type (assembly->assembly->image, &info, ignoreCase);
1612 g_list_free (info.modifiers);
1615 mono_raise_exception (mono_get_exception_type_load ());
1616 /* g_print ("failed find\n"); */
1619 /* g_print ("got it\n"); */
1620 return mono_type_get_object (domain, type);
1625 ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly *assembly)
1627 MonoDomain *domain = mono_domain_get ();
1629 char *name = g_strconcat (
1630 "file://", assembly->assembly->image->name, NULL);
1632 res = mono_string_new (domain, name);
1638 ves_icall_System_MonoType_getFullName (MonoReflectionType *object)
1640 MonoDomain *domain = mono_domain_get ();
1644 name = mono_type_get_name (object->type);
1645 res = mono_string_new (domain, name);
1652 ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly)
1654 MonoDomain *domain = mono_domain_get ();
1657 MonoTableInfo *tdef = &assembly->assembly->image->tables [MONO_TABLE_TYPEDEF];
1659 guint32 attrs, visibility;
1663 for (i = 0; i < tdef->rows; ++i) {
1664 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
1665 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
1666 if (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)
1672 res = mono_array_new (domain, mono_defaults.monotype_class, count);
1674 for (i = 0; i < tdef->rows; ++i) {
1675 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
1676 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
1677 if (!exportedOnly || (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)) {
1678 klass = mono_class_get (assembly->assembly->image, (i + 1) | MONO_TOKEN_TYPE_DEF);
1679 mono_array_set (res, gpointer, count, mono_type_get_object (domain, &klass->byval_arg));
1687 static MonoReflectionType*
1688 ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, MonoString *smodifiers)
1691 int isbyref = 0, rank;
1692 char *str = mono_string_to_utf8 (smodifiers);
1695 klass = mono_class_from_mono_type (tb->type.type);
1697 /* logic taken from mono_reflection_parse_type(): keep in sync */
1701 if (isbyref) { /* only one level allowed by the spec */
1708 return mono_type_get_object (mono_domain_get (), &klass->this_arg);
1711 klass = mono_ptr_class_get (&klass->byval_arg);
1712 mono_class_init (klass);
1723 else if (*p != '*') { /* '*' means unknown lower bound */
1734 klass = mono_array_class_get (&klass->byval_arg, rank);
1735 mono_class_init (klass);
1742 return mono_type_get_object (mono_domain_get (), &klass->byval_arg);
1746 * Magic number to convert a time which is relative to
1747 * Jan 1, 1970 into a value which is relative to Jan 1, 0001.
1749 #define EPOCH_ADJUST ((gint64)62135596800L)
1752 ves_icall_System_DateTime_GetNow (void)
1754 #ifdef PLATFORM_WIN32
1759 SystemTimeToFileTime (&st, &ft);
1760 return (gint64)504911232000000000L + (((gint64)ft.dwHighDateTime)<<32) | ft.dwLowDateTime;
1762 /* FIXME: put this in io-layer and call it GetLocalTime */
1766 if (gettimeofday (&tv, NULL) == 0) {
1767 res = (((gint64)tv.tv_sec + EPOCH_ADJUST)* 1000000 + tv.tv_usec)*10;
1770 /* fixme: raise exception */
1776 * This is heavily based on zdump.c from glibc 2.2.
1778 * * data[0]: start of daylight saving time (in DateTime ticks).
1779 * * data[1]: end of daylight saving time (in DateTime ticks).
1780 * * data[2]: utcoffset (in TimeSpan ticks).
1781 * * data[3]: additional offset when daylight saving (in TimeSpan ticks).
1782 * * name[0]: name of this timezone when not daylight saving.
1783 * * name[1]: name of this timezone when daylight saving.
1785 * FIXME: This only works with "standard" Unix dates (years between 1900 and 2100) while
1786 * the class library allows years between 1 and 9999.
1788 * Returns true on success and zero on failure.
1791 ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names)
1793 #ifndef PLATFORM_WIN32
1794 MonoDomain *domain = mono_domain_get ();
1795 struct tm start, tt;
1799 int is_daylight = 0, day;
1801 memset (&start, 0, sizeof (start));
1804 start.tm_year = year-1900;
1806 t = mktime (&start);
1807 gmtoff = start.tm_gmtoff;
1809 MONO_CHECK_ARG_NULL (data);
1810 MONO_CHECK_ARG_NULL (names);
1812 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
1813 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
1815 /* For each day of the year, calculate the tm_gmtoff. */
1816 for (day = 0; day < 365; day++) {
1819 tt = *localtime (&t);
1821 /* Daylight saving starts or ends here. */
1822 if (tt.tm_gmtoff != gmtoff) {
1826 /* Try to find the exact hour when daylight saving starts/ends. */
1830 tt1 = *localtime (&t1);
1831 } while (tt1.tm_gmtoff != gmtoff);
1833 /* Try to find the exact minute when daylight saving starts/ends. */
1836 tt1 = *localtime (&t1);
1837 } while (tt1.tm_gmtoff == gmtoff);
1839 /* Write data, if we're already in daylight saving, we're done. */
1841 mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tt.tm_zone));
1842 mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
1845 mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tt.tm_zone));
1846 mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
1850 /* This is only set once when we enter daylight saving. */
1851 mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L);
1852 mono_array_set ((*data), gint64, 3, (gint64)(tt.tm_gmtoff - gmtoff) * 10000000L);
1854 gmtoff = tt.tm_gmtoff;
1857 gmtoff = tt.tm_gmtoff;
1861 MonoDomain *domain = mono_domain_get ();
1862 TIME_ZONE_INFORMATION tz_info;
1866 GetTimeZoneInformation (&tz_info);
1868 MONO_CHECK_ARG_NULL (data);
1869 MONO_CHECK_ARG_NULL (names);
1871 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
1872 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
1874 for (i = 0; i < 32; ++i)
1875 if (!tz_info.DaylightName [i])
1877 mono_array_set ((*names), gpointer, 1, mono_string_new_utf16 (domain, tz_info.DaylightName, i));
1878 for (i = 0; i < 32; ++i)
1879 if (!tz_info.StandardName [i])
1881 mono_array_set ((*names), gpointer, 0, mono_string_new_utf16 (domain, tz_info.StandardName, i));
1883 SystemTimeToFileTime (&tz_info.StandardDate, &ft);
1884 mono_array_set ((*data), gint64, 1, ((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime);
1885 SystemTimeToFileTime (&tz_info.DaylightDate, &ft);
1886 mono_array_set ((*data), gint64, 0, ((guint64)ft.dwHighDateTime<<32) | ft.dwLowDateTime);
1887 mono_array_set ((*data), gint64, 3, tz_info.Bias + tz_info.StandardBias);
1888 mono_array_set ((*data), gint64, 2, tz_info.Bias + tz_info.DaylightBias);
1895 ves_icall_System_Object_obj_address (MonoObject *this) {
1902 ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array) {
1908 klass = array->obj.vtable->klass;
1909 etype = klass->element_class->byval_arg.type;
1910 if (etype < MONO_TYPE_BOOLEAN || etype > MONO_TYPE_R8)
1913 if (array->bounds == NULL)
1914 length = array->max_length;
1917 for (i = 0; i < klass->rank; ++ i)
1918 length += array->bounds [i].length;
1921 esize = mono_array_element_size (klass);
1922 return length * esize;
1926 ves_icall_System_Buffer_GetByteInternal (MonoArray *array, gint32 idx) {
1927 return mono_array_get (array, gint8, idx);
1931 ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 value) {
1932 mono_array_set (array, gint8, idx, value);
1936 ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count) {
1937 char *src_buf, *dest_buf;
1939 src_buf = (gint8 *)src->vector + src_offset;
1940 dest_buf = (gint8 *)dest->vector + dest_offset;
1942 memcpy (dest_buf, src_buf, count);
1946 ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this)
1948 MonoDomain *domain = mono_domain_get ();
1950 MonoRealProxy *rp = ((MonoRealProxy *)this);
1954 res = mono_object_new (domain, mono_defaults.transparent_proxy_class);
1956 ((MonoTransparentProxy *)res)->rp = rp;
1957 type = ((MonoReflectionType *)rp->class_to_proxy)->type;
1958 klass = mono_class_from_mono_type (type);
1960 ((MonoTransparentProxy *)res)->klass = klass;
1962 res->vtable = mono_class_proxy_vtable (domain, klass);
1967 /* System.Environment */
1970 ves_icall_System_Environment_get_MachineName (void)
1972 #if defined (PLATFORM_WIN32)
1977 len = MAX_COMPUTERNAME_LENGTH + 1;
1978 buf = g_new (gunichar2, len);
1981 if (GetComputerName (buf, &len))
1982 result = mono_string_new_utf16 (mono_domain_get (), buf, len);
1992 buf = g_new (gchar, len);
1995 if (gethostname (buf, len) != 0)
1996 result = mono_string_new (mono_domain_get (), buf);
2004 ves_icall_System_Environment_get_NewLine (void)
2006 #if defined (PLATFORM_WIN32)
2007 return mono_string_new (mono_domain_get (), "\r\n");
2009 return mono_string_new (mono_domain_get (), "\n");
2014 ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
2022 utf8_name = mono_string_to_utf8 (name); /* FIXME: this should be ascii */
2023 value = g_getenv (utf8_name);
2029 return mono_string_new (mono_domain_get (), value);
2033 * There is no standard way to get at environ.
2035 extern char **environ;
2038 ves_icall_System_Environment_GetEnvironmentVariableNames (void)
2047 for (e = environ; *e != 0; ++ e)
2050 domain = mono_domain_get ();
2051 names = mono_array_new (domain, mono_defaults.string_class, n);
2054 for (e = environ; *e != 0; ++ e) {
2055 parts = g_strsplit (*e, "=", 2);
2057 str = mono_string_new (domain, *parts);
2058 mono_array_set (names, MonoString *, n, str);
2070 ves_icall_System_Environment_Exit (int result)
2072 /* we may need to do some cleanup here... */
2077 ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this,
2078 MonoReflectionMethod *method,
2079 MonoArray *out_args)
2081 MonoDomain *domain = mono_domain_get ();
2083 mono_message_init (domain, this, method, out_args);
2087 ves_icall_IsTransparentProxy (MonoObject *proxy)
2092 if (proxy->vtable->klass == mono_defaults.transparent_proxy_class)
2101 static gconstpointer icall_map [] = {
2105 "System.Array::GetValue", ves_icall_System_Array_GetValue,
2106 "System.Array::SetValue", ves_icall_System_Array_SetValue,
2107 "System.Array::GetValueImpl", ves_icall_System_Array_GetValueImpl,
2108 "System.Array::SetValueImpl", ves_icall_System_Array_SetValueImpl,
2109 "System.Array::GetRank", ves_icall_System_Array_GetRank,
2110 "System.Array::GetLength", ves_icall_System_Array_GetLength,
2111 "System.Array::GetLowerBound", ves_icall_System_Array_GetLowerBound,
2112 "System.Array::CreateInstanceImpl", ves_icall_System_Array_CreateInstanceImpl,
2113 "System.Array::FastCopy", ves_icall_System_Array_FastCopy,
2114 "System.Array::Clone", mono_array_clone,
2119 "System.Object::MemberwiseClone", ves_icall_System_Object_MemberwiseClone,
2120 "System.Object::GetType", ves_icall_System_Object_GetType,
2121 "System.Object::GetHashCode", ves_icall_System_Object_GetHashCode,
2122 "System.Object::obj_address", ves_icall_System_Object_obj_address,
2127 "System.ValueType::GetHashCode", ves_icall_System_ValueType_GetHashCode,
2128 "System.ValueType::Equals", ves_icall_System_ValueType_Equals,
2134 "System.String::.ctor(char*)", ves_icall_System_String_ctor_charp,
2135 "System.String::.ctor(char*,uint,uint)", ves_icall_System_String_ctor_charp_int_int,
2136 "System.String::.ctor(sbyte*)", ves_icall_System_String_ctor_sbytep,
2137 "System.String::.ctor(sbyte*,uint,uint)", ves_icall_System_String_ctor_sbytep_int_int,
2138 "System.String::.ctor(sbyte*,uint,uint,System.Text.Encoding)", ves_icall_System_String_ctor_encoding,
2139 "System.String::.ctor(char[])", ves_icall_System_String_ctor_chara,
2140 "System.String::.ctor(char[],uint,uint)", ves_icall_System_String_ctor_chara_int_int,
2141 "System.String::.ctor(char,uint)", ves_icall_System_String_ctor_char_int,
2142 "System.String::InternalEquals", ves_icall_System_String_InternalEquals,
2143 "System.String::InternalJoin", ves_icall_System_String_InternalJoin,
2144 "System.String::InternalInsert", ves_icall_System_String_InternalInsert,
2145 "System.String::InternalReplace(char,char)", ves_icall_System_String_InternalReplace_Char,
2146 "System.String::InternalReplace(string,string)", ves_icall_System_String_InternalReplace_Str,
2147 "System.String::InternalRemove", ves_icall_System_String_InternalRemove,
2148 "System.String::InternalCopyTo", ves_icall_System_String_InternalCopyTo,
2149 "System.String::InternalSplit", ves_icall_System_String_InternalSplit,
2150 "System.String::InternalTrim", ves_icall_System_String_InternalTrim,
2151 "System.String::InternalIndexOf(char,uint,uint)", ves_icall_System_String_InternalIndexOf_Char,
2152 "System.String::InternalIndexOf(string,uint,uint)", ves_icall_System_String_InternalIndexOf_Str,
2153 "System.String::InternalIndexOfAny", ves_icall_System_String_InternalIndexOfAny,
2154 "System.String::InternalLastIndexOf(char,uint,uint)", ves_icall_System_String_InternalLastIndexOf_Char,
2155 "System.String::InternalLastIndexOf(string,uint,uint)", ves_icall_System_String_InternalLastIndexOf_Str,
2156 "System.String::InternalLastIndexOfAny", ves_icall_System_String_InternalLastIndexOfAny,
2157 "System.String::InternalPad", ves_icall_System_String_InternalPad,
2158 "System.String::InternalToLower", ves_icall_System_String_InternalToLower,
2159 "System.String::InternalToUpper", ves_icall_System_String_InternalToUpper,
2160 "System.String::InternalAllocateStr", ves_icall_System_String_InternalAllocateStr,
2161 "System.String::InternalStrcpy(string,uint,string)", ves_icall_System_String_InternalStrcpy_Str,
2162 "System.String::InternalStrcpy(string,uint,string,uint,uint)", ves_icall_System_String_InternalStrcpy_StrN,
2163 "System.String::InternalIntern", ves_icall_System_String_InternalIntern,
2164 "System.String::InternalIsInterned", ves_icall_System_String_InternalIsInterned,
2165 "System.String::InternalCompare(string,uint,string,uint,uint,bool)", ves_icall_System_String_InternalCompareStr_N,
2166 "System.String::GetHashCode", ves_icall_System_String_GetHashCode,
2167 "System.String::get_Chars", ves_icall_System_String_get_Chars,
2172 "System.AppDomain::createDomain", ves_icall_System_AppDomain_createDomain,
2173 "System.AppDomain::getCurDomain", ves_icall_System_AppDomain_getCurDomain,
2174 "System.AppDomain::GetData", ves_icall_System_AppDomain_GetData,
2175 "System.AppDomain::SetData", ves_icall_System_AppDomain_SetData,
2176 "System.AppDomain::getSetup", ves_icall_System_AppDomain_getSetup,
2177 "System.AppDomain::getFriendlyName", ves_icall_System_AppDomain_getFriendlyName,
2178 "System.AppDomain::GetAssemblies", ves_icall_System_AppDomain_GetAssemblies,
2179 "System.AppDomain::LoadAssembly", ves_icall_System_AppDomain_LoadAssembly,
2180 "System.AppDomain::Unload", ves_icall_System_AppDomain_Unload,
2181 "System.AppDomain::ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly,
2184 * System.AppDomainSetup
2186 "System.AppDomainSetup::InitAppDomainSetup", ves_icall_System_AppDomainSetup_InitAppDomainSetup,
2191 "System.Double::ToStringImpl", mono_double_ToStringImpl,
2196 "System.Decimal::decimal2UInt64", mono_decimal2UInt64,
2197 "System.Decimal::decimal2Int64", mono_decimal2Int64,
2198 "System.Decimal::double2decimal", mono_double2decimal, /* FIXME: wrong signature. */
2199 "System.Decimal::decimalIncr", mono_decimalIncr,
2200 "System.Decimal::decimalSetExponent", mono_decimalSetExponent,
2201 "System.Decimal::decimal2double", mono_decimal2double,
2202 "System.Decimal::decimalFloorAndTrunc", mono_decimalFloorAndTrunc,
2203 "System.Decimal::decimalRound", mono_decimalRound,
2204 "System.Decimal::decimalMult", mono_decimalMult,
2205 "System.Decimal::decimalDiv", mono_decimalDiv,
2206 "System.Decimal::decimalIntDiv", mono_decimalIntDiv,
2207 "System.Decimal::decimalCompare", mono_decimalCompare,
2208 "System.Decimal::string2decimal", mono_string2decimal,
2209 "System.Decimal::decimal2string", mono_decimal2string,
2214 "System.Reflection.Emit.ModuleBuilder::create_modified_type", ves_icall_ModuleBuilder_create_modified_type,
2219 "System.Reflection.Emit.AssemblyBuilder::getDataChunk", ves_icall_AssemblyBuilder_getDataChunk,
2220 "System.Reflection.Emit.AssemblyBuilder::getPEHeader", ves_icall_AssemblyBuilder_getPEHeader,
2221 "System.Reflection.Emit.AssemblyBuilder::getUSIndex", mono_image_insert_string,
2222 "System.Reflection.Emit.AssemblyBuilder::getToken", ves_icall_AssemblyBuilder_getToken,
2223 "System.Reflection.Emit.AssemblyBuilder::basic_init", mono_image_basic_init,
2228 "System.Reflection.MonoMethodInfo::get_method_info", ves_icall_get_method_info,
2229 "System.Reflection.MonoMethodInfo::get_parameter_info", ves_icall_get_parameter_info,
2230 "System.Reflection.MonoFieldInfo::get_field_info", ves_icall_get_field_info,
2231 "System.Reflection.MonoPropertyInfo::get_property_info", ves_icall_get_property_info,
2232 "System.Reflection.MonoMethod::InternalInvoke", ves_icall_InternalInvoke,
2233 "System.Reflection.MonoCMethod::InternalInvoke", ves_icall_InternalInvoke,
2234 "System.MonoCustomAttrs::GetCustomAttributes", mono_reflection_get_custom_attrs,
2235 "System.Reflection.Emit.CustomAttributeBuilder::GetBlob", mono_reflection_get_custom_attrs_blob,
2236 "System.Reflection.MonoField::GetValue", ves_icall_MonoField_GetValue,
2237 "System.Reflection.Emit.SignatureHelper::get_signature_local", mono_reflection_sighelper_get_signature_local,
2238 "System.Reflection.Emit.SignatureHelper::get_signature_field", mono_reflection_sighelper_get_signature_field,
2243 "System.MonoEnumInfo::get_enum_info", ves_icall_get_enum_info,
2244 "System.Enum::get_value", ves_icall_System_Enum_get_value,
2245 "System.Enum::ToObject", ves_icall_System_Enum_ToObject,
2250 "System.Reflection.Emit.TypeBuilder::setup_internal_class", mono_reflection_setup_internal_class,
2260 "System.Type::internal_from_name", ves_icall_type_from_name,
2261 "System.Type::internal_from_handle", ves_icall_type_from_handle,
2262 "System.Type::get_constructor", ves_icall_get_constructor,
2263 "System.Type::get_property", ves_icall_get_property,
2264 "System.Type::get_method", ves_icall_get_method,
2265 "System.MonoType::get_attributes", ves_icall_get_attributes,
2266 "System.Type::type_is_subtype_of", ves_icall_type_is_subtype_of,
2267 "System.Type::Equals", ves_icall_type_Equals,
2270 * System.Runtime.CompilerServices.RuntimeHelpers
2272 "System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray", ves_icall_InitializeArray,
2277 "System.Threading.Thread::Thread_internal", ves_icall_System_Threading_Thread_Thread_internal,
2278 "System.Threading.Thread::Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal,
2279 "System.Threading.Thread::Start_internal", ves_icall_System_Threading_Thread_Start_internal,
2280 "System.Threading.Thread::Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal,
2281 "System.Threading.Thread::CurrentThread_internal", ves_icall_System_Threading_Thread_CurrentThread_internal,
2282 "System.Threading.Thread::CurrentThreadDomain_internal", ves_icall_System_Threading_Thread_CurrentThreadDomain_internal,
2283 "System.Threading.Thread::Join_internal", ves_icall_System_Threading_Thread_Join_internal,
2284 "System.Threading.Thread::SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup,
2285 "System.Threading.Thread::SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store,
2286 "System.Threading.Monitor::Monitor_exit", ves_icall_System_Threading_Monitor_Monitor_exit,
2287 "System.Threading.Monitor::Monitor_test_owner", ves_icall_System_Threading_Monitor_Monitor_test_owner,
2288 "System.Threading.Monitor::Monitor_test_synchronised", ves_icall_System_Threading_Monitor_Monitor_test_synchronised,
2289 "System.Threading.Monitor::Monitor_pulse", ves_icall_System_Threading_Monitor_Monitor_pulse,
2290 "System.Threading.Monitor::Monitor_pulse_all", ves_icall_System_Threading_Monitor_Monitor_pulse_all,
2291 "System.Threading.Monitor::Monitor_try_enter", ves_icall_System_Threading_Monitor_Monitor_try_enter,
2292 "System.Threading.Monitor::Monitor_wait", ves_icall_System_Threading_Monitor_Monitor_wait,
2293 "System.Threading.Mutex::CreateMutex_internal", ves_icall_System_Threading_Mutex_CreateMutex_internal,
2294 "System.Threading.Mutex::ReleaseMutex_internal", ves_icall_System_Threading_Mutex_ReleaseMutex_internal,
2295 "System.Threading.NativeEventCalls::CreateEvent_internal", ves_icall_System_Threading_Events_CreateEvent_internal,
2296 "System.Threading.NativeEventCalls::SetEvent_internal", ves_icall_System_Threading_Events_SetEvent_internal,
2297 "System.Threading.NativeEventCalls::ResetEvent_internal", ves_icall_System_Threading_Events_ResetEvent_internal,
2300 * System.Threading.WaitHandle
2302 "System.Threading.WaitHandle::WaitAll_internal", ves_icall_System_Threading_WaitHandle_WaitAll_internal,
2303 "System.Threading.WaitHandle::WaitAny_internal", ves_icall_System_Threading_WaitHandle_WaitAny_internal,
2304 "System.Threading.WaitHandle::WaitOne_internal", ves_icall_System_Threading_WaitHandle_WaitOne_internal,
2306 "System.Runtime.InteropServices.Marshal::ReadIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr,
2307 "System.Runtime.InteropServices.Marshal::PtrToStringAuto", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAuto,
2308 "System.Runtime.InteropServices.Marshal::GetLastWin32Error", ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error,
2310 "System.Reflection.Assembly::GetType", ves_icall_System_Reflection_Assembly_GetType,
2311 "System.Reflection.Assembly::GetTypes", ves_icall_System_Reflection_Assembly_GetTypes,
2312 "System.Reflection.Assembly::get_code_base", ves_icall_System_Reflection_Assembly_get_code_base,
2317 "System.MonoType::getFullName", ves_icall_System_MonoType_getFullName,
2318 "System.MonoType::type_from_obj", mono_type_type_from_obj,
2319 "System.MonoType::GetElementType", ves_icall_MonoType_GetElementType,
2320 "System.MonoType::get_type_info", ves_icall_get_type_info,
2321 "System.MonoType::GetFields", ves_icall_Type_GetFields,
2322 "System.MonoType::GetMethods", ves_icall_Type_GetMethods,
2323 "System.MonoType::GetConstructors", ves_icall_Type_GetConstructors,
2324 "System.MonoType::GetProperties", ves_icall_Type_GetProperties,
2325 "System.MonoType::GetEvents", ves_icall_Type_GetEvents,
2326 "System.MonoType::GetInterfaces", ves_icall_Type_GetInterfaces,
2327 "System.MonoType::GetNestedTypes", ves_icall_Type_GetNestedTypes,
2330 * System.Net.Sockets I/O Services
2332 "System.Net.Sockets.Socket::Socket_internal", ves_icall_System_Net_Sockets_Socket_Socket_internal,
2333 "System.Net.Sockets.Socket::Close_internal", ves_icall_System_Net_Sockets_Socket_Close_internal,
2334 "System.Net.Sockets.SocketException::WSAGetLastError_internal", ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal,
2335 "System.Net.Sockets.Socket::Available_internal", ves_icall_System_Net_Sockets_Socket_Available_internal,
2336 "System.Net.Sockets.Socket::Blocking_internal", ves_icall_System_Net_Sockets_Socket_Blocking_internal,
2337 "System.Net.Sockets.Socket::Accept_internal", ves_icall_System_Net_Sockets_Socket_Accept_internal,
2338 "System.Net.Sockets.Socket::Listen_internal", ves_icall_System_Net_Sockets_Socket_Listen_internal,
2339 "System.Net.Sockets.Socket::LocalEndPoint_internal", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal,
2340 "System.Net.Sockets.Socket::RemoteEndPoint_internal", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal,
2341 "System.Net.Sockets.Socket::Bind_internal", ves_icall_System_Net_Sockets_Socket_Bind_internal,
2342 "System.Net.Sockets.Socket::Connect_internal", ves_icall_System_Net_Sockets_Socket_Connect_internal,
2343 "System.Net.Sockets.Socket::Receive_internal", ves_icall_System_Net_Sockets_Socket_Receive_internal,
2344 "System.Net.Sockets.Socket::RecvFrom_internal", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal,
2345 "System.Net.Sockets.Socket::Send_internal", ves_icall_System_Net_Sockets_Socket_Send_internal,
2346 "System.Net.Sockets.Socket::SendTo_internal", ves_icall_System_Net_Sockets_Socket_SendTo_internal,
2347 "System.Net.Sockets.Socket::Select_internal", ves_icall_System_Net_Sockets_Socket_Select_internal,
2348 "System.Net.Sockets.Socket::Shutdown_internal", ves_icall_System_Net_Sockets_Socket_Shutdown_internal,
2349 "System.Net.Sockets.Socket::GetSocketOption_obj_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal,
2350 "System.Net.Sockets.Socket::GetSocketOption_arr_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal,
2351 "System.Net.Sockets.Socket::SetSocketOption_internal", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal,
2352 "System.Net.Dns::GetHostByName_internal", ves_icall_System_Net_Dns_GetHostByName_internal,
2353 "System.Net.Dns::GetHostByAddr_internal", ves_icall_System_Net_Dns_GetHostByAddr_internal,
2358 "System.Char::GetNumericValue", ves_icall_System_Char_GetNumericValue,
2359 "System.Char::GetUnicodeCategory", ves_icall_System_Char_GetUnicodeCategory,
2360 "System.Char::IsControl", ves_icall_System_Char_IsControl,
2361 "System.Char::IsDigit", ves_icall_System_Char_IsDigit,
2362 "System.Char::IsLetter", ves_icall_System_Char_IsLetter,
2363 "System.Char::IsLower", ves_icall_System_Char_IsLower,
2364 "System.Char::IsUpper", ves_icall_System_Char_IsUpper,
2365 "System.Char::IsNumber", ves_icall_System_Char_IsNumber,
2366 "System.Char::IsPunctuation", ves_icall_System_Char_IsPunctuation,
2367 "System.Char::IsSeparator", ves_icall_System_Char_IsSeparator,
2368 "System.Char::IsSurrogate", ves_icall_System_Char_IsSurrogate,
2369 "System.Char::IsSymbol", ves_icall_System_Char_IsSymbol,
2370 "System.Char::IsWhiteSpace", ves_icall_System_Char_IsWhiteSpace,
2371 "System.Char::ToLower", ves_icall_System_Char_ToLower,
2372 "System.Char::ToUpper", ves_icall_System_Char_ToUpper,
2374 "System.Text.Encoding::IConvNewEncoder", ves_icall_iconv_new_encoder,
2375 "System.Text.Encoding::IConvNewDecoder", ves_icall_iconv_new_decoder,
2376 "System.Text.Encoding::IConvReset", ves_icall_iconv_reset,
2377 "System.Text.Encoding::IConvGetByteCount", ves_icall_iconv_get_byte_count,
2378 "System.Text.Encoding::IConvGetBytes", ves_icall_iconv_get_bytes,
2379 "System.Text.Encoding::IConvGetCharCount", ves_icall_iconv_get_char_count,
2380 "System.Text.Encoding::IConvGetChars", ves_icall_iconv_get_chars,
2382 "System.DateTime::GetNow", ves_icall_System_DateTime_GetNow,
2383 "System.CurrentTimeZone::GetTimeZoneData", ves_icall_System_CurrentTimeZone_GetTimeZoneData,
2388 "System.GC::InternalCollect", ves_icall_System_GC_InternalCollect,
2389 "System.GC::GetTotalMemory", ves_icall_System_GC_GetTotalMemory,
2390 "System.GC::KeepAlive", ves_icall_System_GC_KeepAlive,
2391 "System.GC::ReRegisterForFinalize", ves_icall_System_GC_ReRegisterForFinalize,
2392 "System.GC::SuppressFinalize", ves_icall_System_GC_SuppressFinalize,
2393 "System.GC::WaitForPendingFinalizers", ves_icall_System_GC_WaitForPendingFinalizers,
2396 * System.Security.Cryptography calls
2399 "System.Security.Cryptography.RNGCryptoServiceProvider::GetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_GetBytes,
2400 "System.Security.Cryptography.RNGCryptoServiceProvider::GetNonZeroBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_GetNonZeroBytes,
2405 "System.Buffer::ByteLengthInternal", ves_icall_System_Buffer_ByteLengthInternal,
2406 "System.Buffer::GetByteInternal", ves_icall_System_Buffer_GetByteInternal,
2407 "System.Buffer::SetByteInternal", ves_icall_System_Buffer_SetByteInternal,
2408 "System.Buffer::BlockCopyInternal", ves_icall_System_Buffer_BlockCopyInternal,
2413 "System.IO.MonoIO::GetLastError", ves_icall_System_IO_MonoIO_GetLastError,
2414 "System.IO.MonoIO::CreateDirectory", ves_icall_System_IO_MonoIO_CreateDirectory,
2415 "System.IO.MonoIO::RemoveDirectory", ves_icall_System_IO_MonoIO_RemoveDirectory,
2416 "System.IO.MonoIO::FindFirstFile", ves_icall_System_IO_MonoIO_FindFirstFile,
2417 "System.IO.MonoIO::FindNextFile", ves_icall_System_IO_MonoIO_FindNextFile,
2418 "System.IO.MonoIO::FindClose", ves_icall_System_IO_MonoIO_FindClose,
2419 "System.IO.MonoIO::GetCurrentDirectory", ves_icall_System_IO_MonoIO_GetCurrentDirectory,
2420 "System.IO.MonoIO::SetCurrentDirectory", ves_icall_System_IO_MonoIO_SetCurrentDirectory,
2421 "System.IO.MonoIO::MoveFile", ves_icall_System_IO_MonoIO_MoveFile,
2422 "System.IO.MonoIO::CopyFile", ves_icall_System_IO_MonoIO_CopyFile,
2423 "System.IO.MonoIO::DeleteFile", ves_icall_System_IO_MonoIO_DeleteFile,
2424 "System.IO.MonoIO::GetFileAttributes", ves_icall_System_IO_MonoIO_GetFileAttributes,
2425 "System.IO.MonoIO::SetFileAttributes", ves_icall_System_IO_MonoIO_SetFileAttributes,
2426 "System.IO.MonoIO::GetFileStat", ves_icall_System_IO_MonoIO_GetFileStat,
2427 "System.IO.MonoIO::Open", ves_icall_System_IO_MonoIO_Open,
2428 "System.IO.MonoIO::Close", ves_icall_System_IO_MonoIO_Close,
2429 "System.IO.MonoIO::Read", ves_icall_System_IO_MonoIO_Read,
2430 "System.IO.MonoIO::Write", ves_icall_System_IO_MonoIO_Write,
2431 "System.IO.MonoIO::Seek", ves_icall_System_IO_MonoIO_Seek,
2432 "System.IO.MonoIO::GetLength", ves_icall_System_IO_MonoIO_GetLength,
2433 "System.IO.MonoIO::SetLength", ves_icall_System_IO_MonoIO_SetLength,
2434 "System.IO.MonoIO::SetFileTime", ves_icall_System_IO_MonoIO_SetFileTime,
2435 "System.IO.MonoIO::Flush", ves_icall_System_IO_MonoIO_Flush,
2436 "System.IO.MonoIO::get_ConsoleOutput", ves_icall_System_IO_MonoIO_get_ConsoleOutput,
2437 "System.IO.MonoIO::get_ConsoleInput", ves_icall_System_IO_MonoIO_get_ConsoleInput,
2438 "System.IO.MonoIO::get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError,
2439 "System.IO.MonoIO::get_VolumeSeparatorChar", ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar,
2440 "System.IO.MonoIO::get_DirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar,
2441 "System.IO.MonoIO::get_AltDirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar,
2442 "System.IO.MonoIO::get_PathSeparator", ves_icall_System_IO_MonoIO_get_PathSeparator,
2443 "System.IO.MonoIO::get_InvalidPathChars", ves_icall_System_IO_MonoIO_get_InvalidPathChars,
2448 "System.Math::Sin", ves_icall_System_Math_Sin,
2449 "System.Math::Cos", ves_icall_System_Math_Cos,
2450 "System.Math::Tan", ves_icall_System_Math_Tan,
2451 "System.Math::Sinh", ves_icall_System_Math_Sinh,
2452 "System.Math::Cosh", ves_icall_System_Math_Cosh,
2453 "System.Math::Tanh", ves_icall_System_Math_Tanh,
2454 "System.Math::Acos", ves_icall_System_Math_Acos,
2455 "System.Math::Asin", ves_icall_System_Math_Asin,
2456 "System.Math::Atan", ves_icall_System_Math_Atan,
2457 "System.Math::Atan2", ves_icall_System_Math_Atan2,
2458 "System.Math::Exp", ves_icall_System_Math_Exp,
2459 "System.Math::Log", ves_icall_System_Math_Log,
2460 "System.Math::Log10", ves_icall_System_Math_Log10,
2461 "System.Math::Pow", ves_icall_System_Math_Pow,
2462 "System.Math::Sqrt", ves_icall_System_Math_Sqrt,
2465 * System.Environment
2467 "System.Environment::get_MachineName", ves_icall_System_Environment_get_MachineName,
2468 "System.Environment::get_NewLine", ves_icall_System_Environment_get_NewLine,
2469 "System.Environment::GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable,
2470 "System.Environment::GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames,
2471 "System.Environment::GetCommandLineArgs", mono_runtime_get_main_args,
2472 "System.Environment::Exit", ves_icall_System_Environment_Exit,
2475 * Mono.CSharp.Debugger
2477 "Mono.CSharp.Debugger.MonoSymbolWriter::get_local_type_from_sig",
2478 ves_icall_Debugger_MonoSymbolWriter_get_local_type_from_sig,
2479 "Mono.CSharp.Debugger.MonoSymbolWriter::get_method",
2480 ves_icall_Debugger_MonoSymbolWriter_method_from_token,
2481 "Mono.CSharp.Debugger.DwarfFileWriter::get_type_token",
2482 ves_icall_Debugger_DwarfFileWriter_get_type_token,
2486 * System.Runtime.Remoting
2488 "System.Runtime.Remoting.RemotingServices::InternalExecute",
2489 ves_icall_InternalExecute,
2490 "System.Runtime.Remoting.RemotingServices::IsTransparentProxy",
2491 ves_icall_IsTransparentProxy,
2494 * System.Runtime.Remoting.Messaging
2496 "System.Runtime.Remoting.Messaging.MonoMethodMessage::InitMessage",
2497 ves_icall_MonoMethodMessage_InitMessage,
2500 * System.Runtime.Remoting.Proxies
2502 "System.Runtime.Remoting.Proxies.RealProxy::GetTransparentProxy",
2503 ves_icall_Remoting_RealProxy_GetTransparentProxy,
2506 * System.Threading.Interlocked
2508 "System.Threading.Interlocked::Increment(uint&)", ves_icall_System_Threading_Interlocked_Increment_Int,
2509 "System.Threading.Interlocked::Increment(long&)", ves_icall_System_Threading_Interlocked_Increment_Long,
2510 "System.Threading.Interlocked::Decrement(uint&)", ves_icall_System_Threading_Interlocked_Decrement_Int,
2511 "System.Threading.Interlocked::Decrement(long&)", ves_icall_System_Threading_Interlocked_Decrement_Long,
2512 "System.Threading.Interlocked::CompareExchange(uint&,uint,uint)", ves_icall_System_Threading_Interlocked_CompareExchange_Int,
2513 "System.Threading.Interlocked::CompareExchange(object&,object,object)", ves_icall_System_Threading_Interlocked_CompareExchange_Object,
2514 "System.Threading.Interlocked::CompareExchange(single&,single,single)", ves_icall_System_Threading_Interlocked_CompareExchange_Single,
2515 "System.Threading.Interlocked::Exchange(uint&,uint)", ves_icall_System_Threading_Interlocked_Exchange_Int,
2516 "System.Threading.Interlocked::Exchange(object&,object)", ves_icall_System_Threading_Interlocked_Exchange_Object,
2517 "System.Threading.Interlocked::Exchange(single&,single)", ves_icall_System_Threading_Interlocked_Exchange_Single,
2520 * add other internal calls here
2526 mono_init_icall (void)
2531 while ((name = icall_map [i])) {
2532 mono_add_internal_call (name, icall_map [i+1]);