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/rand.h>
35 #include <mono/metadata/sysmath.h>
36 #include <mono/metadata/debug-symfile.h>
37 #include <mono/io-layer/io-layer.h>
41 mono_double_ToStringImpl (double value)
43 /* FIXME: Handle formats, etc. */
45 retVal = g_strdup_printf ("%f", value);
46 return mono_string_new (mono_domain_get (), retVal);
50 ves_icall_System_Array_GetValueImpl (MonoObject *this, guint32 pos)
57 ao = (MonoArray *)this;
58 ac = (MonoClass *)ao->obj.vtable->klass;
60 esize = mono_array_element_size (ac);
61 ea = (gpointer*)((char*)ao->vector + (pos * esize));
63 if (ac->element_class->valuetype)
64 return mono_value_box (this->vtable->domain, ac->element_class, ea);
70 ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs)
76 MONO_CHECK_ARG_NULL (idxs);
78 io = (MonoArray *)idxs;
79 ic = (MonoClass *)io->obj.vtable->klass;
81 ao = (MonoArray *)this;
82 ac = (MonoClass *)ao->obj.vtable->klass;
84 g_assert (ic->rank == 1);
85 if (io->bounds [0].length != ac->rank)
86 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
88 ind = (guint32 *)io->vector;
89 for (i = 0; i < ac->rank; i++)
90 if ((ind [i] < ao->bounds [i].lower_bound) ||
91 (ind [i] >= ao->bounds [i].length + ao->bounds [i].lower_bound))
92 mono_raise_exception (mono_get_exception_index_out_of_range ());
94 pos = ind [0] - ao->bounds [0].lower_bound;
95 for (i = 1; i < ac->rank; i++)
96 pos = pos*ao->bounds [i].length + ind [i] -
97 ao->bounds [i].lower_bound;
99 return ves_icall_System_Array_GetValueImpl (this, pos);
103 ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 pos)
105 MonoClass *ac, *vc, *ec;
114 vc = value->vtable->klass;
118 ac = this->obj.vtable->klass;
119 ec = ac->element_class;
121 esize = mono_array_element_size (ac);
122 ea = (gpointer*)((char*)this->vector + (pos * esize));
123 va = (gpointer*)((char*)value + sizeof (MonoObject));
126 memset (ea, 0, esize);
130 #define NO_WIDENING_CONVERSION G_STMT_START{\
131 mono_raise_exception (mono_get_exception_argument ( \
132 "value", "not a widening conversion")); \
135 #define CHECK_WIDENING_CONVERSION(extra) G_STMT_START{\
136 if (esize < vsize + ## extra) \
137 mono_raise_exception (mono_get_exception_argument ( \
138 "value", "not a widening conversion")); \
141 #define INVALID_CAST G_STMT_START{\
142 mono_raise_exception (mono_get_exception_invalid_cast ()); \
145 /* Check element (destination) type. */
146 switch (ec->byval_arg.type) {
147 case MONO_TYPE_STRING:
148 switch (vc->byval_arg.type) {
149 case MONO_TYPE_STRING:
155 case MONO_TYPE_BOOLEAN:
156 switch (vc->byval_arg.type) {
157 case MONO_TYPE_BOOLEAN:
170 NO_WIDENING_CONVERSION;
177 if (!ec->valuetype) {
178 *ea = (gpointer)value;
182 if (mono_object_isinst (value, ec)) {
183 memcpy (ea, (char *)value + sizeof (MonoObject), esize);
190 vsize = mono_class_instance_size (vc) - sizeof (MonoObject);
193 g_message (G_STRLOC ": %d (%d) <= %d (%d)",
194 ec->byval_arg.type, esize,
195 vc->byval_arg.type, vsize);
198 #define ASSIGN_UNSIGNED(etype) G_STMT_START{\
199 switch (vc->byval_arg.type) { \
204 case MONO_TYPE_CHAR: \
205 CHECK_WIDENING_CONVERSION(0); \
206 *(## etype *) ea = (## etype) u64; \
208 /* You can't assign a signed value to an unsigned array. */ \
213 /* You can't assign a floating point number to an integer array. */ \
216 NO_WIDENING_CONVERSION; \
220 #define ASSIGN_SIGNED(etype) G_STMT_START{\
221 switch (vc->byval_arg.type) { \
226 CHECK_WIDENING_CONVERSION(0); \
227 *(## etype *) ea = (## etype) i64; \
229 /* You can assign an unsigned value to a signed array if the array's */ \
230 /* element size is larger than the value size. */ \
235 case MONO_TYPE_CHAR: \
236 CHECK_WIDENING_CONVERSION(1); \
237 *(## etype *) ea = (## etype) u64; \
239 /* You can't assign a floating point number to an integer array. */ \
242 NO_WIDENING_CONVERSION; \
246 #define ASSIGN_REAL(etype) G_STMT_START{\
247 switch (vc->byval_arg.type) { \
250 CHECK_WIDENING_CONVERSION(0); \
251 *(## etype *) ea = (## etype) r64; \
253 /* All integer values fit into a floating point array, so we don't */ \
254 /* need to CHECK_WIDENING_CONVERSION here. */ \
259 *(## etype *) ea = (## etype) i64; \
265 case MONO_TYPE_CHAR: \
266 *(## etype *) ea = (## etype) u64; \
271 switch (vc->byval_arg.type) {
273 u64 = *(guint8 *) va;
276 u64 = *(guint16 *) va;
279 u64 = *(guint32 *) va;
282 u64 = *(guint64 *) va;
288 i64 = *(gint16 *) va;
291 i64 = *(gint32 *) va;
294 i64 = *(gint64 *) va;
297 r64 = *(gfloat *) va;
300 r64 = *(gdouble *) va;
303 u64 = *(guint16 *) va;
305 case MONO_TYPE_BOOLEAN:
306 /* Boolean is only compatible with itself. */
307 switch (ec->byval_arg.type) {
319 NO_WIDENING_CONVERSION;
326 /* If we can't do a direct copy, let's try a widening conversion. */
327 switch (ec->byval_arg.type) {
329 ASSIGN_UNSIGNED (guint16);
331 ASSIGN_UNSIGNED (guint8);
333 ASSIGN_UNSIGNED (guint16);
335 ASSIGN_UNSIGNED (guint32);
337 ASSIGN_UNSIGNED (guint64);
339 ASSIGN_SIGNED (gint8);
341 ASSIGN_SIGNED (gint16);
343 ASSIGN_SIGNED (gint32);
345 ASSIGN_SIGNED (gint64);
347 ASSIGN_REAL (gfloat);
349 ASSIGN_REAL (gdouble);
353 /* Not reached, INVALID_CAST does not return. Just to avoid a compiler warning ... */
357 #undef NO_WIDENING_CONVERSION
358 #undef CHECK_WIDENING_CONVERSION
359 #undef ASSIGN_UNSIGNED
365 ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value,
371 MONO_CHECK_ARG_NULL (idxs);
373 ic = idxs->obj.vtable->klass;
374 ac = this->obj.vtable->klass;
376 g_assert (ic->rank == 1);
377 if (idxs->bounds [0].length != ac->rank)
378 mono_raise_exception (mono_get_exception_argument (NULL, NULL));
380 ind = (guint32 *)idxs->vector;
381 for (i = 0; i < ac->rank; i++)
382 if ((ind [i] < this->bounds [i].lower_bound) ||
383 (ind [i] >= this->bounds [i].length + this->bounds [i].lower_bound))
384 mono_raise_exception (mono_get_exception_index_out_of_range ());
386 pos = ind [0] - this->bounds [0].lower_bound;
387 for (i = 1; i < ac->rank; i++)
388 pos = pos * this->bounds [i].length + ind [i] -
389 this->bounds [i].lower_bound;
391 ves_icall_System_Array_SetValueImpl (this, value, pos);
395 ves_icall_System_Array_CreateInstanceImpl (MonoReflectionType *type, MonoArray *lengths, MonoArray *bounds)
401 MONO_CHECK_ARG_NULL (type);
402 MONO_CHECK_ARG_NULL (lengths);
404 MONO_CHECK_ARG (lengths, mono_array_length (lengths) > 0);
406 MONO_CHECK_ARG (bounds, mono_array_length (lengths) == mono_array_length (bounds));
408 for (i = 0; i < mono_array_length (lengths); i++)
409 if (mono_array_get (lengths, gint32, i) < 0)
410 mono_raise_exception (mono_get_exception_argument_out_of_range (NULL));
412 aklass = mono_array_class_get (type->type, mono_array_length (lengths));
414 sizes = alloca (aklass->rank * sizeof(guint32) * 2);
415 for (i = 0; i < aklass->rank; ++i) {
416 sizes [i] = mono_array_get (lengths, gint32, i);
418 sizes [i + aklass->rank] = mono_array_get (bounds, gint32, i);
420 sizes [i + aklass->rank] = 0;
423 array = mono_array_new_full (mono_domain_get (), aklass, sizes, sizes + aklass->rank);
429 ves_icall_System_Array_GetRank (MonoObject *this)
431 return this->vtable->klass->rank;
435 ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension)
437 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
438 if ((dimension < 0) || (dimension >= rank))
439 mono_raise_exception (mono_get_exception_index_out_of_range ());
440 return this->bounds [dimension].length;
444 ves_icall_System_Array_GetLowerBound (MonoArray *this, gint32 dimension)
446 gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
447 if ((dimension < 0) || (dimension >= rank))
448 mono_raise_exception (mono_get_exception_index_out_of_range ());
449 return this->bounds [dimension].lower_bound;
453 ves_icall_System_Array_FastCopy (MonoArray *source, int source_idx, MonoArray* dest, int dest_idx, int length)
455 int element_size = mono_array_element_size (source->obj.vtable->klass);
456 void * dest_addr = mono_array_addr_with_size (dest, element_size, dest_idx);
457 void * source_addr = mono_array_addr_with_size (source, element_size, source_idx);
459 g_assert (dest_idx + length <= mono_array_length (dest));
460 g_assert (source_idx + length <= mono_array_length (source));
461 memmove (dest_addr, source_addr, element_size * length);
465 ves_icall_InitializeArray (MonoArray *array, MonoClassField *field_handle)
467 MonoClass *klass = array->obj.vtable->klass;
468 guint32 size = mono_array_element_size (klass);
471 for (i = 0; i < klass->rank; ++i)
472 size *= array->bounds [i].length;
474 memcpy (mono_array_addr (array, char, 0), field_handle->data, size);
476 #if G_BYTE_ORDER != G_LITTLE_ENDIAN
480 guint ## n *data = (guint ## n *) mono_array_addr (array, char, 0); \
482 for (i = 0; i < size; i += n/8, data++) { \
483 tmp = read ## n (data); \
488 printf ("Initialize array with elements of %s type\n", klass->element_class->name);
490 switch (klass->element_class->byval_arg.type) {
510 ves_icall_System_Object_MemberwiseClone (MonoObject *this)
512 return mono_object_clone (this);
516 ves_icall_System_Object_GetHashCode (MonoObject *this)
518 return *((gint32 *)this - 1);
522 * A hash function for value types. I have no idea if this is a good hash
523 * function (its similar to g_str_hash).
526 ves_icall_System_ValueType_GetHashCode (MonoObject *this)
532 MONO_CHECK_ARG_NULL (this);
534 size = this->vtable->klass->instance_size - sizeof (MonoObject);
536 p = (const char *)this + sizeof (MonoObject);
538 for (i = 0; i < size; i++) {
539 h = (h << 5) - h + *p;
547 ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that)
552 MONO_CHECK_ARG_NULL (that);
554 if (this->vtable != that->vtable)
557 size = this->vtable->klass->instance_size - sizeof (MonoObject);
559 p = (const char *)this + sizeof (MonoObject);
560 s = (const char *)that + sizeof (MonoObject);
562 return memcmp (p, s, size)? FALSE: TRUE;
565 static MonoReflectionType *
566 ves_icall_System_Object_GetType (MonoObject *obj)
568 return mono_type_get_object (mono_domain_get (), &obj->vtable->klass->byval_arg);
572 mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
574 mtype->type = &obj->vtable->klass->byval_arg;
575 g_assert (mtype->type->type);
579 ves_icall_AssemblyBuilder_getToken (MonoReflectionAssemblyBuilder *assb, MonoObject *obj)
581 return mono_image_create_token (assb->dynamic_assembly, obj);
585 ves_icall_AssemblyBuilder_getPEHeader (MonoReflectionAssemblyBuilder *assb, MonoArray *buf, gint32 *data_size)
588 MonoDynamicAssembly *ass = assb->dynamic_assembly;
590 hsize = mono_image_get_header (assb, (char*)buf->vector, buf->bounds->length);
593 count = ass->code.index + ass->meta_size;
602 ves_icall_AssemblyBuilder_getDataChunk (MonoReflectionAssemblyBuilder *assb, MonoArray *buf)
604 int count, real_data;
605 MonoDynamicAssembly *ass = assb->dynamic_assembly;
606 char *p = mono_array_addr (buf, char, 0);
608 count = real_data = ass->code.index + ass->meta_size;
611 if (count > mono_array_length (buf))
615 memcpy (p, ass->code.data, ass->code.index);
616 p += ass->code.index;
617 memcpy (p, ass->assembly.image->raw_metadata, ass->meta_size);
619 /* null-pad section */
620 memset (p, 0, count);
622 return real_data + count;
625 static MonoReflectionType*
626 ves_icall_type_from_name (MonoString *name)
628 MonoDomain *domain = mono_domain_get ();
631 MonoTypeNameParse info;
634 str = mono_string_to_utf8 (name);
635 /*g_print ("requested type %s\n", str);*/
636 if (!mono_reflection_parse_type (str, &info)) {
638 g_list_free (info.modifiers);
643 image = mono_image_loaded (info.assembly);
644 /* do we need to load if it's not already loaded? */
647 g_list_free (info.modifiers);
651 image = mono_defaults.corlib;
653 type = mono_reflection_get_type (image, &info, FALSE);
655 g_list_free (info.modifiers);
658 /*g_print ("got it\n");*/
659 return mono_type_get_object (domain, type);
662 static MonoReflectionType*
663 ves_icall_type_from_handle (MonoType *handle)
665 MonoDomain *domain = mono_domain_get ();
666 MonoClass *klass = mono_class_from_mono_type (handle);
668 mono_class_init (klass);
669 return mono_type_get_object (domain, handle);
673 ves_icall_type_Equals (MonoReflectionType *type, MonoReflectionType *c)
675 if (type->type && c->type)
676 return mono_metadata_type_equal (type->type, c->type);
677 g_print ("type equals\n");
682 ves_icall_type_is_subtype_of (MonoReflectionType *type, MonoReflectionType *c, MonoBoolean check_interfaces)
688 g_assert (type != NULL);
690 domain = ((MonoObject *)type)->vtable->domain;
692 if (!c) /* FIXME: dont know what do do here */
695 klass = mono_class_from_mono_type (type->type);
696 klassc = mono_class_from_mono_type (c->type);
698 /* cut&paste from mono_object_isinst (): keep in sync */
699 if (check_interfaces && (klassc->flags & TYPE_ATTRIBUTE_INTERFACE) && !(klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
700 MonoVTable *klass_vt = mono_class_vtable (domain, klass);
701 if ((klassc->interface_id <= klass->max_interface_id) &&
702 klass_vt->interface_offsets [klassc->interface_id])
704 } else if (check_interfaces && (klassc->flags & TYPE_ATTRIBUTE_INTERFACE) && (klass->flags & TYPE_ATTRIBUTE_INTERFACE)) {
707 for (i = 0; i < klass->interface_count; i ++) {
708 MonoClass *ic = klass->interfaces [i];
714 * klass->baseval is 0 for interfaces
716 if (klass->baseval && ((klass->baseval - klassc->baseval) <= klassc->diffval))
723 ves_icall_get_attributes (MonoReflectionType *type)
725 MonoClass *klass = mono_class_from_mono_type (type->type);
731 ves_icall_MonoMethod_get_Name (MonoReflectionMethod *method)
733 return mono_string_new (mono_object_domain (method), method->method->name);
737 ves_icall_get_method_info (MonoMethod *method, MonoMethodInfo *info)
739 MonoDomain *domain = mono_domain_get ();
741 info->parent = mono_type_get_object (domain, &method->klass->byval_arg);
742 info->ret = mono_type_get_object (domain, method->signature->ret);
743 info->name = mono_string_new (domain, method->name);
744 info->attrs = method->flags;
745 info->implattrs = method->iflags;
749 ves_icall_get_parameter_info (MonoMethod *method)
751 MonoDomain *domain = mono_domain_get ();
753 static MonoClass *System_Reflection_ParameterInfo;
754 MonoReflectionParameter** args;
757 args = mono_param_get_objects (domain, method);
758 if (!System_Reflection_ParameterInfo)
759 System_Reflection_ParameterInfo = mono_class_from_name (
760 mono_defaults.corlib, "System.Reflection", "ParameterInfo");
761 res = mono_array_new (domain, System_Reflection_ParameterInfo, method->signature->param_count);
762 for (i = 0; i < method->signature->param_count; ++i) {
763 mono_array_set (res, gpointer, i, args [i]);
769 ves_icall_get_field_info (MonoReflectionField *field, MonoFieldInfo *info)
771 MonoDomain *domain = mono_domain_get ();
773 info->parent = mono_type_get_object (domain, &field->klass->byval_arg);
774 info->type = mono_type_get_object (domain, field->field->type);
775 info->name = mono_string_new (domain, field->field->name);
776 info->attrs = field->field->type->attrs;
780 ves_icall_MonoField_GetValue (MonoReflectionField *field, MonoObject *obj) {
783 MonoType *ftype = field->field->type;
784 int type = ftype->type;
788 mono_class_init (field->klass);
789 if (ftype->attrs & FIELD_ATTRIBUTE_STATIC) {
791 vtable = mono_class_vtable (mono_domain_get (), field->klass);
792 p = (char*)(vtable->data) + field->field->offset;
794 p = (char*)obj + field->field->offset;
798 case MONO_TYPE_OBJECT:
799 case MONO_TYPE_STRING:
800 case MONO_TYPE_SZARRAY:
801 case MONO_TYPE_ARRAY:
802 return *(MonoObject**)p;
804 klass = mono_class_from_mono_type (ftype);
805 res = mono_object_new (mono_domain_get (), klass);
806 r = (char*)res + sizeof (MonoObject);
807 memcpy (r, p, mono_class_value_size (klass, &align));
813 ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info)
815 MonoDomain *domain = mono_domain_get ();
817 info->parent = mono_type_get_object (domain, &property->klass->byval_arg);
818 info->name = mono_string_new (domain, property->property->name);
819 info->attrs = property->property->attrs;
820 info->get = property->property->get ? mono_method_get_object (domain, property->property->get): NULL;
821 info->set = property->property->set ? mono_method_get_object (domain, property->property->set): NULL;
823 * There may be other methods defined for properties, though, it seems they are not exposed
824 * in the reflection API
829 ves_icall_Type_GetInterfaces (MonoReflectionType* type)
831 MonoDomain *domain = mono_domain_get ();
834 MonoClass *class = mono_class_from_mono_type (type->type);
838 for (parent = class; parent; parent = parent->parent) {
839 ninterf += parent->interface_count;
841 intf = mono_array_new (domain, mono_defaults.monotype_class, ninterf);
843 for (parent = class; parent; parent = parent->parent) {
844 for (i = 0; i < parent->interface_count; ++i) {
845 mono_array_set (intf, gpointer, ninterf, mono_type_get_object (domain, &parent->interfaces [i]->byval_arg));
853 ves_icall_get_type_info (MonoType *type, MonoTypeInfo *info)
855 MonoDomain *domain = mono_domain_get ();
856 MonoClass *class = mono_class_from_mono_type (type);
858 info->parent = class->parent ? mono_type_get_object (domain, &class->parent->byval_arg): NULL;
859 info->name = mono_string_new (domain, class->name);
860 info->name_space = mono_string_new (domain, class->name_space);
861 info->attrs = class->flags;
862 info->rank = class->rank;
863 info->assembly = mono_assembly_get_object (domain, class->image->assembly);
864 if (class->enumtype && class->enum_basetype) /* types that are modifierd typebuilkders may not have enum_basetype set */
865 info->etype = mono_type_get_object (domain, class->enum_basetype);
866 else if (class->element_class)
867 info->etype = mono_type_get_object (domain, &class->element_class->byval_arg);
871 info->isbyref = type->byref;
872 info->ispointer = type->type == MONO_TYPE_PTR;
873 info->isprimitive = (type->type >= MONO_TYPE_BOOLEAN) && (type->type <= MONO_TYPE_R8);
877 ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params)
879 return mono_runtime_invoke_array (method->method, this, params);
883 ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoArray *params, MonoArray **outArgs)
885 MonoDomain *domain = mono_domain_get ();
886 MonoMethod *m = method->method;
887 MonoMethodSignature *sig = m->signature;
890 int i, j, outarg_count = 0;
892 if (m->klass == mono_defaults.object_class) {
894 if (!strcmp (m->name, "FieldGetter")) {
895 MonoClass *k = this->vtable->klass;
896 MonoString *name = mono_array_get (params, MonoString *, 1);
899 str = mono_string_to_utf8 (name);
901 for (i = 0; i < k->field.count; i++) {
902 if (!strcmp (k->fields [i].name, str)) {
903 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
904 if (field_klass->valuetype)
905 result = mono_value_box (domain, field_klass,
906 (char *)this + k->fields [i].offset);
908 result = *((gpointer *)((char *)this + k->fields [i].offset));
911 out_args = mono_array_new (domain, mono_defaults.object_class, 1);
913 mono_array_set (out_args, gpointer, 0, result);
920 g_assert_not_reached ();
922 } else if (!strcmp (m->name, "FieldSetter")) {
923 MonoClass *k = this->vtable->klass;
924 MonoString *name = mono_array_get (params, MonoString *, 1);
928 str = mono_string_to_utf8 (name);
930 for (i = 0; i < k->field.count; i++) {
931 if (!strcmp (k->fields [i].name, str)) {
932 MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
933 MonoObject *val = mono_array_get (params, gpointer, 2);
935 if (field_klass->valuetype) {
936 size = mono_type_size (k->fields [i].type, &align);
937 memcpy ((char *)this + k->fields [i].offset,
938 ((char *)val) + sizeof (MonoObject), size);
940 *((gpointer *)this + k->fields [i].offset) = val;
949 g_assert_not_reached ();
954 for (i = 0; i < params->bounds->length; i++) {
955 if (sig->params [i]->byref)
959 out_args = mono_array_new (domain, mono_defaults.object_class, outarg_count);
961 for (i = 0, j = 0; i < params->bounds->length; i++) {
962 if (sig->params [i]->byref) {
964 arg = mono_array_get (params, gpointer, i);
965 mono_array_set (out_args, gpointer, j, arg);
970 /* fixme: handle constructors? */
971 if (!strcmp (method->method->name, ".ctor"))
972 g_assert_not_reached ();
974 result = mono_runtime_invoke_array (method->method, this, params);
982 ves_icall_System_Enum_ToObject (MonoReflectionType *type, MonoObject *obj)
984 MonoDomain *domain = mono_domain_get ();
985 MonoClass *enumc, *objc;
989 MONO_CHECK_ARG_NULL (type);
990 MONO_CHECK_ARG_NULL (obj);
992 enumc = mono_class_from_mono_type (type->type);
993 objc = obj->vtable->klass;
995 MONO_CHECK_ARG (obj, enumc->enumtype == TRUE);
996 MONO_CHECK_ARG (obj, (objc->enumtype) || (objc->byval_arg.type >= MONO_TYPE_I1 &&
997 objc->byval_arg.type <= MONO_TYPE_U8));
999 s1 = mono_class_value_size (enumc, NULL);
1000 s2 = mono_class_value_size (objc, NULL);
1002 res = mono_object_new (domain, enumc);
1004 #if G_BYTE_ORDER == G_LITTLE_ENDIAN
1005 memcpy ((char *)res + sizeof (MonoObject), (char *)obj + sizeof (MonoObject), MIN (s1, s2));
1007 memcpy ((char *)res + sizeof (MonoObject) + (s1 > s2 ? s1 - s2 : 0),
1008 (char *)obj + sizeof (MonoObject) + (s2 > s1 ? s2 - s1 : 0),
1015 ves_icall_System_Enum_get_value (MonoObject *this)
1017 MonoDomain *domain = mono_domain_get ();
1027 g_assert (this->vtable->klass->enumtype);
1029 enumc = mono_class_from_mono_type (this->vtable->klass->enum_basetype);
1030 res = mono_object_new (domain, enumc);
1031 dst = (char *)res + sizeof (MonoObject);
1032 src = (char *)this + sizeof (MonoObject);
1033 size = mono_class_value_size (enumc, NULL);
1035 memcpy (dst, src, size);
1041 ves_icall_get_enum_info (MonoReflectionType *type, MonoEnumInfo *info)
1043 MonoDomain *domain = mono_domain_get ();
1044 MonoClass *enumc = mono_class_from_mono_type (type->type);
1045 guint i, j, nvalues, crow;
1046 MonoClassField *field;
1048 info->utype = mono_type_get_object (domain, enumc->enum_basetype);
1049 nvalues = enumc->field.count - 1;
1050 info->names = mono_array_new (domain, mono_defaults.string_class, nvalues);
1051 info->values = mono_array_new (domain, enumc, nvalues);
1053 for (i = 0, j = 0; i < enumc->field.count; ++i) {
1054 field = &enumc->fields [i];
1055 if (strcmp ("value__", field->name) == 0)
1057 mono_array_set (info->names, gpointer, j, mono_string_new (domain, field->name));
1059 crow = mono_metadata_get_constant_index (enumc->image, MONO_TOKEN_FIELD_DEF | (i+enumc->field.first+1));
1060 crow = mono_metadata_decode_row_col (&enumc->image->tables [MONO_TABLE_CONSTANT], crow-1, MONO_CONSTANT_VALUE);
1061 /* 1 is the length of the blob */
1062 field->data = 1 + mono_metadata_blob_heap (enumc->image, crow);
1064 switch (enumc->enum_basetype->type) {
1067 mono_array_set (info->values, gchar, j, *field->data);
1069 case MONO_TYPE_CHAR:
1072 mono_array_set (info->values, gint16, j, read16 (field->data));
1076 mono_array_set (info->values, gint32, j, read32 (field->data));
1080 mono_array_set (info->values, gint64, j, read64 (field->data));
1083 g_error ("Implement type 0x%02x in get_enum_info", enumc->enum_basetype->type);
1090 search_method (MonoReflectionType *type, const char *name, guint32 flags, MonoArray *args)
1092 MonoClass *klass, *start_class;
1094 MonoReflectionType *paramt;
1097 start_class = klass = mono_class_from_mono_type (type->type);
1099 for (i = 0; i < klass->method.count; ++i) {
1100 m = klass->methods [i];
1101 if (!((m->flags & flags) == flags))
1103 if (strcmp(m->name, name))
1105 if (m->signature->param_count != mono_array_length (args))
1107 for (j = 0; j < m->signature->param_count; ++j) {
1108 paramt = mono_array_get (args, MonoReflectionType*, j);
1109 if (!mono_metadata_type_equal (paramt->type, m->signature->params [j]))
1112 if (j == m->signature->param_count)
1115 klass = klass->parent;
1117 g_print ("Method %s.%s::%s (%d) not found\n", start_class->name_space, start_class->name, name, mono_array_length (args));
1121 static MonoReflectionMethod*
1122 ves_icall_get_constructor (MonoReflectionType *type, MonoArray *args)
1124 MonoDomain *domain = mono_domain_get ();
1127 m = search_method (type, ".ctor", METHOD_ATTRIBUTE_RT_SPECIAL_NAME, args);
1129 return mono_method_get_object (domain, m);
1133 static MonoReflectionMethod*
1134 ves_icall_get_method (MonoReflectionType *type, MonoString *name, MonoArray *args)
1136 MonoDomain *domain = mono_domain_get ();
1138 char *n = mono_string_to_utf8 (name);
1140 m = search_method (type, n, 0, args);
1143 return mono_method_get_object (domain, m);
1147 static MonoProperty*
1148 search_property (MonoClass *klass, char* name, MonoArray *args) {
1152 /* FIXME: handle args */
1153 for (i = 0; i < klass->property.count; ++i) {
1154 p = &klass->properties [i];
1155 if (strcmp (p->name, name) == 0)
1161 static MonoReflectionProperty*
1162 ves_icall_get_property (MonoReflectionType *type, MonoString *name, MonoArray *args)
1164 MonoDomain *domain = mono_domain_get ();
1166 MonoClass *class = mono_class_from_mono_type (type->type);
1167 char *n = mono_string_to_utf8 (name);
1169 p = search_property (class, n, args);
1172 return mono_property_get_object (domain, class, p);
1177 BFLAGS_IgnoreCase = 1,
1178 BFLAGS_DeclaredOnly = 2,
1179 BFLAGS_Instance = 4,
1181 BFLAGS_Public = 0x10,
1182 BFLAGS_NonPublic = 0x20,
1183 BFLAGS_InvokeMethod = 0x100,
1184 BFLAGS_CreateInstance = 0x200,
1185 BFLAGS_GetField = 0x400,
1186 BFLAGS_SetField = 0x800,
1187 BFLAGS_GetProperty = 0x1000,
1188 BFLAGS_SetProperty = 0x2000,
1189 BFLAGS_ExactBinding = 0x10000,
1190 BFLAGS_SuppressChangeType = 0x20000,
1191 BFLAGS_OptionalParamBinding = 0x40000
1195 ves_icall_Type_GetFields (MonoReflectionType *type, guint32 bflags)
1198 GSList *l = NULL, *tmp;
1199 static MonoClass *System_Reflection_FieldInfo;
1200 MonoClass *startklass, *klass;
1204 MonoClassField *field;
1206 domain = ((MonoObject *)type)->vtable->domain;
1207 klass = startklass = mono_class_from_mono_type (type->type);
1210 for (i = 0; i < klass->field.count; ++i) {
1212 field = &klass->fields [i];
1213 if ((field->type->attrs & FIELD_ATTRIBUTE_FIELD_ACCESS_MASK) == FIELD_ATTRIBUTE_PUBLIC) {
1214 if (bflags & BFLAGS_Public)
1217 if (bflags & BFLAGS_NonPublic)
1223 if (field->type->attrs & FIELD_ATTRIBUTE_STATIC) {
1224 if (bflags & BFLAGS_Static)
1227 if (bflags & BFLAGS_Instance)
1233 member = (MonoObject*)mono_field_get_object (domain, klass, field);
1234 l = g_slist_prepend (l, member);
1236 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1238 len = g_slist_length (l);
1239 if (!System_Reflection_FieldInfo)
1240 System_Reflection_FieldInfo = mono_class_from_name (
1241 mono_defaults.corlib, "System.Reflection", "FieldInfo");
1242 res = mono_array_new (domain, System_Reflection_FieldInfo, len);
1244 tmp = g_slist_reverse (l);
1245 for (; tmp; tmp = tmp->next, ++i)
1246 mono_array_set (res, gpointer, i, tmp->data);
1252 ves_icall_Type_GetMethods (MonoReflectionType *type, guint32 bflags)
1255 GSList *l = NULL, *tmp;
1256 static MonoClass *System_Reflection_MethodInfo;
1257 MonoClass *startklass, *klass;
1263 domain = ((MonoObject *)type)->vtable->domain;
1264 klass = startklass = mono_class_from_mono_type (type->type);
1267 for (i = 0; i < klass->method.count; ++i) {
1269 method = klass->methods [i];
1270 if (strcmp (method->name, ".ctor") == 0 || strcmp (method->name, ".cctor") == 0)
1272 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1273 if (bflags & BFLAGS_Public)
1276 if (bflags & BFLAGS_NonPublic)
1282 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1283 if (bflags & BFLAGS_Static)
1286 if (bflags & BFLAGS_Instance)
1293 member = (MonoObject*)mono_method_get_object (domain, method);
1295 l = g_slist_prepend (l, member);
1297 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1299 len = g_slist_length (l);
1300 if (!System_Reflection_MethodInfo)
1301 System_Reflection_MethodInfo = mono_class_from_name (
1302 mono_defaults.corlib, "System.Reflection", "MethodInfo");
1303 res = mono_array_new (domain, System_Reflection_MethodInfo, len);
1306 for (; tmp; tmp = tmp->next, ++i)
1307 mono_array_set (res, gpointer, i, tmp->data);
1313 ves_icall_Type_GetConstructors (MonoReflectionType *type, guint32 bflags)
1316 GSList *l = NULL, *tmp;
1317 static MonoClass *System_Reflection_ConstructorInfo;
1318 MonoClass *startklass, *klass;
1324 domain = ((MonoObject *)type)->vtable->domain;
1325 klass = startklass = mono_class_from_mono_type (type->type);
1328 for (i = 0; i < klass->method.count; ++i) {
1330 method = klass->methods [i];
1331 if (strcmp (method->name, ".ctor") && strcmp (method->name, ".cctor"))
1333 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1334 if (bflags & BFLAGS_Public)
1337 if (bflags & BFLAGS_NonPublic)
1343 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1344 if (bflags & BFLAGS_Static)
1347 if (bflags & BFLAGS_Instance)
1353 member = (MonoObject*)mono_method_get_object (domain, method);
1355 l = g_slist_prepend (l, member);
1357 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1359 len = g_slist_length (l);
1360 if (!System_Reflection_ConstructorInfo)
1361 System_Reflection_ConstructorInfo = mono_class_from_name (
1362 mono_defaults.corlib, "System.Reflection", "ConstructorInfo");
1363 res = mono_array_new (domain, System_Reflection_ConstructorInfo, len);
1366 for (; tmp; tmp = tmp->next, ++i)
1367 mono_array_set (res, gpointer, i, tmp->data);
1373 ves_icall_Type_GetProperties (MonoReflectionType *type, guint32 bflags)
1376 GSList *l = NULL, *tmp;
1377 static MonoClass *System_Reflection_PropertyInfo;
1378 MonoClass *startklass, *klass;
1384 domain = ((MonoObject *)type)->vtable->domain;
1385 klass = startklass = mono_class_from_mono_type (type->type);
1388 for (i = 0; i < klass->property.count; ++i) {
1389 prop = &klass->properties [i];
1394 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1395 if (bflags & BFLAGS_Public)
1398 if (bflags & BFLAGS_NonPublic)
1404 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1405 if (bflags & BFLAGS_Static)
1408 if (bflags & BFLAGS_Instance)
1415 l = g_slist_prepend (l, mono_property_get_object (domain, klass, prop));
1417 if (!l && (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent)))
1419 len = g_slist_length (l);
1420 if (!System_Reflection_PropertyInfo)
1421 System_Reflection_PropertyInfo = mono_class_from_name (
1422 mono_defaults.corlib, "System.Reflection", "PropertyInfo");
1423 res = mono_array_new (domain, System_Reflection_PropertyInfo, len);
1426 for (; tmp; tmp = tmp->next, ++i)
1427 mono_array_set (res, gpointer, i, tmp->data);
1433 ves_icall_Type_GetEvents (MonoReflectionType *type, guint32 bflags)
1436 GSList *l = NULL, *tmp;
1437 static MonoClass *System_Reflection_EventInfo;
1438 MonoClass *startklass, *klass;
1444 domain = ((MonoObject *)type)->vtable->domain;
1445 klass = startklass = mono_class_from_mono_type (type->type);
1448 for (i = 0; i < klass->event.count; ++i) {
1449 event = &klass->events [i];
1451 method = event->add;
1453 method = event->remove;
1454 if ((method->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) == METHOD_ATTRIBUTE_PUBLIC) {
1455 if (bflags & BFLAGS_Public)
1458 if (bflags & BFLAGS_NonPublic)
1464 if (method->flags & METHOD_ATTRIBUTE_STATIC) {
1465 if (bflags & BFLAGS_Static)
1468 if (bflags & BFLAGS_Instance)
1475 l = g_slist_prepend (l, mono_event_get_object (domain, klass, event));
1477 if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
1479 len = g_slist_length (l);
1480 if (!System_Reflection_EventInfo)
1481 System_Reflection_EventInfo = mono_class_from_name (
1482 mono_defaults.corlib, "System.Reflection", "EventInfo");
1483 res = mono_array_new (domain, System_Reflection_EventInfo, len);
1486 for (; tmp; tmp = tmp->next, ++i)
1487 mono_array_set (res, gpointer, i, tmp->data);
1493 ves_icall_Type_GetNestedTypes (MonoReflectionType *type, guint32 bflags)
1496 GSList *l = NULL, *tmp;
1498 MonoClass *startklass, *klass;
1504 domain = ((MonoObject *)type)->vtable->domain;
1505 klass = startklass = mono_class_from_mono_type (type->type);
1507 for (tmpn = klass->nested_classes; tmpn; tmpn = tmpn->next) {
1509 nested = tmpn->data;
1510 if ((nested->flags & TYPE_ATTRIBUTE_VISIBILITY_MASK) == TYPE_ATTRIBUTE_NESTED_PUBLIC) {
1511 if (bflags & BFLAGS_Public)
1514 if (bflags & BFLAGS_NonPublic)
1519 member = (MonoObject*)mono_type_get_object (domain, &nested->byval_arg);
1520 l = g_slist_prepend (l, member);
1522 len = g_slist_length (l);
1523 res = mono_array_new (domain, mono_defaults.monotype_class, len);
1525 tmp = g_slist_reverse (l);
1526 for (; tmp; tmp = tmp->next, ++i)
1527 mono_array_set (res, gpointer, i, tmp->data);
1533 ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr (gpointer ptr)
1535 return (gpointer)(*(int *)ptr);
1539 ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAuto (gpointer ptr)
1541 MonoDomain *domain = mono_domain_get ();
1543 return mono_string_new (domain, (char *)ptr);
1546 static guint32 ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error(void)
1548 return(GetLastError());
1551 static MonoReflectionType*
1552 ves_icall_System_Reflection_Assembly_GetType (MonoReflectionAssembly *assembly, MonoString *name, MonoBoolean throwOnError, MonoBoolean ignoreCase)
1554 MonoDomain *domain = mono_domain_get ();
1557 MonoTypeNameParse info;
1559 str = mono_string_to_utf8 (name);
1560 /*g_print ("requested type %s in %s\n", str, assembly->assembly->name);*/
1561 if (!mono_reflection_parse_type (str, &info)) {
1563 g_list_free (info.modifiers);
1564 if (throwOnError) /* uhm: this is a parse error, though... */
1565 mono_raise_exception (mono_get_exception_type_load ());
1569 type = mono_reflection_get_type (assembly->assembly->image, &info, ignoreCase);
1571 g_list_free (info.modifiers);
1574 mono_raise_exception (mono_get_exception_type_load ());
1577 /*g_print ("got it\n");*/
1578 return mono_type_get_object (domain, type);
1583 ves_icall_System_Reflection_Assembly_get_code_base (MonoReflectionAssembly *assembly)
1585 MonoDomain *domain = mono_domain_get ();
1587 char *name = g_strconcat (
1588 "file://", assembly->assembly->image->name, NULL);
1590 res = mono_string_new (domain, name);
1596 ves_icall_System_MonoType_getFullName (MonoReflectionType *object)
1598 MonoDomain *domain = mono_domain_get ();
1602 name = mono_type_get_name (object->type);
1603 res = mono_string_new (domain, name);
1610 ves_icall_System_Reflection_Assembly_GetTypes (MonoReflectionAssembly *assembly, MonoBoolean exportedOnly)
1612 MonoDomain *domain = mono_domain_get ();
1615 MonoTableInfo *tdef = &assembly->assembly->image->tables [MONO_TABLE_TYPEDEF];
1617 guint32 attrs, visibility;
1621 for (i = 0; i < tdef->rows; ++i) {
1622 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
1623 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
1624 if (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)
1630 res = mono_array_new (domain, mono_defaults.monotype_class, count);
1632 for (i = 0; i < tdef->rows; ++i) {
1633 attrs = mono_metadata_decode_row_col (tdef, i, MONO_TYPEDEF_FLAGS);
1634 visibility = attrs & TYPE_ATTRIBUTE_VISIBILITY_MASK;
1635 if (!exportedOnly || (visibility == TYPE_ATTRIBUTE_PUBLIC || visibility == TYPE_ATTRIBUTE_NESTED_PUBLIC)) {
1636 klass = mono_class_get (assembly->assembly->image, (i + 1) | MONO_TOKEN_TYPE_DEF);
1637 mono_array_set (res, gpointer, count, mono_type_get_object (domain, &klass->byval_arg));
1645 static MonoReflectionType*
1646 ves_icall_ModuleBuilder_create_modified_type (MonoReflectionTypeBuilder *tb, MonoString *smodifiers)
1649 int isbyref = 0, rank;
1650 char *str = mono_string_to_utf8 (smodifiers);
1653 klass = mono_class_from_mono_type (tb->type.type);
1655 /* logic taken from mono_reflection_parse_type(): keep in sync */
1659 if (isbyref) /* only one level allowed by the spec */
1663 return mono_type_get_object (mono_domain_get (), &klass->this_arg);
1666 klass = mono_ptr_class_get (&klass->byval_arg);
1667 mono_class_init (klass);
1678 else if (*p != '*') /* '*' means unknown lower bound */
1685 klass = mono_array_class_get (&klass->byval_arg, rank);
1686 mono_class_init (klass);
1693 return mono_type_get_object (mono_domain_get (), &klass->byval_arg);
1697 * Magic number to convert a time which is relative to
1698 * Jan 1, 1970 into a value which is relative to Jan 1, 0001.
1700 #define EPOCH_ADJUST ((gint64)62135596800L)
1703 ves_icall_System_DateTime_GetNow (void)
1705 #ifndef PLATFORM_WIN32
1706 /* FIXME: put this in io-layer and call it GetLocalTime */
1710 if (gettimeofday (&tv, NULL) == 0) {
1711 res = (((gint64)tv.tv_sec + EPOCH_ADJUST)* 1000000 + tv.tv_usec)*10;
1715 /* fixme: raise exception */
1721 * This is heavily based on zdump.c from glibc 2.2.
1723 * * data[0]: start of daylight saving time (in DateTime ticks).
1724 * * data[1]: end of daylight saving time (in DateTime ticks).
1725 * * data[2]: utcoffset (in TimeSpan ticks).
1726 * * data[3]: additional offset when daylight saving (in TimeSpan ticks).
1727 * * name[0]: name of this timezone when not daylight saving.
1728 * * name[1]: name of this timezone when daylight saving.
1730 * FIXME: This only works with "standard" Unix dates (years between 1900 and 2100) while
1731 * the class library allows years between 1 and 9999.
1733 * Returns true on success and zero on failure.
1736 ves_icall_System_CurrentTimeZone_GetTimeZoneData (guint32 year, MonoArray **data, MonoArray **names)
1738 #ifndef PLATFORM_WIN32
1739 MonoDomain *domain = mono_domain_get ();
1740 struct tm start, tt;
1744 int is_daylight = 0, day;
1746 memset (&start, 0, sizeof (start));
1749 start.tm_year = year-1900;
1751 t = mktime (&start);
1752 gmtoff = start.tm_gmtoff;
1754 MONO_CHECK_ARG_NULL (data);
1755 MONO_CHECK_ARG_NULL (names);
1757 (*data) = mono_array_new (domain, mono_defaults.int64_class, 4);
1758 (*names) = mono_array_new (domain, mono_defaults.string_class, 2);
1760 /* For each day of the year, calculate the tm_gmtoff. */
1761 for (day = 0; day < 365; day++) {
1764 tt = *localtime (&t);
1766 /* Daylight saving starts or ends here. */
1767 if (tt.tm_gmtoff != gmtoff) {
1771 /* Try to find the exact hour when daylight saving starts/ends. */
1775 tt1 = *localtime (&t1);
1776 } while (tt1.tm_gmtoff != gmtoff);
1778 /* Try to find the exact minute when daylight saving starts/ends. */
1781 tt1 = *localtime (&t1);
1782 } while (tt1.tm_gmtoff == gmtoff);
1784 /* Write data, if we're already in daylight saving, we're done. */
1786 mono_array_set ((*names), gpointer, 0, mono_string_new (domain, tt.tm_zone));
1787 mono_array_set ((*data), gint64, 1, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
1790 mono_array_set ((*names), gpointer, 1, mono_string_new (domain, tt.tm_zone));
1791 mono_array_set ((*data), gint64, 0, ((gint64)t1 + EPOCH_ADJUST) * 10000000L);
1795 /* This is only set once when we enter daylight saving. */
1796 mono_array_set ((*data), gint64, 2, (gint64)gmtoff * 10000000L);
1797 mono_array_set ((*data), gint64, 3, (gint64)(tt.tm_gmtoff - gmtoff) * 10000000L);
1799 gmtoff = tt.tm_gmtoff;
1802 gmtoff = tt.tm_gmtoff;
1806 /* FIXME: This is a reminder to implement this icall on windows */
1811 ves_icall_System_Object_obj_address (MonoObject *this) {
1818 ves_icall_System_Buffer_ByteLengthInternal (MonoArray *array) {
1824 klass = array->obj.vtable->klass;
1825 etype = klass->element_class->byval_arg.type;
1826 if (etype < MONO_TYPE_BOOLEAN || etype > MONO_TYPE_R8)
1830 for (i = 0; i < klass->rank; ++ i)
1831 length += array->bounds [i].length;
1833 esize = mono_array_element_size (klass);
1834 return length * esize;
1838 ves_icall_System_Buffer_GetByteInternal (MonoArray *array, gint32 idx) {
1839 return mono_array_get (array, gint8, idx);
1843 ves_icall_System_Buffer_SetByteInternal (MonoArray *array, gint32 idx, gint8 value) {
1844 mono_array_set (array, gint8, idx, value);
1848 ves_icall_System_Buffer_BlockCopyInternal (MonoArray *src, gint32 src_offset, MonoArray *dest, gint32 dest_offset, gint32 count) {
1849 char *src_buf, *dest_buf;
1851 src_buf = (gint8 *)src->vector + src_offset;
1852 dest_buf = (gint8 *)dest->vector + dest_offset;
1854 memcpy (dest_buf, src_buf, count);
1858 ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this)
1860 MonoDomain *domain = mono_domain_get ();
1862 MonoRealProxy *rp = ((MonoRealProxy *)this);
1866 res = mono_object_new (domain, mono_defaults.transparent_proxy_class);
1868 ((MonoTransparentProxy *)res)->rp = rp;
1869 type = ((MonoReflectionType *)rp->class_to_proxy)->type;
1870 klass = mono_class_from_mono_type (type);
1872 res->vtable = mono_class_proxy_vtable (domain, klass);
1877 /* System.Environment */
1880 ves_icall_System_Environment_get_MachineName (void)
1882 #if defined (PLATFORM_WIN32)
1887 len = MAX_COMPUTERNAME_LENGTH + 1;
1888 buf = g_new (gunichar2, len);
1891 if (GetComputerName (buf, &len))
1892 result = mono_string_new_utf16 (mono_domain_get (), buf, len);
1902 buf = g_new (gchar, len);
1905 if (gethostname (buf, len) != 0)
1906 result = mono_string_new (mono_domain_get (), buf);
1914 ves_icall_System_Environment_get_NewLine (void)
1916 #if defined (PLATFORM_WIN32)
1917 return mono_string_new (mono_domain_get (), "\r\n");
1919 return mono_string_new (mono_domain_get (), "\n");
1924 ves_icall_System_Environment_GetEnvironmentVariable (MonoString *name)
1932 utf8_name = mono_string_to_utf8 (name); /* FIXME: this should be ascii */
1933 value = g_getenv (utf8_name);
1939 return mono_string_new (mono_domain_get (), value);
1943 * There is no standard way to get at environ.
1945 extern char **environ;
1948 ves_icall_System_Environment_GetEnvironmentVariableNames (void)
1957 for (e = environ; *e != 0; ++ e)
1960 domain = mono_domain_get ();
1961 names = mono_array_new (domain, mono_defaults.string_class, n);
1964 for (e = environ; *e != 0; ++ e) {
1965 parts = g_strsplit (*e, "=", 2);
1967 str = mono_string_new (domain, *parts);
1968 mono_array_set (names, MonoString *, n, str);
1980 ves_icall_System_Environment_GetCommandLine (void)
1982 return NULL; /* FIXME */
1986 ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this,
1987 MonoReflectionMethod *method,
1988 MonoArray *out_args)
1990 MonoDomain *domain = mono_domain_get ();
1992 mono_message_init (domain, this, method, out_args);
1996 ves_icall_IsTransparentProxy (MonoObject *proxy)
2001 if (proxy->vtable->klass == mono_defaults.transparent_proxy_class)
2008 ves_icall_System_String_InternalIndexOfAny (MonoString *str, MonoArray *chars, gint32 start, gint32 count)
2011 gunichar2 *data = mono_string_chars (str);
2013 for (i = start; i < start + count; ++i) {
2014 for (j = 0; j < mono_array_length (chars); ++j) {
2015 if (data [i] == mono_array_get (chars, guint16, j))
2023 ves_icall_System_String_GetHashCode (MonoString *str)
2026 gunichar2 *data = mono_string_chars (str);
2028 for (i = 0; i < mono_string_length (str); ++i)
2029 h = (h << 5) - h + data [i];
2035 static gconstpointer icall_map [] = {
2039 "System.Array::GetValue", ves_icall_System_Array_GetValue,
2040 "System.Array::SetValue", ves_icall_System_Array_SetValue,
2041 "System.Array::GetValueImpl", ves_icall_System_Array_GetValueImpl,
2042 "System.Array::SetValueImpl", ves_icall_System_Array_SetValueImpl,
2043 "System.Array::GetRank", ves_icall_System_Array_GetRank,
2044 "System.Array::GetLength", ves_icall_System_Array_GetLength,
2045 "System.Array::GetLowerBound", ves_icall_System_Array_GetLowerBound,
2046 "System.Array::CreateInstanceImpl", ves_icall_System_Array_CreateInstanceImpl,
2047 "System.Array::FastCopy", ves_icall_System_Array_FastCopy,
2048 "System.Array::Clone", mono_array_clone,
2053 "System.Object::MemberwiseClone", ves_icall_System_Object_MemberwiseClone,
2054 "System.Object::GetType", ves_icall_System_Object_GetType,
2055 "System.Object::GetHashCode", ves_icall_System_Object_GetHashCode,
2056 "System.Object::obj_address", ves_icall_System_Object_obj_address,
2061 "System.ValueType::GetHashCode", ves_icall_System_ValueType_GetHashCode,
2062 "System.ValueType::Equals", ves_icall_System_ValueType_Equals,
2067 "System.String::_IsInterned", mono_string_is_interned,
2068 "System.String::_Intern", mono_string_intern,
2069 "System.String::InternalIndexOfAny", ves_icall_System_String_InternalIndexOfAny,
2070 "System.String::GetHashCode", ves_icall_System_String_GetHashCode,
2075 "System.AppDomain::createDomain", ves_icall_System_AppDomain_createDomain,
2076 "System.AppDomain::getCurDomain", ves_icall_System_AppDomain_getCurDomain,
2077 "System.AppDomain::GetData", ves_icall_System_AppDomain_GetData,
2078 "System.AppDomain::SetData", ves_icall_System_AppDomain_SetData,
2079 "System.AppDomain::getSetup", ves_icall_System_AppDomain_getSetup,
2080 "System.AppDomain::getFriendlyName", ves_icall_System_AppDomain_getFriendlyName,
2081 "System.AppDomain::GetAssemblies", ves_icall_System_AppDomain_GetAssemblies,
2082 "System.AppDomain::LoadAssembly", ves_icall_System_AppDomain_LoadAssembly,
2083 "System.AppDomain::Unload", ves_icall_System_AppDomain_Unload,
2084 "System.AppDomain::ExecuteAssembly", ves_icall_System_AppDomain_ExecuteAssembly,
2087 * System.AppDomainSetup
2089 "System.AppDomainSetup::InitAppDomainSetup", ves_icall_System_AppDomainSetup_InitAppDomainSetup,
2094 "System.Double::ToStringImpl", mono_double_ToStringImpl,
2099 "System.Decimal::decimal2UInt64", mono_decimal2UInt64,
2100 "System.Decimal::decimal2Int64", mono_decimal2Int64,
2101 "System.Decimal::double2decimal", mono_double2decimal, /* FIXME: wrong signature. */
2102 "System.Decimal::decimalIncr", mono_decimalIncr,
2103 "System.Decimal::decimalSetExponent", mono_decimalSetExponent,
2104 "System.Decimal::decimal2double", mono_decimal2double,
2105 "System.Decimal::decimalFloorAndTrunc", mono_decimalFloorAndTrunc,
2106 "System.Decimal::decimalRound", mono_decimalRound,
2107 "System.Decimal::decimalMult", mono_decimalMult,
2108 "System.Decimal::decimalDiv", mono_decimalDiv,
2109 "System.Decimal::decimalIntDiv", mono_decimalIntDiv,
2110 "System.Decimal::decimalCompare", mono_decimalCompare,
2111 "System.Decimal::string2decimal", mono_string2decimal,
2112 "System.Decimal::decimal2string", mono_decimal2string,
2117 "System.Reflection.Emit.ModuleBuilder::create_modified_type", ves_icall_ModuleBuilder_create_modified_type,
2122 "System.Reflection.Emit.AssemblyBuilder::getDataChunk", ves_icall_AssemblyBuilder_getDataChunk,
2123 "System.Reflection.Emit.AssemblyBuilder::getPEHeader", ves_icall_AssemblyBuilder_getPEHeader,
2124 "System.Reflection.Emit.AssemblyBuilder::getUSIndex", mono_image_insert_string,
2125 "System.Reflection.Emit.AssemblyBuilder::getToken", ves_icall_AssemblyBuilder_getToken,
2126 "System.Reflection.Emit.AssemblyBuilder::basic_init", mono_image_basic_init,
2131 "System.Reflection.MonoMethodInfo::get_method_info", ves_icall_get_method_info,
2132 "System.Reflection.MonoMethodInfo::get_parameter_info", ves_icall_get_parameter_info,
2133 "System.Reflection.MonoFieldInfo::get_field_info", ves_icall_get_field_info,
2134 "System.Reflection.MonoPropertyInfo::get_property_info", ves_icall_get_property_info,
2135 "System.Reflection.MonoMethod::InternalInvoke", ves_icall_InternalInvoke,
2136 "System.Reflection.MonoMethod::get_Name", ves_icall_MonoMethod_get_Name,
2137 "System.Reflection.MonoCMethod::InternalInvoke", ves_icall_InternalInvoke,
2138 "System.MonoCustomAttrs::GetCustomAttributes", mono_reflection_get_custom_attrs,
2139 "System.Reflection.Emit.CustomAttributeBuilder::GetBlob", mono_reflection_get_custom_attrs_blob,
2140 "System.Reflection.MonoField::GetValue", ves_icall_MonoField_GetValue,
2141 "System.Reflection.Emit.SignatureHelper::get_signature_local", mono_reflection_sighelper_get_signature_local,
2142 "System.Reflection.Emit.SignatureHelper::get_signature_field", mono_reflection_sighelper_get_signature_field,
2147 "System.MonoEnumInfo::get_enum_info", ves_icall_get_enum_info,
2148 "System.Enum::get_value", ves_icall_System_Enum_get_value,
2149 "System.Enum::ToObject", ves_icall_System_Enum_ToObject,
2154 "System.Reflection.Emit.TypeBuilder::setup_internal_class", mono_reflection_setup_internal_class,
2164 "System.Type::internal_from_name", ves_icall_type_from_name,
2165 "System.Type::internal_from_handle", ves_icall_type_from_handle,
2166 "System.Type::get_constructor", ves_icall_get_constructor,
2167 "System.Type::get_property", ves_icall_get_property,
2168 "System.Type::get_method", ves_icall_get_method,
2169 "System.MonoType::get_attributes", ves_icall_get_attributes,
2170 "System.Type::type_is_subtype_of", ves_icall_type_is_subtype_of,
2171 "System.Type::Equals", ves_icall_type_Equals,
2174 * System.Runtime.CompilerServices.RuntimeHelpers
2176 "System.Runtime.CompilerServices.RuntimeHelpers::InitializeArray", ves_icall_InitializeArray,
2181 "System.Threading.Thread::Thread_internal", ves_icall_System_Threading_Thread_Thread_internal,
2182 "System.Threading.Thread::Start_internal", ves_icall_System_Threading_Thread_Start_internal,
2183 "System.Threading.Thread::Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal,
2184 "System.Threading.Thread::CurrentThread_internal", ves_icall_System_Threading_Thread_CurrentThread_internal,
2185 "System.Threading.Thread::CurrentThreadDomain_internal", ves_icall_System_Threading_Thread_CurrentThreadDomain_internal,
2186 "System.Threading.Thread::Join_internal", ves_icall_System_Threading_Thread_Join_internal,
2187 "System.Threading.Thread::SlotHash_lookup", ves_icall_System_Threading_Thread_SlotHash_lookup,
2188 "System.Threading.Thread::SlotHash_store", ves_icall_System_Threading_Thread_SlotHash_store,
2189 "System.Threading.Monitor::Monitor_exit", ves_icall_System_Threading_Monitor_Monitor_exit,
2190 "System.Threading.Monitor::Monitor_test_owner", ves_icall_System_Threading_Monitor_Monitor_test_owner,
2191 "System.Threading.Monitor::Monitor_test_synchronised", ves_icall_System_Threading_Monitor_Monitor_test_synchronised,
2192 "System.Threading.Monitor::Monitor_pulse", ves_icall_System_Threading_Monitor_Monitor_pulse,
2193 "System.Threading.Monitor::Monitor_pulse_all", ves_icall_System_Threading_Monitor_Monitor_pulse_all,
2194 "System.Threading.Monitor::Monitor_try_enter", ves_icall_System_Threading_Monitor_Monitor_try_enter,
2195 "System.Threading.Monitor::Monitor_wait", ves_icall_System_Threading_Monitor_Monitor_wait,
2196 "System.Threading.Mutex::CreateMutex_internal", ves_icall_System_Threading_Mutex_CreateMutex_internal,
2197 "System.Threading.Mutex::ReleaseMutex_internal", ves_icall_System_Threading_Mutex_ReleaseMutex_internal,
2198 "System.Threading.NativeEventCalls::CreateEvent_internal", ves_icall_System_Threading_Events_CreateEvent_internal,
2199 "System.Threading.NativeEventCalls::SetEvent_internal", ves_icall_System_Threading_Events_SetEvent_internal,
2200 "System.Threading.NativeEventCalls::ResetEvent_internal", ves_icall_System_Threading_Events_ResetEvent_internal,
2203 * System.Threading.WaitHandle
2205 "System.Threading.WaitHandle::WaitAll_internal", ves_icall_System_Threading_WaitHandle_WaitAll_internal,
2206 "System.Threading.WaitHandle::WaitAny_internal", ves_icall_System_Threading_WaitHandle_WaitAny_internal,
2207 "System.Threading.WaitHandle::WaitOne_internal", ves_icall_System_Threading_WaitHandle_WaitOne_internal,
2209 "System.Runtime.InteropServices.Marshal::ReadIntPtr", ves_icall_System_Runtime_InteropServices_Marshal_ReadIntPtr,
2210 "System.Runtime.InteropServices.Marshal::PtrToStringAuto", ves_icall_System_Runtime_InteropServices_Marshal_PtrToStringAuto,
2211 "System.Runtime.InteropServices.Marshal::GetLastWin32Error", ves_icall_System_Runtime_InteropServices_Marshal_GetLastWin32Error,
2213 "System.Reflection.Assembly::GetType", ves_icall_System_Reflection_Assembly_GetType,
2214 "System.Reflection.Assembly::GetTypes", ves_icall_System_Reflection_Assembly_GetTypes,
2215 "System.Reflection.Assembly::get_code_base", ves_icall_System_Reflection_Assembly_get_code_base,
2220 "System.MonoType::getFullName", ves_icall_System_MonoType_getFullName,
2221 "System.MonoType::type_from_obj", mono_type_type_from_obj,
2222 "System.MonoType::get_type_info", ves_icall_get_type_info,
2223 "System.MonoType::GetFields", ves_icall_Type_GetFields,
2224 "System.MonoType::GetMethods", ves_icall_Type_GetMethods,
2225 "System.MonoType::GetConstructors", ves_icall_Type_GetConstructors,
2226 "System.MonoType::GetProperties", ves_icall_Type_GetProperties,
2227 "System.MonoType::GetEvents", ves_icall_Type_GetEvents,
2228 "System.MonoType::GetInterfaces", ves_icall_Type_GetInterfaces,
2229 "System.MonoType::GetNestedTypes", ves_icall_Type_GetNestedTypes,
2232 * System.Net.Sockets I/O Services
2234 "System.Net.Sockets.Socket::Socket_internal", ves_icall_System_Net_Sockets_Socket_Socket_internal,
2235 "System.Net.Sockets.Socket::Close_internal", ves_icall_System_Net_Sockets_Socket_Close_internal,
2236 "System.Net.Sockets.SocketException::WSAGetLastError_internal", ves_icall_System_Net_Sockets_SocketException_WSAGetLastError_internal,
2237 "System.Net.Sockets.Socket::Available_internal", ves_icall_System_Net_Sockets_Socket_Available_internal,
2238 "System.Net.Sockets.Socket::Blocking_internal", ves_icall_System_Net_Sockets_Socket_Blocking_internal,
2239 "System.Net.Sockets.Socket::Accept_internal", ves_icall_System_Net_Sockets_Socket_Accept_internal,
2240 "System.Net.Sockets.Socket::Listen_internal", ves_icall_System_Net_Sockets_Socket_Listen_internal,
2241 "System.Net.Sockets.Socket::LocalEndPoint_internal", ves_icall_System_Net_Sockets_Socket_LocalEndPoint_internal,
2242 "System.Net.Sockets.Socket::RemoteEndPoint_internal", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal,
2243 "System.Net.Sockets.Socket::Bind_internal", ves_icall_System_Net_Sockets_Socket_Bind_internal,
2244 "System.Net.Sockets.Socket::Connect_internal", ves_icall_System_Net_Sockets_Socket_Connect_internal,
2245 "System.Net.Sockets.Socket::Receive_internal", ves_icall_System_Net_Sockets_Socket_Receive_internal,
2246 "System.Net.Sockets.Socket::RecvFrom_internal", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal,
2247 "System.Net.Sockets.Socket::Send_internal", ves_icall_System_Net_Sockets_Socket_Send_internal,
2248 "System.Net.Sockets.Socket::SendTo_internal", ves_icall_System_Net_Sockets_Socket_SendTo_internal,
2249 "System.Net.Sockets.Socket::Select_internal", ves_icall_System_Net_Sockets_Socket_Select_internal,
2250 "System.Net.Sockets.Socket::Shutdown_internal", ves_icall_System_Net_Sockets_Socket_Shutdown_internal,
2251 "System.Net.Sockets.Socket::GetSocketOption_obj_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_obj_internal,
2252 "System.Net.Sockets.Socket::GetSocketOption_arr_internal", ves_icall_System_Net_Sockets_Socket_GetSocketOption_arr_internal,
2253 "System.Net.Sockets.Socket::SetSocketOption_internal", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal,
2254 "System.Net.Dns::GetHostByName_internal", ves_icall_System_Net_Dns_GetHostByName_internal,
2255 "System.Net.Dns::GetHostByAddr_internal", ves_icall_System_Net_Dns_GetHostByAddr_internal,
2260 "System.Char::GetNumericValue", ves_icall_System_Char_GetNumericValue,
2261 "System.Char::GetUnicodeCategory", ves_icall_System_Char_GetUnicodeCategory,
2262 "System.Char::IsControl", ves_icall_System_Char_IsControl,
2263 "System.Char::IsDigit", ves_icall_System_Char_IsDigit,
2264 "System.Char::IsLetter", ves_icall_System_Char_IsLetter,
2265 "System.Char::IsLower", ves_icall_System_Char_IsLower,
2266 "System.Char::IsUpper", ves_icall_System_Char_IsUpper,
2267 "System.Char::IsNumber", ves_icall_System_Char_IsNumber,
2268 "System.Char::IsPunctuation", ves_icall_System_Char_IsPunctuation,
2269 "System.Char::IsSeparator", ves_icall_System_Char_IsSeparator,
2270 "System.Char::IsSurrogate", ves_icall_System_Char_IsSurrogate,
2271 "System.Char::IsSymbol", ves_icall_System_Char_IsSymbol,
2272 "System.Char::IsWhiteSpace", ves_icall_System_Char_IsWhiteSpace,
2273 "System.Char::ToLower", ves_icall_System_Char_ToLower,
2274 "System.Char::ToUpper", ves_icall_System_Char_ToUpper,
2276 "System.Text.Encoding::IConvNewEncoder", ves_icall_iconv_new_encoder,
2277 "System.Text.Encoding::IConvNewDecoder", ves_icall_iconv_new_decoder,
2278 "System.Text.Encoding::IConvReset", ves_icall_iconv_reset,
2279 "System.Text.Encoding::IConvGetByteCount", ves_icall_iconv_get_byte_count,
2280 "System.Text.Encoding::IConvGetBytes", ves_icall_iconv_get_bytes,
2281 "System.Text.Encoding::IConvGetCharCount", ves_icall_iconv_get_char_count,
2282 "System.Text.Encoding::IConvGetChars", ves_icall_iconv_get_chars,
2284 "System.DateTime::GetNow", ves_icall_System_DateTime_GetNow,
2285 "System.CurrentTimeZone::GetTimeZoneData", ves_icall_System_CurrentTimeZone_GetTimeZoneData,
2288 * System.Security.Cryptography calls
2291 "System.Security.Cryptography.RNGCryptoServiceProvider::GetBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_GetBytes,
2292 "System.Security.Cryptography.RNG_CryptoServiceProvider::GetNonZeroBytes", ves_icall_System_Security_Cryptography_RNGCryptoServiceProvider_GetNonZeroBytes,
2297 "System.Buffer::ByteLengthInternal", ves_icall_System_Buffer_ByteLengthInternal,
2298 "System.Buffer::GetByteInternal", ves_icall_System_Buffer_GetByteInternal,
2299 "System.Buffer::SetByteInternal", ves_icall_System_Buffer_SetByteInternal,
2300 "System.Buffer::BlockCopyInternal", ves_icall_System_Buffer_BlockCopyInternal,
2305 "System.IO.MonoIO::GetLastError", ves_icall_System_IO_MonoIO_GetLastError,
2306 "System.IO.MonoIO::CreateDirectory", ves_icall_System_IO_MonoIO_CreateDirectory,
2307 "System.IO.MonoIO::RemoveDirectory", ves_icall_System_IO_MonoIO_RemoveDirectory,
2308 "System.IO.MonoIO::FindFirstFile", ves_icall_System_IO_MonoIO_FindFirstFile,
2309 "System.IO.MonoIO::FindNextFile", ves_icall_System_IO_MonoIO_FindNextFile,
2310 "System.IO.MonoIO::FindClose", ves_icall_System_IO_MonoIO_FindClose,
2311 "System.IO.MonoIO::GetCurrentDirectory", ves_icall_System_IO_MonoIO_GetCurrentDirectory,
2312 "System.IO.MonoIO::SetCurrentDirectory", ves_icall_System_IO_MonoIO_SetCurrentDirectory,
2313 "System.IO.MonoIO::MoveFile", ves_icall_System_IO_MonoIO_MoveFile,
2314 "System.IO.MonoIO::CopyFile", ves_icall_System_IO_MonoIO_CopyFile,
2315 "System.IO.MonoIO::DeleteFile", ves_icall_System_IO_MonoIO_DeleteFile,
2316 "System.IO.MonoIO::GetFileAttributes", ves_icall_System_IO_MonoIO_GetFileAttributes,
2317 "System.IO.MonoIO::SetFileAttributes", ves_icall_System_IO_MonoIO_SetFileAttributes,
2318 "System.IO.MonoIO::GetFileStat", ves_icall_System_IO_MonoIO_GetFileStat,
2319 "System.IO.MonoIO::Open", ves_icall_System_IO_MonoIO_Open,
2320 "System.IO.MonoIO::Close", ves_icall_System_IO_MonoIO_Close,
2321 "System.IO.MonoIO::Read", ves_icall_System_IO_MonoIO_Read,
2322 "System.IO.MonoIO::Write", ves_icall_System_IO_MonoIO_Write,
2323 "System.IO.MonoIO::Seek", ves_icall_System_IO_MonoIO_Seek,
2324 "System.IO.MonoIO::GetLength", ves_icall_System_IO_MonoIO_GetLength,
2325 "System.IO.MonoIO::SetLength", ves_icall_System_IO_MonoIO_SetLength,
2326 "System.IO.MonoIO::SetFileTime", ves_icall_System_IO_MonoIO_SetFileTime,
2327 "System.IO.MonoIO::Flush", ves_icall_System_IO_MonoIO_Flush,
2328 "System.IO.MonoIO::get_ConsoleOutput", ves_icall_System_IO_MonoIO_get_ConsoleOutput,
2329 "System.IO.MonoIO::get_ConsoleInput", ves_icall_System_IO_MonoIO_get_ConsoleInput,
2330 "System.IO.MonoIO::get_ConsoleError", ves_icall_System_IO_MonoIO_get_ConsoleError,
2331 "System.IO.MonoIO::get_VolumeSeparatorChar", ves_icall_System_IO_MonoIO_get_VolumeSeparatorChar,
2332 "System.IO.MonoIO::get_DirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_DirectorySeparatorChar,
2333 "System.IO.MonoIO::get_AltDirectorySeparatorChar", ves_icall_System_IO_MonoIO_get_AltDirectorySeparatorChar,
2334 "System.IO.MonoIO::get_PathSeparator", ves_icall_System_IO_MonoIO_get_PathSeparator,
2335 "System.IO.MonoIO::get_InvalidPathChars", ves_icall_System_IO_MonoIO_get_InvalidPathChars,
2340 "System.Math::Sin", ves_icall_System_Math_Sin,
2341 "System.Math::Cos", ves_icall_System_Math_Cos,
2342 "System.Math::Tan", ves_icall_System_Math_Tan,
2343 "System.Math::Sinh", ves_icall_System_Math_Sinh,
2344 "System.Math::Cosh", ves_icall_System_Math_Cosh,
2345 "System.Math::Tanh", ves_icall_System_Math_Tanh,
2346 "System.Math::Acos", ves_icall_System_Math_Acos,
2347 "System.Math::Asin", ves_icall_System_Math_Asin,
2348 "System.Math::Atan", ves_icall_System_Math_Atan,
2349 "System.Math::Atan2", ves_icall_System_Math_Atan2,
2350 "System.Math::Exp", ves_icall_System_Math_Exp,
2351 "System.Math::Log", ves_icall_System_Math_Log,
2352 "System.Math::Log10", ves_icall_System_Math_Log10,
2353 "System.Math::Pow", ves_icall_System_Math_Pow,
2354 "System.Math::Sqrt", ves_icall_System_Math_Sqrt,
2357 * System.Environment
2359 "System.Environment::get_MachineName", ves_icall_System_Environment_get_MachineName,
2360 "System.Environment::get_NewLine", ves_icall_System_Environment_get_NewLine,
2361 "System.Environment::GetEnvironmentVariable", ves_icall_System_Environment_GetEnvironmentVariable,
2362 "System.Environment::GetEnvironmentVariableNames", ves_icall_System_Environment_GetEnvironmentVariableNames,
2363 "System.Environment::GetCommandLine", ves_icall_System_Environment_GetCommandLine,
2366 * Mono.CSharp.Debugger
2368 "Mono.CSharp.Debugger.MonoSymbolWriter::get_local_type_from_sig",
2369 ves_icall_Debugger_MonoSymbolWriter_get_local_type_from_sig,
2370 "Mono.CSharp.Debugger.MonoSymbolWriter::get_method",
2371 ves_icall_Debugger_MonoSymbolWriter_method_from_token,
2372 "Mono.CSharp.Debugger.DwarfFileWriter::get_type_token",
2373 ves_icall_Debugger_DwarfFileWriter_get_type_token,
2377 * System.Runtime.Remoting
2379 "System.Runtime.Remoting.RemotingServices::InternalExecute",
2380 ves_icall_InternalExecute,
2381 "System.Runtime.Remoting.RemotingServices::IsTransparentProxy",
2382 ves_icall_IsTransparentProxy,
2385 * System.Runtime.Remoting.Messaging
2387 "System.Runtime.Remoting.Messaging.MonoMethodMessage::InitMessage",
2388 ves_icall_MonoMethodMessage_InitMessage,
2391 * System.Runtime.Remoting.Proxies
2393 "System.Runtime.Remoting.Proxies.RealProxy::GetTransparentProxy",
2394 ves_icall_Remoting_RealProxy_GetTransparentProxy,
2397 * add other internal calls here
2403 mono_init_icall (void)
2408 while ((name = icall_map [i])) {
2409 mono_add_internal_call (name, icall_map [i+1]);