ICALL_EXPORT MonoReflectionAssembly* ves_icall_System_Reflection_Assembly_GetCallingAssembly (void);
+/* Lazy class loading functions */
+static GENERATE_GET_CLASS_WITH_CACHE (system_version, System, Version)
+static GENERATE_GET_CLASS_WITH_CACHE (assembly_name, System.Reflection, AssemblyName)
+static GENERATE_GET_CLASS_WITH_CACHE (constructor_info, System.Reflection, ConstructorInfo)
+static GENERATE_GET_CLASS_WITH_CACHE (property_info, System.Reflection, PropertyInfo)
+static GENERATE_GET_CLASS_WITH_CACHE (event_info, System.Reflection, EventInfo)
+static GENERATE_GET_CLASS_WITH_CACHE (module, System.Reflection, Module)
+
static MonoArray*
-type_array_from_modifiers (MonoImage *image, MonoType *type, int optional);
+type_array_from_modifiers (MonoImage *image, MonoType *type, int optional, MonoError *error);
static inline MonoBoolean
is_generic_parameter (MonoType *type)
}
static void
-mono_class_init_or_throw (MonoClass *klass)
+mono_class_init_checked (MonoClass *klass, MonoError *error)
{
+ mono_error_init (error);
+
if (!mono_class_init (klass))
- mono_raise_exception (mono_class_get_exception_for_failure (klass));
+ mono_error_set_exception_instance (error, mono_class_get_exception_for_failure (klass));
}
ICALL_EXPORT MonoObject *
}
klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
if (bounds && (mono_array_length (bounds) == 1) && (mono_array_get (bounds, gint32, 0) != 0))
/* vectors are not the same as one dimensional arrays with no-zero bounds */
}
klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
if (bounds && (mono_array_length (bounds) == 1) && (mono_array_get (bounds, gint64, 0) != 0))
/* vectors are not the same as one dimensional arrays with no-zero bounds */
ICALL_EXPORT void
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor (MonoType *handle)
{
+ MonoError error;
MonoClass *klass;
MonoVTable *vtable;
if (klass->generic_container)
return;
- vtable = mono_class_vtable_full (mono_domain_get (), klass, TRUE);
+ vtable = mono_class_vtable_full (mono_domain_get (), klass, &error);
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return;
+ }
/* This will call the type constructor */
- mono_runtime_class_init (vtable);
+ if (!mono_runtime_class_init_full (vtable, &error))
+ mono_error_set_pending_exception (&error);
}
ICALL_EXPORT void
return;
}
/*It's fine to raise the exception here*/
- mono_runtime_class_init (mono_class_vtable_full (mono_domain_get (), module_klass, TRUE));
+ MonoVTable * vtable = mono_class_vtable_full (mono_domain_get (), module_klass, &error);
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return;
+ }
+ if (!mono_runtime_class_init_full (vtable, &error))
+ mono_error_set_pending_exception (&error);
}
}
}
ICALL_EXPORT void
-mono_type_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
+ves_icall_MonoType_type_from_obj (MonoReflectionType *mtype, MonoObject *obj)
{
mtype->type = &obj->vtable->klass->byval_arg;
g_assert (mtype->type->type);
}
ICALL_EXPORT MonoReflectionType*
-ves_icall_type_from_name (MonoString *name,
- MonoBoolean throwOnError,
- MonoBoolean ignoreCase)
+ves_icall_System_Type_internal_from_name (MonoString *name,
+ MonoBoolean throwOnError,
+ MonoBoolean ignoreCase)
{
MonoError error;
char *str = mono_string_to_utf8 (name);
ICALL_EXPORT MonoReflectionType*
-ves_icall_type_from_handle (MonoType *handle)
+ves_icall_System_Type_internal_from_handle (MonoType *handle)
{
MonoError error;
MonoReflectionType *ret;
}
ICALL_EXPORT guint32
-ves_icall_type_is_assignable_from (MonoReflectionType *type, MonoReflectionType *c)
+ves_icall_RuntimeTypeHandle_type_is_assignable_from (MonoReflectionType *type, MonoReflectionType *c)
{
MonoClass *klass;
MonoClass *klassc;
}
ICALL_EXPORT guint32
-ves_icall_type_IsInstanceOfType (MonoReflectionType *type, MonoObject *obj)
+ves_icall_RuntimeTypeHandle_IsInstanceOfType (MonoReflectionType *type, MonoObject *obj)
{
+ MonoError error;
MonoClass *klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
return mono_object_isinst (obj, klass) != NULL;
}
ICALL_EXPORT guint32
-ves_icall_get_attributes (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_GetAttributes (MonoReflectionType *type)
{
MonoClass *klass = mono_class_from_mono_type (type->type);
return klass->flags;
{
MonoError error;
MonoType *type = mono_field_get_type_checked (field->field, &error);
+ MonoArray *res;
+
if (!mono_error_ok (&error)) {
mono_error_set_pending_exception (&error);
return NULL;
}
- return type_array_from_modifiers (field->field->parent->image, type, optional);
+ res = type_array_from_modifiers (field->field->parent->image, type, optional, &error);
+ mono_error_raise_exception (&error);
+ return res;
}
ICALL_EXPORT int
}
if (type->attrs & FIELD_ATTRIBUTE_STATIC) {
- MonoVTable *vtable = mono_class_vtable_full (mono_object_domain (field), cf->parent, TRUE);
- if (!vtable->initialized)
- mono_runtime_class_init (vtable);
+ MonoVTable *vtable = mono_class_vtable_full (mono_object_domain (field), cf->parent, &error);
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return;
+ }
+ if (!vtable->initialized) {
+ if (!mono_runtime_class_init_full (vtable, &error)) {
+ mono_error_set_pending_exception (&error);
+ return;
+ }
+ }
mono_field_static_set_value (vtable, cf, v);
} else {
mono_field_set_value (obj, cf, v);
} PInfo;
ICALL_EXPORT void
-ves_icall_get_property_info (const MonoReflectionProperty *property, MonoPropertyInfo *info, PInfo req_info)
+ves_icall_MonoPropertyInfo_get_property_info (const MonoReflectionProperty *property, MonoPropertyInfo *info, PInfo req_info)
{
MonoError error;
MonoReflectionType *rt;
}
ICALL_EXPORT void
-ves_icall_get_event_info (MonoReflectionMonoEvent *event, MonoEventInfo *info)
+ves_icall_MonoEventInfo_get_event_info (MonoReflectionMonoEvent *event, MonoEventInfo *info)
{
MonoError error;
MonoReflectionType *rt;
MonoDomain *domain;
MonoError error;
- mono_class_init_or_throw (klass);
- mono_class_init_or_throw (iclass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
+ mono_class_init_checked (iclass, &error);
+ mono_error_raise_exception (&error);
mono_class_setup_vtable (klass);
ICALL_EXPORT void
ves_icall_Type_GetPacking (MonoReflectionType *type, guint32 *packing, guint32 *size)
{
+ MonoError error;
MonoClass *klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
+
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
if (image_is_dynamic (klass->image)) {
MonoReflectionTypeBuilder *tb = (MonoReflectionTypeBuilder*)type;
}
ICALL_EXPORT MonoReflectionType*
-ves_icall_MonoType_GetElementType (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_GetElementType (MonoReflectionType *type)
{
MonoError error;
MonoReflectionType *ret;
}
klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
// GetElementType should only return a type for:
// Array Pointer PassedByRef
}
ICALL_EXPORT MonoReflectionType*
-ves_icall_get_type_parent (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_GetBaseType (MonoReflectionType *type)
{
MonoError error;
MonoReflectionType *ret;
}
ICALL_EXPORT MonoBoolean
-ves_icall_type_ispointer (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_IsPointer (MonoReflectionType *type)
{
return type->type->type == MONO_TYPE_PTR;
}
ICALL_EXPORT MonoBoolean
-ves_icall_type_isprimitive (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_IsPrimitive (MonoReflectionType *type)
{
return (!type->type->byref && (((type->type->type >= MONO_TYPE_BOOLEAN) && (type->type->type <= MONO_TYPE_R8)) || (type->type->type == MONO_TYPE_I) || (type->type->type == MONO_TYPE_U)));
}
ICALL_EXPORT MonoBoolean
-ves_icall_type_isbyref (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_IsByRef (MonoReflectionType *type)
{
return type->type->byref;
}
ICALL_EXPORT MonoBoolean
-ves_icall_type_iscomobject (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_IsComObject (MonoReflectionType *type)
{
+ MonoError error;
MonoClass *klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
return mono_class_is_com_object (klass);
}
+ICALL_EXPORT guint32
+ves_icall_RuntimeTypeHandle_GetMetadataToken (MonoReflectionType *obj)
+{
+ return mono_reflection_get_token ((MonoObject*)obj);
+}
+
ICALL_EXPORT MonoReflectionModule*
-ves_icall_MonoType_get_Module (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_GetModule (MonoReflectionType *type)
{
MonoError error;
MonoReflectionModule *result = NULL;
}
ICALL_EXPORT MonoReflectionAssembly*
-ves_icall_MonoType_get_Assembly (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_GetAssembly (MonoReflectionType *type)
{
MonoError error;
MonoDomain *domain = mono_domain_get ();
}
ICALL_EXPORT gint32
-ves_icall_MonoType_GetArrayRank (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_GetArrayRank (MonoReflectionType *type)
{
MonoClass *klass;
}
ICALL_EXPORT gboolean
-ves_icall_Type_get_IsGenericTypeDefinition (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_IsGenericTypeDefinition (MonoReflectionType *type)
{
MonoClass *klass;
}
ICALL_EXPORT MonoReflectionType*
-ves_icall_Type_GetGenericTypeDefinition_impl (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_GetGenericTypeDefinition_impl (MonoReflectionType *type)
{
MonoError error;
MonoReflectionType *ret;
int i, count;
g_assert (IS_MONOTYPE (type));
- mono_class_init_or_throw (mono_class_from_mono_type (type->type));
+ mono_class_init_checked (mono_class_from_mono_type (type->type), &error);
+ mono_error_raise_exception (&error);
count = mono_array_length (type_array);
types = g_new0 (MonoType *, count);
}
ICALL_EXPORT gboolean
-ves_icall_Type_get_IsGenericType (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_HasInstantiation (MonoReflectionType *type)
{
MonoClass *klass;
}
ICALL_EXPORT MonoBoolean
-ves_icall_MonoType_get_IsGenericParameter (MonoReflectionType *type)
+ves_icall_RuntimeTypeHandle_IsGenericVariable (MonoReflectionType *type)
{
return is_generic_parameter (type->type);
}
domain = ((MonoObject *)type)->vtable->domain;
klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
mono_security_core_clr_ensure_reflection_access_method (m);
if (!(m->flags & METHOD_ATTRIBUTE_STATIC)) {
- if (!mono_class_vtable_full (mono_object_domain (method), m->klass, FALSE)) {
+ if (!mono_class_vtable_full (mono_object_domain (method), m->klass, &error)) {
+ mono_error_cleanup (&error); /* FIXME does this make sense? */
mono_gc_wbarrier_generic_store (exc, (MonoObject*) mono_class_get_exception_for_failure (m->klass));
return NULL;
}
domain = mono_object_domain (enumType);
enumc = mono_class_from_mono_type (enumType->type);
- mono_class_init_or_throw (enumc);
+ mono_class_init_checked (enumc, &error);
+ mono_error_raise_exception (&error);
etype = mono_class_enum_basetype (enumc);
MonoClass *klass;
klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
etype = mono_class_enum_basetype (klass);
if (!etype) {
ICALL_EXPORT MonoBoolean
ves_icall_System_Enum_GetEnumValuesAndNames (MonoReflectionType *type, MonoArray **values, MonoArray **names)
{
+ MonoError error;
MonoDomain *domain = mono_object_domain (type);
MonoClass *enumc = mono_class_from_mono_type (type->type);
guint j = 0, nvalues;
guint64 field_value, previous_value = 0;
gboolean sorted = TRUE;
- mono_class_init_or_throw (enumc);
+ mono_class_init_checked (enumc, &error);
+ mono_error_raise_exception (&error);
if (!enumc->enumtype) {
mono_set_pending_exception (mono_get_exception_argument ("enumType", "Type provided must be an Enum."));
mono_ptr_array_init (tmp_array, 2, MONO_ROOT_SOURCE_REFLECTION, "temporary reflection fields list");
handle_parent:
- if (klass->exception_type != MONO_EXCEPTION_NONE) {
+ if (mono_class_has_failure (klass)) {
mono_ptr_array_destroy (tmp_array);
mono_set_pending_exception (mono_class_get_exception_for_failure (klass));
return NULL;
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
- if (klass->exception_type != MONO_EXCEPTION_NONE || mono_loader_get_last_error ())
+ if (mono_class_has_failure (klass) || mono_loader_get_last_error ())
goto loader_error;
if (is_generic_parameter (&klass->byval_arg))
handle_parent:
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
- if (klass->exception_type != MONO_EXCEPTION_NONE || mono_loader_get_last_error ())
+ if (mono_class_has_failure (klass) || mono_loader_get_last_error ())
goto loader_error;
iter = NULL;
g_free (method_slots);
g_ptr_array_free (array, TRUE);
- if (klass->exception_type != MONO_EXCEPTION_NONE) {
+ if (mono_class_has_failure (klass)) {
*ex = mono_class_get_exception_for_failure (klass);
} else {
*ex = mono_loader_error_prepare_exception (mono_loader_get_last_error ());
klass = mono_class_from_mono_type (type->type);
refklass = mono_class_from_mono_type (reftype->type);
domain = ((MonoObject *)type)->vtable->domain;
- array_vtable = mono_class_vtable_full (domain, MethodInfo_array, TRUE);
+ array_vtable = mono_class_vtable_full (domain, MethodInfo_array, &error);
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return NULL;
+ }
if (type->type->byref) {
res = mono_array_new_specific_checked (array_vtable, 0, &error);
mono_error_set_pending_exception (&error);
ves_icall_Type_GetConstructors_internal (MonoReflectionType *type, guint32 bflags, MonoReflectionType *reftype)
{
MonoDomain *domain;
- static MonoClass *System_Reflection_ConstructorInfo;
MonoClass *startklass, *klass, *refklass;
MonoArray *res;
MonoMethod *method;
klass = startklass = mono_class_from_mono_type (type->type);
refklass = mono_class_from_mono_type (reftype->type);
- if (!System_Reflection_ConstructorInfo)
- System_Reflection_ConstructorInfo = mono_class_from_name (
- mono_defaults.corlib, "System.Reflection", "ConstructorInfo");
-
mono_class_setup_methods (klass);
- if (klass->exception_type != MONO_EXCEPTION_NONE) {
+ if (mono_class_has_failure (klass)) {
mono_set_pending_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
mono_ptr_array_append (tmp_array, member);
}
- res = mono_array_new_cached (domain, System_Reflection_ConstructorInfo, mono_ptr_array_size (tmp_array));
+ res = mono_array_new_cached (domain, mono_class_get_constructor_info_class (), mono_ptr_array_size (tmp_array));
for (i = 0; i < mono_ptr_array_size (tmp_array); ++i)
mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i));
{
MonoError error;
MonoDomain *domain;
- static MonoClass *System_Reflection_PropertyInfo;
MonoClass *startklass, *klass;
MonoArray *res;
MonoMethod *method;
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 (
- mono_defaults.corlib, "System.Reflection", "PropertyInfo");
-
domain = ((MonoObject *)type)->vtable->domain;
if (type->type->byref)
- return mono_array_new_cached (domain, System_Reflection_PropertyInfo, 0);
+ return mono_array_new_cached (domain, mono_class_get_property_info_class (), 0);
klass = startklass = mono_class_from_mono_type (type->type);
if (name != NULL) {
handle_parent:
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
- if (klass->exception_type != MONO_EXCEPTION_NONE || mono_loader_get_last_error ())
+ if (mono_class_has_failure (klass) || mono_loader_get_last_error ())
goto loader_error;
iter = NULL;
g_hash_table_destroy (properties);
g_free (propname);
- res = mono_array_new_cached (domain, System_Reflection_PropertyInfo, mono_ptr_array_size (tmp_array));
+ res = mono_array_new_cached (domain, mono_class_get_property_info_class (), mono_ptr_array_size (tmp_array));
for (i = 0; i < mono_ptr_array_size (tmp_array); ++i)
mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i));
loader_error:
- if (klass->exception_type != MONO_EXCEPTION_NONE) {
+ if (mono_class_has_failure (klass)) {
mono_error_set_exception_instance (&error, mono_class_get_exception_for_failure (klass));
} else {
mono_error_set_from_loader_error (&error);
{
MonoError error;
MonoDomain *domain;
- static MonoClass *System_Reflection_EventInfo;
MonoClass *startklass, *klass;
MonoArray *res;
MonoMethod *method;
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 (
- mono_defaults.corlib, "System.Reflection", "EventInfo");
-
domain = mono_object_domain (type);
if (type->type->byref)
- return mono_array_new_cached (domain, System_Reflection_EventInfo, 0);
+ return mono_array_new_cached (domain, mono_class_get_event_info_class (), 0);
klass = startklass = mono_class_from_mono_type (type->type);
events = g_hash_table_new (event_hash, (GEqualFunc)event_equal);
handle_parent:
mono_class_setup_methods (klass);
mono_class_setup_vtable (klass);
- if (klass->exception_type != MONO_EXCEPTION_NONE || mono_loader_get_last_error ())
+ if (mono_class_has_failure (klass) || mono_loader_get_last_error ())
goto loader_error;
iter = NULL;
g_hash_table_destroy (events);
- res = mono_array_new_cached (domain, System_Reflection_EventInfo, mono_ptr_array_size (tmp_array));
+ res = mono_array_new_cached (domain, mono_class_get_event_info_class (), mono_ptr_array_size (tmp_array));
for (i = 0; i < mono_ptr_array_size (tmp_array); ++i)
mono_array_setref (res, i, mono_ptr_array_get (tmp_array, i));
return res;
loader_error:
- if (klass->exception_type != MONO_EXCEPTION_NONE) {
+ if (mono_class_has_failure (klass)) {
mono_error_set_exception_instance (&error, mono_class_get_exception_for_failure (klass));
} else {
mono_error_set_from_loader_error (&error);
MonoClass *klass = mono_type_get_class (type);
/* need to report exceptions ? */
- if (throwOnError && klass->exception_type) {
+ if (throwOnError && mono_class_has_failure (klass)) {
/* report SecurityException (or others) that occured when loading the assembly */
MonoException *exc = mono_class_get_exception_for_failure (klass);
mono_loader_clear_error ();
static MonoObject*
create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build, guint32 revision, MonoError *error)
{
- static MonoClass *System_Version = NULL;
static MonoMethod *create_version = NULL;
MonoObject *result;
gpointer args [4];
mono_error_init (error);
- if (!System_Version) {
- System_Version = mono_class_from_name (mono_defaults.corlib, "System", "Version");
- g_assert (System_Version);
- }
if (!create_version) {
MonoMethodDesc *desc = mono_method_desc_new (":.ctor(int,int,int,int)", FALSE);
- create_version = mono_method_desc_search_in_class (desc, System_Version);
+ create_version = mono_method_desc_search_in_class (desc, mono_class_get_system_version_class ());
g_assert (create_version);
mono_method_desc_free (desc);
}
args [1] = &minor;
args [2] = &build;
args [3] = &revision;
- result = mono_object_new_checked (domain, System_Version, error);
+ result = mono_object_new_checked (domain, mono_class_get_system_version_class (), error);
return_val_if_nok (error, NULL);
mono_runtime_invoke_checked (create_version, result, args, error);
ICALL_EXPORT MonoArray*
ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAssembly *assembly)
{
- static MonoClass *System_Reflection_AssemblyName;
MonoError error;
MonoArray *result;
MonoDomain *domain = mono_object_domain (assembly);
MonoTableInfo *t;
MonoObject *o;
- if (!System_Reflection_AssemblyName)
- System_Reflection_AssemblyName = mono_class_from_name (
- mono_defaults.corlib, "System.Reflection", "AssemblyName");
-
t = &assembly->assembly->image->tables [MONO_TABLE_ASSEMBLYREF];
count = t->rows;
- result = mono_array_new (domain, System_Reflection_AssemblyName, count);
+ result = mono_array_new (domain, mono_class_get_assembly_name_class (), count);
if (count > 0 && !create_culture) {
MonoMethodDesc *desc = mono_method_desc_new (
mono_metadata_decode_row (t, i, cols, MONO_ASSEMBLYREF_SIZE);
aname = (MonoReflectionAssemblyName *) mono_object_new_checked (
- domain, System_Reflection_AssemblyName, &error);
+ domain, mono_class_get_assembly_name_class (), &error);
mono_error_raise_exception (&error);
MONO_OBJECT_SETREF (aname, name, mono_string_new (domain, mono_metadata_string_heap (image, cols [MONO_ASSEMBLYREF_NAME])));
if (modules [i])
real_module_count ++;
- klass = mono_class_from_name (mono_defaults.corlib, "System.Reflection", "Module");
+ klass = mono_class_get_module_class ();
res = mono_array_new (domain, klass, 1 + real_module_count + file_count);
MonoReflectionModule *image_obj = mono_module_get_object_checked (domain, image, &error);
}
mono_class_setup_methods (method->klass);
- if (method->klass->exception_type)
+ if (mono_class_has_failure (method->klass))
return NULL;
for (i = 0; i < method->klass->method.count; ++i) {
if (method->klass->methods [i] == method) {
}
}
mono_class_setup_methods (klass);
- if (klass->exception_type)
+ if (mono_class_has_failure (klass))
return NULL;
g_assert (offset >= 0 && offset < klass->method.count);
return klass->methods [offset];
ICALL_EXPORT int
vell_icall_MonoType_get_core_clr_security_level (MonoReflectionType *rfield)
{
+ MonoError error;
MonoClass *klass = mono_class_from_mono_type (rfield->type);
- mono_class_init_or_throw (klass);
+
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
return mono_security_core_clr_class_level (klass);
}
if (t) {
klass = mono_type_get_class (t->type);
- if ((klass != NULL) && klass->exception_type) {
+ if ((klass != NULL) && mono_class_has_failure (klass)) {
/* keep the class in the list */
list = g_list_append (list, klass);
/* and replace Type with NULL */
}
ICALL_EXPORT MonoBoolean
-ves_icall_Type_IsArrayImpl (MonoReflectionType *t)
+ves_icall_RuntimeTypeHandle_IsArray (MonoReflectionType *t)
{
MonoType *type;
MonoBoolean res;
}
static void
-check_for_invalid_type (MonoClass *klass)
+check_for_invalid_type (MonoClass *klass, MonoError *error)
{
char *name;
MonoString *str;
+
+ mono_error_init (error);
+
if (klass->byval_arg.type != MONO_TYPE_TYPEDBYREF)
return;
name = mono_type_get_full_name (klass);
str = mono_string_new (mono_domain_get (), name);
g_free (name);
- mono_raise_exception ((MonoException*)mono_get_exception_type_load (str, NULL));
+ mono_error_set_exception_instance (error, mono_get_exception_type_load (str, NULL));
}
ICALL_EXPORT MonoReflectionType *
MonoClass *klass, *aklass;
klass = mono_class_from_mono_type (type->type);
- check_for_invalid_type (klass);
+ check_for_invalid_type (klass, &error);
+ mono_error_raise_exception (&error);
if (rank == 0) //single dimentional array
aklass = mono_array_class_get (klass, 1);
MonoClass *klass;
klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
- check_for_invalid_type (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
+ check_for_invalid_type (klass, &error);
+ mono_error_raise_exception (&error);
ret = mono_type_get_object_checked (mono_object_domain (type), &klass->this_arg, &error);
mono_error_raise_exception (&error);
MonoClass *klass, *pklass;
klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
- check_for_invalid_type (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
+ check_for_invalid_type (klass, &error);
+ mono_error_raise_exception (&error);
pklass = mono_ptr_class_get (type->type);
gpointer func;
MonoMethod *method = info->method;
- mono_class_init_or_throw (delegate_class);
+ mono_class_init_checked (delegate_class, &error);
+ mono_error_raise_exception (&error);
mono_assert (delegate_class->parent == mono_defaults.multicastdelegate_class);
// mono_remote_class_vtable cannot handle errors well, so force any loading error to occur early
mono_class_setup_vtable (klass);
- if (klass->exception_type) {
+ if (mono_class_has_failure (klass)) {
mono_set_pending_exception (mono_class_get_exception_for_failure (klass));
return NULL;
}
method = rmethod->method;
klass = mono_class_from_mono_type (rtype->type);
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
if (MONO_CLASS_IS_INTERFACE (klass))
return NULL;
ICALL_EXPORT void
ves_icall_System_Runtime_Activation_ActivationServices_EnableProxyActivation (MonoReflectionType *type, MonoBoolean enable)
{
+ MonoError error;
MonoClass *klass;
MonoVTable* vtable;
klass = mono_class_from_mono_type (type->type);
- vtable = mono_class_vtable_full (mono_domain_get (), klass, TRUE);
+ vtable = mono_class_vtable_full (mono_domain_get (), klass, &error);
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return;
+ }
mono_vtable_set_is_remote (vtable, enable);
}
domain = mono_object_domain (type);
klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
if (MONO_CLASS_IS_INTERFACE (klass) || (klass->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
mono_set_pending_exception (mono_get_exception_argument ("type", "Type cannot be instantiated"));
g_assert (klass->rank == 1);
return (MonoObject *) mono_array_new (domain, klass->element_class, 0);
} else {
+ MonoVTable *vtable = mono_class_vtable_full (domain, klass, &error);
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return NULL;
+ }
/* Bypass remoting object creation check */
- ret = mono_object_new_alloc_specific_checked (mono_class_vtable_full (domain, klass, TRUE), &error);
+ ret = mono_object_new_alloc_specific_checked (vtable, &error);
mono_error_set_pending_exception (&error);
return ret;
#endif
ICALL_EXPORT gpointer
-ves_icall_RuntimeMethod_GetFunctionPointer (MonoMethod *method)
+ves_icall_RuntimeMethodHandle_GetFunctionPointer (MonoMethod *method)
{
return mono_compile_method (method);
}
domain = mono_object_domain (type);
klass = mono_class_from_mono_type (type->type);
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
if (mono_class_is_nullable (klass))
/* No arguments -> null */
}
static void
-prelink_method (MonoMethod *method)
+prelink_method (MonoMethod *method, MonoError *error)
{
const char *exc_class, *exc_arg;
+
+ mono_error_init (error);
if (!(method->flags & METHOD_ATTRIBUTE_PINVOKE_IMPL))
return;
mono_lookup_pinvoke_call (method, &exc_class, &exc_arg);
if (exc_class) {
- mono_raise_exception(
- mono_exception_from_name_msg (mono_defaults.corlib, "System", exc_class, exc_arg ) );
+ mono_error_set_exception_instance (error,
+ mono_exception_from_name_msg (mono_defaults.corlib, "System", exc_class, exc_arg));
+ return;
}
/* create the wrapper, too? */
}
ICALL_EXPORT void
ves_icall_System_Runtime_InteropServices_Marshal_Prelink (MonoReflectionMethod *method)
{
- prelink_method (method->method);
+ MonoError error;
+
+ prelink_method (method->method, &error);
+ mono_error_raise_exception (&error);
}
ICALL_EXPORT void
ves_icall_System_Runtime_InteropServices_Marshal_PrelinkAll (MonoReflectionType *type)
{
+ MonoError error;
MonoClass *klass = mono_class_from_mono_type (type->type);
MonoMethod* m;
gpointer iter = NULL;
- mono_class_init_or_throw (klass);
+ mono_class_init_checked (klass, &error);
+ mono_error_raise_exception (&error);
- while ((m = mono_class_get_methods (klass, &iter)))
- prelink_method (m);
+ while ((m = mono_class_get_methods (klass, &iter))) {
+ prelink_method (m, &error);
+ mono_error_raise_exception (&error);
+ }
}
/* These parameters are "readonly" in corlib/System/NumberFormatter.cs */
/*
* We return NULL for no modifiers so the corlib code can return Type.EmptyTypes
* and avoid useless allocations.
- *
- * MAY THROW
*/
static MonoArray*
-type_array_from_modifiers (MonoImage *image, MonoType *type, int optional)
+type_array_from_modifiers (MonoImage *image, MonoType *type, int optional, MonoError *error)
{
- MonoError error;
MonoReflectionType *rt;
MonoArray *res;
int i, count = 0;
+
+ mono_error_init (error);
for (i = 0; i < type->num_mods; ++i) {
if ((optional && !type->modifiers [i].required) || (!optional && type->modifiers [i].required))
count++;
count = 0;
for (i = 0; i < type->num_mods; ++i) {
if ((optional && !type->modifiers [i].required) || (!optional && type->modifiers [i].required)) {
- MonoClass *klass = mono_class_get_checked (image, type->modifiers [i].token, &error);
- mono_error_raise_exception (&error); /* this is safe, no cleanup needed on callers */
+ MonoClass *klass = mono_class_get_checked (image, type->modifiers [i].token, error);
+ return_val_if_nok (error, NULL);
- rt = mono_type_get_object_checked (mono_domain_get (), &klass->byval_arg, &error);
- mono_error_raise_exception (&error);
+ rt = mono_type_get_object_checked (mono_domain_get (), &klass->byval_arg, error);
+ return_val_if_nok (error, NULL);
mono_array_setref (res, count, rt);
count++;
}
ICALL_EXPORT MonoArray*
-param_info_get_type_modifiers (MonoReflectionParameter *param, MonoBoolean optional)
+ves_icall_ParameterInfo_GetTypeModifiers (MonoReflectionParameter *param, MonoBoolean optional)
{
+ MonoError error;
MonoType *type = param->ClassImpl->type;
MonoClass *member_class = mono_object_class (param->MemberImpl);
MonoMethod *method = NULL;
MonoImage *image;
int pos;
MonoMethodSignature *sig;
+ MonoArray *res;
if (mono_class_is_reflection_method_or_constructor (member_class)) {
MonoReflectionMethod *rmethod = (MonoReflectionMethod*)param->MemberImpl;
else
type = sig->params [pos];
- return type_array_from_modifiers (image, type, optional);
+ res = type_array_from_modifiers (image, type, optional, &error);
+ mono_error_raise_exception (&error);
+ return res;
}
static MonoType*
}
ICALL_EXPORT MonoArray*
-property_info_get_type_modifiers (MonoReflectionProperty *property, MonoBoolean optional)
+ves_icall_MonoPropertyInfo_GetTypeModifiers (MonoReflectionProperty *property, MonoBoolean optional)
{
+ MonoError error;
MonoType *type = get_property_type (property->property);
MonoImage *image = property->klass->image;
+ MonoArray *res;
if (!type)
return NULL;
- return type_array_from_modifiers (image, type, optional);
+ res = type_array_from_modifiers (image, type, optional, &error);
+ mono_error_raise_exception (&error);
+ return res;
}
/*
ICALL_EXPORT MonoBoolean
custom_attrs_defined_internal (MonoObject *obj, MonoReflectionType *attr_type)
{
+ MonoError error;
MonoClass *attr_class = mono_class_from_mono_type (attr_type->type);
MonoCustomAttrInfo *cinfo;
gboolean found;
- mono_class_init_or_throw (attr_class);
+ mono_class_init_checked (attr_class, &error);
+ mono_error_raise_exception (&error);
- cinfo = mono_reflection_get_custom_attrs_info (obj);
+ cinfo = mono_reflection_get_custom_attrs_info_checked (obj, &error);
+ if (!is_ok (&error)) {
+ mono_error_set_pending_exception (&error);
+ return FALSE;
+ }
if (!cinfo)
return FALSE;
found = mono_custom_attrs_has_attr (cinfo, attr_class);
MonoArray *res;
MonoError error;
- if (attr_class)
- mono_class_init_or_throw (attr_class);
+ if (attr_class) {
+ mono_class_init_checked (attr_class, &error);
+ mono_error_raise_exception (&error);
+ }
res = mono_reflection_get_custom_attrs_by_type (obj, attr_class, &error);
if (!mono_error_ok (&error)) {
return il_offset;
}
+ICALL_EXPORT gpointer
+ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcess (void)
+{
+ return GetCurrentProcess ();
+}
+
+ICALL_EXPORT MonoBoolean
+ves_icall_Microsoft_Win32_NativeMethods_GetExitCodeProcess (gpointer handle, gint32 *exitcode)
+{
+ return GetExitCodeProcess (handle, (guint32*) exitcode);
+}
+
+ICALL_EXPORT MonoBoolean
+ves_icall_Microsoft_Win32_NativeMethods_CloseProcess (gpointer handle)
+{
+#if defined(TARGET_WIN32) || defined(HOST_WIN32)
+ return CloseHandle (handle);
+#else
+ return CloseProcess (handle);
+#endif
+}
+
+ICALL_EXPORT MonoBoolean
+ves_icall_Microsoft_Win32_NativeMethods_TerminateProcess (gpointer handle, gint32 exitcode)
+{
+ return TerminateProcess (handle, exitcode);
+}
+
+ICALL_EXPORT gint32
+ves_icall_Microsoft_Win32_NativeMethods_WaitForInputIdle (gpointer handle, gint32 milliseconds)
+{
+ return WaitForInputIdle (handle, milliseconds);
+}
+
+ICALL_EXPORT MonoBoolean
+ves_icall_Microsoft_Win32_NativeMethods_GetProcessWorkingSetSize (gpointer handle, gsize *min, gsize *max)
+{
+ return GetProcessWorkingSetSize (handle, min, max);
+}
+
+ICALL_EXPORT MonoBoolean
+ves_icall_Microsoft_Win32_NativeMethods_SetProcessWorkingSetSize (gpointer handle, gsize min, gsize max)
+{
+ return SetProcessWorkingSetSize (handle, min, max);
+}
+
+ICALL_EXPORT MonoBoolean
+ves_icall_Microsoft_Win32_NativeMethods_GetProcessTimes (gpointer handle, gint64 *creationtime, gint64 *exittime, gint64 *kerneltime, gint64 *usertime)
+{
+ return GetProcessTimes (handle, (LPFILETIME) creationtime, (LPFILETIME) exittime, (LPFILETIME) kerneltime, (LPFILETIME) usertime);
+}
+
+ICALL_EXPORT gint32
+ves_icall_Microsoft_Win32_NativeMethods_GetCurrentProcessId (void)
+{
+ return mono_process_current_pid ();
+}
+
+ICALL_EXPORT gint32
+ves_icall_Microsoft_Win32_NativeMethods_GetPriorityClass (gpointer handle)
+{
+ return GetPriorityClass (handle);
+}
+
+ICALL_EXPORT MonoBoolean
+ves_icall_Microsoft_Win32_NativeMethods_SetPriorityClass (gpointer handle, gint32 priorityClass)
+{
+ return SetPriorityClass (handle, priorityClass);
+}
+
#ifndef DISABLE_ICALL_TABLES
#define ICALL_TYPE(id,name,first)