#include <mono/metadata/object.h>
#include <mono/metadata/threads.h>
#include <mono/metadata/threads-types.h>
-#include <mono/metadata/threadpool.h>
#include <mono/metadata/threadpool-ms.h>
#include <mono/metadata/threadpool-ms-io.h>
#include <mono/metadata/monitor.h>
#include <mono/metadata/profiler-private.h>
#include <mono/metadata/locales.h>
#include <mono/metadata/filewatcher.h>
-#include <mono/metadata/char-conversions.h>
#include <mono/metadata/security.h>
#include <mono/metadata/mono-config.h>
#include <mono/metadata/cil-coff.h>
#include <mono/metadata/file-mmap.h>
#include <mono/metadata/seq-points-data.h>
#include <mono/io-layer/io-layer.h>
-#include <mono/utils/strtod.h>
#include <mono/utils/monobitset.h>
#include <mono/utils/mono-time.h>
#include <mono/utils/mono-proclib.h>
#include <shlobj.h>
#endif
#include "decimal-ms.h"
+#include "number-ms.h"
extern MonoString* ves_icall_System_Environment_GetOSVersionString (void);
mono_raise_exception (mono_class_get_exception_for_failure (klass));
}
-/*
- * We expect a pointer to a char, not a string
- */
-ICALL_EXPORT gboolean
-mono_double_ParseImpl (char *ptr, double *result)
-{
- gchar *endptr = NULL;
- *result = 0.0;
-
- if (*ptr){
- /* mono_strtod () is not thread-safe */
- mono_mutex_lock (&mono_strtod_mutex);
- *result = mono_strtod (ptr, &endptr);
- mono_mutex_unlock (&mono_strtod_mutex);
- }
-
- if (!*ptr || (endptr && *endptr))
- return FALSE;
-
- return TRUE;
-}
-
ICALL_EXPORT MonoObject *
-ves_icall_System_Array_GetValueImpl (MonoObject *this, guint32 pos)
+ves_icall_System_Array_GetValueImpl (MonoArray *arr, guint32 pos)
{
MonoClass *ac;
- MonoArray *ao;
gint32 esize;
gpointer *ea;
- ao = (MonoArray *)this;
- ac = (MonoClass *)ao->obj.vtable->klass;
+ ac = (MonoClass *)arr->obj.vtable->klass;
esize = mono_array_element_size (ac);
- ea = (gpointer*)((char*)ao->vector + (pos * esize));
+ ea = (gpointer*)((char*)arr->vector + (pos * esize));
if (ac->element_class->valuetype)
- return mono_value_box (this->vtable->domain, ac->element_class, ea);
+ return mono_value_box (arr->obj.vtable->domain, ac->element_class, ea);
else
return *ea;
}
ICALL_EXPORT MonoObject *
-ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs)
+ves_icall_System_Array_GetValue (MonoArray *arr, MonoArray *idxs)
{
MonoClass *ac, *ic;
- MonoArray *ao, *io;
+ MonoArray *io;
gint32 i, pos, *ind;
MONO_CHECK_ARG_NULL (idxs, NULL);
- io = (MonoArray *)idxs;
+ io = idxs;
ic = (MonoClass *)io->obj.vtable->klass;
- ao = (MonoArray *)this;
- ac = (MonoClass *)ao->obj.vtable->klass;
+ ac = (MonoClass *)arr->obj.vtable->klass;
g_assert (ic->rank == 1);
if (io->bounds != NULL || io->max_length != ac->rank) {
ind = (gint32 *)io->vector;
- if (ao->bounds == NULL) {
- if (*ind < 0 || *ind >= ao->max_length) {
+ if (arr->bounds == NULL) {
+ if (*ind < 0 || *ind >= arr->max_length) {
mono_set_pending_exception (mono_get_exception_index_out_of_range ());
return NULL;
}
- return ves_icall_System_Array_GetValueImpl (this, *ind);
+ return ves_icall_System_Array_GetValueImpl (arr, *ind);
}
for (i = 0; i < ac->rank; i++) {
- if ((ind [i] < ao->bounds [i].lower_bound) ||
- (ind [i] >= (mono_array_lower_bound_t)ao->bounds [i].length + ao->bounds [i].lower_bound)) {
+ if ((ind [i] < arr->bounds [i].lower_bound) ||
+ (ind [i] >= (mono_array_lower_bound_t)arr->bounds [i].length + arr->bounds [i].lower_bound)) {
mono_set_pending_exception (mono_get_exception_index_out_of_range ());
return NULL;
}
}
- pos = ind [0] - ao->bounds [0].lower_bound;
+ pos = ind [0] - arr->bounds [0].lower_bound;
for (i = 1; i < ac->rank; i++)
- pos = pos*ao->bounds [i].length + ind [i] -
- ao->bounds [i].lower_bound;
+ pos = pos * arr->bounds [i].length + ind [i] -
+ arr->bounds [i].lower_bound;
- return ves_icall_System_Array_GetValueImpl (this, pos);
+ return ves_icall_System_Array_GetValueImpl (arr, pos);
}
ICALL_EXPORT void
-ves_icall_System_Array_SetValueImpl (MonoArray *this, MonoObject *value, guint32 pos)
+ves_icall_System_Array_SetValueImpl (MonoArray *arr, MonoObject *value, guint32 pos)
{
MonoClass *ac, *vc, *ec;
gint32 esize, vsize;
else
vc = NULL;
- ac = this->obj.vtable->klass;
+ ac = arr->obj.vtable->klass;
ec = ac->element_class;
esize = mono_array_element_size (ac);
- ea = (gpointer*)((char*)this->vector + (pos * esize));
+ ea = (gpointer*)((char*)arr->vector + (pos * esize));
va = (gpointer*)((char*)value + sizeof (MonoObject));
if (mono_class_is_nullable (ec)) {
if (!ec->valuetype) {
if (!mono_object_isinst (value, ec))
INVALID_CAST;
- mono_gc_wbarrier_set_arrayref (this, ea, (MonoObject*)value);
+ mono_gc_wbarrier_set_arrayref (arr, ea, (MonoObject*)value);
return;
}
}
ICALL_EXPORT void
-ves_icall_System_Array_SetValue (MonoArray *this, MonoObject *value,
+ves_icall_System_Array_SetValue (MonoArray *arr, MonoObject *value,
MonoArray *idxs)
{
MonoClass *ac, *ic;
MONO_CHECK_ARG_NULL (idxs,);
ic = idxs->obj.vtable->klass;
- ac = this->obj.vtable->klass;
+ ac = arr->obj.vtable->klass;
g_assert (ic->rank == 1);
if (idxs->bounds != NULL || idxs->max_length != ac->rank) {
ind = (gint32 *)idxs->vector;
- if (this->bounds == NULL) {
- if (*ind < 0 || *ind >= this->max_length) {
+ if (arr->bounds == NULL) {
+ if (*ind < 0 || *ind >= arr->max_length) {
mono_set_pending_exception (mono_get_exception_index_out_of_range ());
return;
}
- ves_icall_System_Array_SetValueImpl (this, value, *ind);
+ ves_icall_System_Array_SetValueImpl (arr, value, *ind);
return;
}
for (i = 0; i < ac->rank; i++)
- if ((ind [i] < this->bounds [i].lower_bound) ||
- (ind [i] >= (mono_array_lower_bound_t)this->bounds [i].length + this->bounds [i].lower_bound)) {
+ if ((ind [i] < arr->bounds [i].lower_bound) ||
+ (ind [i] >= (mono_array_lower_bound_t)arr->bounds [i].length + arr->bounds [i].lower_bound)) {
mono_set_pending_exception (mono_get_exception_index_out_of_range ());
return;
}
- pos = ind [0] - this->bounds [0].lower_bound;
+ pos = ind [0] - arr->bounds [0].lower_bound;
for (i = 1; i < ac->rank; i++)
- pos = pos * this->bounds [i].length + ind [i] -
- this->bounds [i].lower_bound;
+ pos = pos * arr->bounds [i].length + ind [i] -
+ arr->bounds [i].lower_bound;
- ves_icall_System_Array_SetValueImpl (this, value, pos);
+ ves_icall_System_Array_SetValueImpl (arr, value, pos);
}
ICALL_EXPORT MonoArray *
}
ICALL_EXPORT gint32
-ves_icall_System_Array_GetRank (MonoObject *this)
+ves_icall_System_Array_GetRank (MonoObject *arr)
{
- return this->vtable->klass->rank;
+ return arr->vtable->klass->rank;
}
ICALL_EXPORT gint32
-ves_icall_System_Array_GetLength (MonoArray *this, gint32 dimension)
+ves_icall_System_Array_GetLength (MonoArray *arr, gint32 dimension)
{
- gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
+ gint32 rank = arr->obj.vtable->klass->rank;
uintptr_t length;
if ((dimension < 0) || (dimension >= rank)) {
return 0;
}
- if (this->bounds == NULL)
- length = this->max_length;
+ if (arr->bounds == NULL)
+ length = arr->max_length;
else
- length = this->bounds [dimension].length;
+ length = arr->bounds [dimension].length;
#ifdef MONO_BIG_ARRAYS
if (length > G_MAXINT32) {
}
ICALL_EXPORT gint64
-ves_icall_System_Array_GetLongLength (MonoArray *this, gint32 dimension)
+ves_icall_System_Array_GetLongLength (MonoArray *arr, gint32 dimension)
{
- gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
+ gint32 rank = arr->obj.vtable->klass->rank;
if ((dimension < 0) || (dimension >= rank)) {
mono_set_pending_exception (mono_get_exception_index_out_of_range ());
return 0;
}
- if (this->bounds == NULL)
- return this->max_length;
+ if (arr->bounds == NULL)
+ return arr->max_length;
- return this->bounds [dimension].length;
+ return arr->bounds [dimension].length;
}
ICALL_EXPORT gint32
-ves_icall_System_Array_GetLowerBound (MonoArray *this, gint32 dimension)
+ves_icall_System_Array_GetLowerBound (MonoArray *arr, gint32 dimension)
{
- gint32 rank = ((MonoObject *)this)->vtable->klass->rank;
+ gint32 rank = arr->obj.vtable->klass->rank;
if ((dimension < 0) || (dimension >= rank)) {
mono_set_pending_exception (mono_get_exception_index_out_of_range ());
return 0;
}
- if (this->bounds == NULL)
+ if (arr->bounds == NULL)
return 0;
- return this->bounds [dimension].lower_bound;
+ return arr->bounds [dimension].lower_bound;
}
ICALL_EXPORT void
}
ICALL_EXPORT void
-ves_icall_System_Array_GetGenericValueImpl (MonoObject *this, guint32 pos, gpointer value)
+ves_icall_System_Array_GetGenericValueImpl (MonoArray *arr, guint32 pos, gpointer value)
{
MonoClass *ac;
- MonoArray *ao;
gint32 esize;
gpointer *ea;
- ao = (MonoArray *)this;
- ac = (MonoClass *)ao->obj.vtable->klass;
+ ac = (MonoClass *)arr->obj.vtable->klass;
esize = mono_array_element_size (ac);
- ea = (gpointer*)((char*)ao->vector + (pos * esize));
+ ea = (gpointer*)((char*)arr->vector + (pos * esize));
mono_gc_memmove_atomic (value, ea, esize);
}
ICALL_EXPORT void
-ves_icall_System_Array_SetGenericValueImpl (MonoObject *this, guint32 pos, gpointer value)
+ves_icall_System_Array_SetGenericValueImpl (MonoArray *arr, guint32 pos, gpointer value)
{
MonoClass *ac, *ec;
- MonoArray *ao;
gint32 esize;
gpointer *ea;
- ao = (MonoArray *)this;
- ac = (MonoClass *)ao->obj.vtable->klass;
+ ac = (MonoClass *)arr->obj.vtable->klass;
ec = ac->element_class;
esize = mono_array_element_size (ac);
- ea = (gpointer*)((char*)ao->vector + (pos * esize));
+ ea = (gpointer*)((char*)arr->vector + (pos * esize));
if (MONO_TYPE_IS_REFERENCE (&ec->byval_arg)) {
g_assert (esize == sizeof (gpointer));
}
ICALL_EXPORT MonoObject *
-ves_icall_System_Object_MemberwiseClone (MonoObject *this)
+ves_icall_System_Object_MemberwiseClone (MonoObject *this_obj)
{
- return mono_object_clone (this);
+ return mono_object_clone (this_obj);
}
ICALL_EXPORT gint32
-ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this, MonoArray **fields)
+ves_icall_System_ValueType_InternalGetHashCode (MonoObject *this_obj, MonoArray **fields)
{
MonoClass *klass;
MonoObject **values = NULL;
MonoClassField* field;
gpointer iter;
- klass = mono_object_class (this);
+ klass = mono_object_class (this_obj);
if (mono_class_num_fields (klass) == 0)
return result;
/* FIXME: Add more types */
switch (field->type->type) {
case MONO_TYPE_I4:
- result ^= *(gint32*)((guint8*)this + field->offset);
+ result ^= *(gint32*)((guint8*)this_obj + field->offset);
break;
case MONO_TYPE_STRING: {
MonoString *s;
- s = *(MonoString**)((guint8*)this + field->offset);
+ s = *(MonoString**)((guint8*)this_obj + field->offset);
if (s != NULL)
result ^= mono_string_hash (s);
break;
default:
if (!values)
values = g_newa (MonoObject*, mono_class_num_fields (klass));
- o = mono_field_get_value_object (mono_object_domain (this), field, this);
+ o = mono_field_get_value_object (mono_object_domain (this_obj), field, this_obj);
values [count++] = o;
}
}
}
ICALL_EXPORT MonoBoolean
-ves_icall_System_ValueType_Equals (MonoObject *this, MonoObject *that, MonoArray **fields)
+ves_icall_System_ValueType_Equals (MonoObject *this_obj, MonoObject *that, MonoArray **fields)
{
MonoClass *klass;
MonoObject **values = NULL;
MONO_CHECK_ARG_NULL (that, FALSE);
- if (this->vtable != that->vtable)
+ if (this_obj->vtable != that->vtable)
return FALSE;
- klass = mono_object_class (this);
+ klass = mono_object_class (this_obj);
if (klass->enumtype && mono_class_enum_basetype (klass) && mono_class_enum_basetype (klass)->type == MONO_TYPE_I4)
- return (*(gint32*)((guint8*)this + sizeof (MonoObject)) == *(gint32*)((guint8*)that + sizeof (MonoObject)));
+ return (*(gint32*)((guint8*)this_obj + sizeof (MonoObject)) == *(gint32*)((guint8*)that + sizeof (MonoObject)));
/*
* Do the comparison for fields of primitive type and return a result if
case MONO_TYPE_U1:
case MONO_TYPE_I1:
case MONO_TYPE_BOOLEAN:
- if (*((guint8*)this + field->offset) != *((guint8*)that + field->offset))
+ if (*((guint8*)this_obj + field->offset) != *((guint8*)that + field->offset))
return FALSE;
break;
case MONO_TYPE_U2:
case MONO_TYPE_I2:
case MONO_TYPE_CHAR:
- if (*(gint16*)((guint8*)this + field->offset) != *(gint16*)((guint8*)that + field->offset))
+ if (*(gint16*)((guint8*)this_obj + field->offset) != *(gint16*)((guint8*)that + field->offset))
return FALSE;
break;
case MONO_TYPE_U4:
case MONO_TYPE_I4:
- if (*(gint32*)((guint8*)this + field->offset) != *(gint32*)((guint8*)that + field->offset))
+ if (*(gint32*)((guint8*)this_obj + field->offset) != *(gint32*)((guint8*)that + field->offset))
return FALSE;
break;
case MONO_TYPE_U8:
case MONO_TYPE_I8:
- if (*(gint64*)((guint8*)this + field->offset) != *(gint64*)((guint8*)that + field->offset))
+ if (*(gint64*)((guint8*)this_obj + field->offset) != *(gint64*)((guint8*)that + field->offset))
return FALSE;
break;
case MONO_TYPE_R4:
- if (*(float*)((guint8*)this + field->offset) != *(float*)((guint8*)that + field->offset))
+ if (*(float*)((guint8*)this_obj + field->offset) != *(float*)((guint8*)that + field->offset))
return FALSE;
break;
case MONO_TYPE_R8:
- if (*(double*)((guint8*)this + field->offset) != *(double*)((guint8*)that + field->offset))
+ if (*(double*)((guint8*)this_obj + field->offset) != *(double*)((guint8*)that + field->offset))
return FALSE;
break;
case MONO_TYPE_STRING: {
MonoString *s1, *s2;
guint32 s1len, s2len;
- s1 = *(MonoString**)((guint8*)this + field->offset);
+ s1 = *(MonoString**)((guint8*)this_obj + field->offset);
s2 = *(MonoString**)((guint8*)that + field->offset);
if (s1 == s2)
break;
default:
if (!values)
values = g_newa (MonoObject*, mono_class_num_fields (klass) * 2);
- o = mono_field_get_value_object (mono_object_domain (this), field, this);
+ o = mono_field_get_value_object (mono_object_domain (this_obj), field, this_obj);
values [count++] = o;
- o = mono_field_get_value_object (mono_object_domain (this), field, that);
+ o = mono_field_get_value_object (mono_object_domain (this_obj), field, that);
values [count++] = o;
}
mono_image_register_token (mb->dynamic_image, token, obj);
}
+ICALL_EXPORT MonoObject*
+ves_icall_ModuleBuilder_GetRegisteredToken (MonoReflectionModuleBuilder *mb, guint32 token)
+{
+ gpointer obj;
+
+ mono_loader_lock ();
+ obj = mono_g_hash_table_lookup (mb->dynamic_image->tokens, GUINT_TO_POINTER (token));
+ mono_loader_unlock ();
+
+ return obj;
+}
+
static gboolean
get_caller (MonoMethod *m, gint32 no, gint32 ilo, gboolean managed, gpointer data)
{
}
ICALL_EXPORT MonoObject *
-ves_icall_MonoField_GetRawConstantValue (MonoReflectionField *this)
+ves_icall_MonoField_GetRawConstantValue (MonoReflectionField *rfield)
{
MonoObject *o = NULL;
- MonoClassField *field = this->field;
+ MonoClassField *field = rfield->field;
MonoClass *klass;
- MonoDomain *domain = mono_object_domain (this);
+ MonoDomain *domain = mono_object_domain (rfield);
gchar *v;
MonoTypeEnum def_type;
const char *def_value;
} PInfo;
ICALL_EXPORT void
-ves_icall_get_property_info (MonoReflectionProperty *property, MonoPropertyInfo *info, PInfo req_info)
+ves_icall_get_property_info (const MonoReflectionProperty *property, MonoPropertyInfo *info, PInfo req_info)
{
MonoDomain *domain = mono_object_domain (property);
+ const MonoProperty *pproperty = property->property;
if ((req_info & PInfo_ReflectedType) != 0)
MONO_STRUCT_SETREF (info, parent, mono_type_get_object (domain, &property->klass->byval_arg));
if ((req_info & PInfo_DeclaringType) != 0)
- MONO_STRUCT_SETREF (info, declaring_type, mono_type_get_object (domain, &property->property->parent->byval_arg));
+ MONO_STRUCT_SETREF (info, declaring_type, mono_type_get_object (domain, &pproperty->parent->byval_arg));
if ((req_info & PInfo_Name) != 0)
- MONO_STRUCT_SETREF (info, name, mono_string_new (domain, property->property->name));
+ MONO_STRUCT_SETREF (info, name, mono_string_new (domain, pproperty->name));
if ((req_info & PInfo_Attributes) != 0)
- info->attrs = property->property->attrs;
+ info->attrs = pproperty->attrs;
if ((req_info & PInfo_GetMethod) != 0)
- MONO_STRUCT_SETREF (info, get, property->property->get ?
- mono_method_get_object (domain, property->property->get, property->klass): NULL);
-
+ MONO_STRUCT_SETREF (info, get, pproperty->get &&
+ (((pproperty->get->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE) || pproperty->get->klass == property->klass) ?
+ mono_method_get_object (domain, pproperty->get, property->klass): NULL);
if ((req_info & PInfo_SetMethod) != 0)
- MONO_STRUCT_SETREF (info, set, property->property->set ?
- mono_method_get_object (domain, property->property->set, property->klass): NULL);
+ MONO_STRUCT_SETREF (info, set, pproperty->set &&
+ (((pproperty->set->flags & METHOD_ATTRIBUTE_MEMBER_ACCESS_MASK) != METHOD_ATTRIBUTE_PRIVATE) || pproperty->set->klass == property->klass) ?
+ mono_method_get_object (domain, pproperty->set, property->klass): NULL);
/*
* There may be other methods defined for properties, though, it seems they are not exposed
* in the reflection API
mono_metadata_free_type (inflated);
}
+static guint
+get_interfaces_hash (gconstpointer v1)
+{
+ MonoClass *k = (MonoClass*)v1;
+
+ return k->type_token;
+}
+
ICALL_EXPORT MonoArray*
ves_icall_Type_GetInterfaces (MonoReflectionType* type)
{
FillIfaceArrayData data = { 0 };
int len;
- GHashTable *iface_hash = g_hash_table_new (NULL, NULL);
+ GHashTable *iface_hash = g_hash_table_new (get_interfaces_hash, NULL);
if (class->generic_class && class->generic_class->context.class_inst->is_open) {
data.context = mono_class_get_context (class);
return NULL;
}
-
-
ICALL_EXPORT MonoReflectionMethod *
ves_icall_MonoType_get_DeclaringMethod (MonoReflectionType *ref_type)
{
return mono_method_get_object (mono_object_domain (ref_type), method, method->klass);
}
+ICALL_EXPORT MonoBoolean
+ves_icall_System_RuntimeType_IsTypeExportedToWindowsRuntime (void)
+{
+ mono_set_pending_exception (mono_get_exception_not_implemented (NULL));
+ return FALSE;
+}
+
+ICALL_EXPORT MonoBoolean
+ves_icall_System_RuntimeType_IsWindowsRuntimeObjectType (void)
+{
+ mono_set_pending_exception (mono_get_exception_not_implemented (NULL));
+ return FALSE;
+}
+
ICALL_EXPORT void
ves_icall_MonoMethod_GetPInvoke (MonoReflectionMethod *method, int* flags, MonoString** entry_point, MonoString** dll_name)
{
}
ICALL_EXPORT MonoObject *
-ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this, MonoArray *params, MonoException **exc)
+ves_icall_InternalInvoke (MonoReflectionMethod *method, MonoObject *this_arg, MonoArray *params, MonoException **exc)
{
/*
* Invoke from reflection is supposed to always be a virtual call (the API
MonoMethodSignature *sig = mono_method_signature (m);
MonoImage *image;
int pcount;
- void *obj = this;
+ void *obj = this_arg;
*exc = NULL;
return NULL;
}
- if (this) {
- if (!mono_object_isinst (this, m->klass)) {
- char *this_name = mono_type_get_full_name (mono_object_get_class (this));
+ if (this_arg) {
+ if (!mono_object_isinst (this_arg, m->klass)) {
+ char *this_name = mono_type_get_full_name (mono_object_get_class (this_arg));
char *target_name = mono_type_get_full_name (m->klass);
char *msg = g_strdup_printf ("Object of type '%s' doesn't match target type '%s'", this_name, target_name);
mono_gc_wbarrier_generic_store (exc, (MonoObject*) mono_exception_from_name_msg (mono_defaults.corlib, "System.Reflection", "TargetException", msg));
g_free (this_name);
return NULL;
}
- m = mono_object_get_virtual_method (this, m);
+ m = mono_object_get_virtual_method (this_arg, m);
/* must pass the pointer to the value for valuetype methods */
if (m->klass->valuetype)
- obj = mono_object_unbox (this);
+ obj = mono_object_unbox (this_arg);
} else if (strcmp (m->name, ".ctor") && !m->wrapper_type) {
mono_gc_wbarrier_generic_store (exc, (MonoObject*) mono_exception_from_name_msg (mono_defaults.corlib, "System.Reflection", "TargetException", "Non-static method requires a target."));
return NULL;
return NULL;
}
- if ((m->klass->flags & TYPE_ATTRIBUTE_ABSTRACT) && !strcmp (m->name, ".ctor") && !this) {
+ if ((m->klass->flags & TYPE_ATTRIBUTE_ABSTRACT) && !strcmp (m->name, ".ctor") && !this_arg) {
mono_gc_wbarrier_generic_store (exc, (MonoObject*) mono_exception_from_name_msg (mono_defaults.corlib, "System.Reflection", "TargetException", "Cannot invoke constructor of an abstract class."));
return NULL;
}
#ifndef DISABLE_REMOTING
ICALL_EXPORT MonoObject *
-ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this, MonoArray *params, MonoArray **outArgs)
+ves_icall_InternalExecute (MonoReflectionMethod *method, MonoObject *this_arg, MonoArray *params, MonoArray **outArgs)
{
MonoDomain *domain = mono_object_domain (method);
MonoMethod *m = method->method;
if (m->klass == mono_defaults.object_class) {
if (!strcmp (m->name, "FieldGetter")) {
- MonoClass *k = this->vtable->klass;
+ MonoClass *k = this_arg->vtable->klass;
MonoString *name;
char *str;
/* If this is a proxy, then it must be a CBO */
if (k == mono_defaults.transparent_proxy_class) {
- MonoTransparentProxy *tp = (MonoTransparentProxy*) this;
- this = tp->rp->unwrapped_server;
- g_assert (this);
- k = this->vtable->klass;
+ MonoTransparentProxy *tp = (MonoTransparentProxy*) this_arg;
+ this_arg = tp->rp->unwrapped_server;
+ g_assert (this_arg);
+ k = this_arg->vtable->klass;
}
name = mono_array_get (params, MonoString *, 1);
if (field) {
MonoClass *field_klass = mono_class_from_mono_type (field->type);
if (field_klass->valuetype)
- result = mono_value_box (domain, field_klass, (char *)this + field->offset);
+ result = mono_value_box (domain, field_klass, (char *)this_arg + field->offset);
else
- result = *((gpointer *)((char *)this + field->offset));
+ result = *((gpointer *)((char *)this_arg + field->offset));
out_args = mono_array_new (domain, mono_defaults.object_class, 1);
mono_gc_wbarrier_generic_store (outArgs, (MonoObject*) out_args);
g_assert_not_reached ();
} else if (!strcmp (m->name, "FieldSetter")) {
- MonoClass *k = this->vtable->klass;
+ MonoClass *k = this_arg->vtable->klass;
MonoString *name;
guint32 size;
gint32 align;
/* If this is a proxy, then it must be a CBO */
if (k == mono_defaults.transparent_proxy_class) {
- MonoTransparentProxy *tp = (MonoTransparentProxy*) this;
- this = tp->rp->unwrapped_server;
- g_assert (this);
- k = this->vtable->klass;
+ MonoTransparentProxy *tp = (MonoTransparentProxy*) this_arg;
+ this_arg = tp->rp->unwrapped_server;
+ g_assert (this_arg);
+ k = this_arg->vtable->klass;
}
name = mono_array_get (params, MonoString *, 1);
if (field_klass->valuetype) {
size = mono_type_size (field->type, &align);
g_assert (size == mono_class_value_size (field_klass, NULL));
- mono_gc_wbarrier_value_copy ((char *)this + field->offset, (char*)val + sizeof (MonoObject), 1, field_klass);
+ mono_gc_wbarrier_value_copy ((char *)this_arg + field->offset, (char*)val + sizeof (MonoObject), 1, field_klass);
} else {
- mono_gc_wbarrier_set_field (this, (char*)this + field->offset, val);
+ mono_gc_wbarrier_set_field (this_arg, (char*)this_arg + field->offset, val);
}
out_args = mono_array_new (domain, mono_defaults.object_class, 0);
/* handle constructors only for objects already allocated */
if (!strcmp (method->method->name, ".ctor"))
- g_assert (this);
+ g_assert (this_arg);
/* This can be called only on MBR objects, so no need to unbox for valuetypes. */
g_assert (!method->method->klass->valuetype);
- result = mono_runtime_invoke_array (method->method, this, params, NULL);
+ result = mono_runtime_invoke_array (method->method, this_arg, params, NULL);
for (i = 0, j = 0; i < mono_array_length (params); i++) {
if (sig->params [i]->byref) {
}
ICALL_EXPORT MonoObject *
-ves_icall_System_Enum_get_value (MonoObject *this)
+ves_icall_System_Enum_get_value (MonoObject *eobj)
{
MonoObject *res;
MonoClass *enumc;
gpointer src;
int size;
- if (!this)
+ if (!eobj)
return NULL;
- g_assert (this->vtable->klass->enumtype);
+ g_assert (eobj->vtable->klass->enumtype);
- enumc = mono_class_from_mono_type (mono_class_enum_basetype (this->vtable->klass));
- res = mono_object_new (mono_object_domain (this), enumc);
+ enumc = mono_class_from_mono_type (mono_class_enum_basetype (eobj->vtable->klass));
+ res = mono_object_new (mono_object_domain (eobj), enumc);
dst = (char *)res + sizeof (MonoObject);
- src = (char *)this + sizeof (MonoObject);
+ src = (char *)eobj + sizeof (MonoObject);
size = mono_class_value_size (enumc, NULL);
memcpy (dst, src, size);
}
ICALL_EXPORT int
-ves_icall_System_Enum_compare_value_to (MonoObject *this, MonoObject *other)
+ves_icall_System_Enum_compare_value_to (MonoObject *eobj, MonoObject *other)
{
- gpointer tdata = (char *)this + sizeof (MonoObject);
+ gpointer tdata = (char *)eobj + sizeof (MonoObject);
gpointer odata = (char *)other + sizeof (MonoObject);
- MonoType *basetype = mono_class_enum_basetype (this->vtable->klass);
+ MonoType *basetype = mono_class_enum_basetype (eobj->vtable->klass);
g_assert (basetype);
if (other == NULL)
return 1;
- if (this->vtable->klass != other->vtable->klass)
+ if (eobj->vtable->klass != other->vtable->klass)
return 2;
#define COMPARE_ENUM_VALUES(ENUM_TYPE) do { \
}
ICALL_EXPORT int
-ves_icall_System_Enum_get_hashcode (MonoObject *this)
+ves_icall_System_Enum_get_hashcode (MonoObject *eobj)
{
- gpointer data = (char *)this + sizeof (MonoObject);
- MonoType *basetype = mono_class_enum_basetype (this->vtable->klass);
+ gpointer data = (char *)eobj + sizeof (MonoObject);
+ MonoType *basetype = mono_class_enum_basetype (eobj->vtable->klass);
g_assert (basetype);
switch (basetype->type) {
klass = startklass = mono_class_from_mono_type (type->type);
refklass = mono_class_from_mono_type (reftype->type);
- mono_ptr_array_init (tmp_array, 2);
+ mono_ptr_array_init (tmp_array, 2, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection fields list");
handle_parent:
if (klass->exception_type != MONO_EXCEPTION_NONE) {
gpointer iter = NULL;
MonoPtrArray tmp_array;
- mono_ptr_array_init (tmp_array, 4); /*FIXME, guestimating*/
+ mono_ptr_array_init (tmp_array, 4, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection constructors list"); /*FIXME, guestimating*/
domain = ((MonoObject *)type)->vtable->domain;
if (type->type->byref)
GHashTable *properties = NULL;
MonoPtrArray tmp_array;
- mono_ptr_array_init (tmp_array, 8); /*This the average for ASP.NET types*/
+ mono_ptr_array_init (tmp_array, 8, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection properties list"); /*This the average for ASP.NET types*/
if (!System_Reflection_PropertyInfo)
System_Reflection_PropertyInfo = mono_class_from_name (
GHashTable *events = NULL;
MonoPtrArray tmp_array;
- mono_ptr_array_init (tmp_array, 4);
+ mono_ptr_array_init (tmp_array, 4, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection events list");
if (!System_Reflection_EventInfo)
System_Reflection_EventInfo = mono_class_from_name (
if (klass->generic_class)
klass = klass->generic_class->container_class;
- mono_ptr_array_init (tmp_array, 1);
+ mono_ptr_array_init (tmp_array, 1, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection nested types list");
iter = NULL;
while ((nested = mono_class_get_nested_types (klass, &iter))) {
match = 0;
if (type->type == MONO_TYPE_CLASS) {
MonoClass *klass = mono_type_get_class (type);
- if (mono_security_enabled () && !klass->exception_type)
- /* Some security problems are detected during generic vtable construction */
- mono_class_setup_vtable (klass);
-
/* need to report exceptions ? */
if (throwOnError && klass->exception_type) {
/* report SecurityException (or others) that occured when loading the assembly */
mono_loader_clear_error ();
mono_set_pending_exception (exc);
return NULL;
- } else if (mono_security_enabled () && klass->exception_type == MONO_EXCEPTION_SECURITY_INHERITANCEDEMAND) {
- return NULL;
}
}
}
ICALL_EXPORT int
-vell_icall_MonoType_get_core_clr_security_level (MonoReflectionType *this)
+vell_icall_MonoType_get_core_clr_security_level (MonoReflectionType *rfield)
{
- MonoClass *klass = mono_class_from_mono_type (this->type);
+ MonoClass *klass = mono_class_from_mono_type (rfield->type);
mono_class_init_or_throw (klass);
return mono_security_core_clr_class_level (klass);
}
ICALL_EXPORT int
-ves_icall_MonoField_get_core_clr_security_level (MonoReflectionField *this)
+ves_icall_MonoField_get_core_clr_security_level (MonoReflectionField *rfield)
{
- MonoClassField *field = this->field;
+ MonoClassField *field = rfield->field;
return mono_security_core_clr_field_level (field, TRUE);
}
ICALL_EXPORT int
-ves_icall_MonoMethod_get_core_clr_security_level (MonoReflectionMethod *this)
+ves_icall_MonoMethod_get_core_clr_security_level (MonoReflectionMethod *rfield)
{
- MonoMethod *method = this->method;
+ MonoMethod *method = rfield->method;
return mono_security_core_clr_method_level (method, TRUE);
}
if (!exportedOnly || mono_module_type_is_visible (tdef, image, i + 1)) {
MonoError error;
klass = mono_class_get_checked (image, (i + 1) | MONO_TOKEN_TYPE_DEF, &error);
- g_assert (!mono_loader_get_last_error ()); /* Plug any leaks */
+ mono_loader_assert_no_error (); /* Plug any leaks */
if (klass) {
mono_array_setref (res, count, mono_type_get_object (domain, &klass->byval_arg));
return delegate;
}
-ICALL_EXPORT void
-ves_icall_System_Delegate_SetMulticastInvoke (MonoDelegate *this)
+ICALL_EXPORT MonoMulticastDelegate *
+ves_icall_System_Delegate_AllocDelegateLike_internal (MonoDelegate *delegate)
{
- /* Reset the invoke impl to the default one */
- this->invoke_impl = mono_runtime_create_delegate_trampoline (this->object.vtable->klass);
+ MonoMulticastDelegate *ret;
+
+ g_assert (mono_class_has_parent (mono_object_class (delegate), mono_defaults.multicastdelegate_class));
+
+ ret = (MonoMulticastDelegate*) mono_object_new (mono_object_domain (delegate), mono_object_class (delegate));
+ ret->delegate.invoke_impl = mono_runtime_create_delegate_trampoline (mono_object_class (delegate));
+
+ return ret;
+}
+
+ICALL_EXPORT MonoReflectionMethod*
+ves_icall_System_Delegate_GetVirtualMethod_internal (MonoDelegate *delegate)
+{
+ return mono_method_get_object (mono_domain_get (), mono_object_get_virtual_method (delegate->target, delegate->method), mono_object_class (delegate->target));
}
/* System.Buffer */
{
guint8 *src_buf, *dest_buf;
+ if (count < 0) {
+ mono_set_pending_exception (mono_get_exception_argument ("count", "is negative"));
+ return FALSE;
+ }
+
+ g_assert (count >= 0);
+
/* This is called directly from the class libraries without going through the managed wrapper */
MONO_CHECK_ARG_NULL (src, FALSE);
MONO_CHECK_ARG_NULL (dest, FALSE);
#ifndef DISABLE_REMOTING
ICALL_EXPORT MonoObject *
-ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this, MonoString *class_name)
+ves_icall_Remoting_RealProxy_GetTransparentProxy (MonoObject *this_obj, MonoString *class_name)
{
- MonoDomain *domain = mono_object_domain (this);
+ MonoDomain *domain = mono_object_domain (this_obj);
MonoObject *res;
- MonoRealProxy *rp = ((MonoRealProxy *)this);
+ MonoRealProxy *rp = ((MonoRealProxy *)this_obj);
MonoTransparentProxy *tp;
MonoType *type;
MonoClass *klass;
type = ((MonoReflectionType *)rp->class_to_proxy)->type;
klass = mono_class_from_mono_type (type);
- tp->custom_type_info = (mono_object_isinst (this, mono_defaults.iremotingtypeinfo_class) != NULL);
+ tp->custom_type_info = (mono_object_isinst (this_obj, mono_defaults.iremotingtypeinfo_class) != NULL);
tp->remote_class = mono_remote_class (domain, class_name, klass);
res->vtable = mono_remote_class_vtable (domain, tp->remote_class, rp);
}
ICALL_EXPORT void
-ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this,
+ves_icall_MonoMethodMessage_InitMessage (MonoMethodMessage *this_obj,
MonoReflectionMethod *method,
MonoArray *out_args)
{
- mono_message_init (mono_object_domain (this), this, method, out_args);
+ mono_message_init (mono_object_domain (this_obj), this_obj, method, out_args);
}
#ifndef DISABLE_REMOTING
MonoDomain *domain;
MonoString *file;
gchar *config_file_name, *config_file_path;
- gsize len;
+ gsize len, config_file_path_length, config_ext_length;
gchar *module;
domain = mono_domain_get ();
file = domain->setup->configuration_file;
- if (!file)
+ if (!file || file->length == 0)
return NULL;
// Retrieve config file and remove the extension
config_file_path = mono_portability_find_file (config_file_name, TRUE);
if (!config_file_path)
config_file_path = config_file_name;
- len = strlen (config_file_path) - strlen (".config");
+
+ config_file_path_length = strlen (config_file_path);
+ config_ext_length = strlen (".config");
+ if (config_file_path_length <= config_ext_length)
+ return NULL;
+
+ len = config_file_path_length - config_ext_length;
module = g_malloc0 (len + 1);
memcpy (module, config_file_path, len);
// Get the config file from the module name
*decHexDigits = Formatter_DecHexDigits;
}
-/* These parameters are "readonly" in corlib/System/Globalization/TextInfo.cs */
-ICALL_EXPORT void
-ves_icall_System_Globalization_TextInfo_GetDataTablePointersLite (
- guint16 const **to_lower_data_low,
- guint16 const **to_lower_data_high,
- guint16 const **to_upper_data_low,
- guint16 const **to_upper_data_high)
-{
- *to_lower_data_low = ToLowerDataLow;
- *to_lower_data_high = ToLowerDataHigh;
- *to_upper_data_low = ToUpperDataLow;
- *to_upper_data_high = ToUpperDataHigh;
-}
-
/*
* We return NULL for no modifiers so the corlib code can return Type.EmptyTypes
* and avoid useless allocations.
guint32 il_offset;
char *path_str = mono_string_to_utf8 (path);
- if (!seq_point_data_get_il_offset (path_str, method_token, method_index, native_offset, &il_offset))
+ if (!mono_seq_point_data_get_il_offset (path_str, method_token, method_index, native_offset, &il_offset))
il_offset = -1;
g_free (path_str);