* (C) 2002 Ximian, Inc.
* Copyright 2003-2011 Novell Inc (http://www.novell.com)
* Copyright 2011 Xamarin Inc (http://www.xamarin.com)
+ * Licensed under the MIT license. See LICENSE file in the project root for full license information.
*/
#include <config.h>
#include <math.h>
void
mono_helper_stelem_ref_check (MonoArray *array, MonoObject *val)
{
+ MonoError error;
if (!array) {
mono_set_pending_exception (mono_get_exception_null_reference ());
return;
}
- if (val && !mono_object_isinst (val, array->obj.vtable->klass->element_class)) {
+ if (val && !mono_object_isinst_checked (val, array->obj.vtable->klass->element_class, &error)) {
+ if (mono_error_set_pending_exception (&error))
+ return;
mono_set_pending_exception (mono_get_exception_array_type_mismatch ());
return;
}
MonoObject*
mono_object_castclass_unbox (MonoObject *obj, MonoClass *klass)
{
+ MonoError error;
MonoJitTlsData *jit_tls = NULL;
MonoClass *oklass;
oklass = obj->vtable->klass;
if ((klass->enumtype && oklass == klass->element_class) || (oklass->enumtype && klass == oklass->element_class))
return obj;
- if (mono_object_isinst (obj, klass))
+ if (mono_object_isinst_checked (obj, klass, &error))
return obj;
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (mini_get_debug_options ()->better_cast_details) {
jit_tls->class_cast_from = oklass;
MonoObject*
mono_object_castclass_with_cache (MonoObject *obj, MonoClass *klass, gpointer *cache)
{
+ MonoError error;
MonoJitTlsData *jit_tls = NULL;
gpointer cached_vtable, obj_vtable;
if (cached_vtable == obj_vtable)
return obj;
- if (mono_object_isinst (obj, klass)) {
+ if (mono_object_isinst_checked (obj, klass, &error)) {
*cache = obj_vtable;
return obj;
}
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
if (mini_get_debug_options ()->better_cast_details) {
jit_tls->class_cast_from = obj->vtable->klass;
MonoObject*
mono_object_isinst_with_cache (MonoObject *obj, MonoClass *klass, gpointer *cache)
{
+ MonoError error;
size_t cached_vtable, obj_vtable;
if (!obj)
return (cached_vtable & 0x1) ? NULL : obj;
}
- if (mono_object_isinst (obj, klass)) {
+ if (mono_object_isinst_checked (obj, klass, &error)) {
*cache = (gpointer)obj_vtable;
return obj;
} else {
+ if (mono_error_set_pending_exception (&error))
+ return NULL;
/*negative cache*/
*cache = (gpointer)(obj_vtable | 0x1);
return NULL;
/*
* Calling a non-vtype method with a vtype receiver, has to box.
*/
- *this_arg = mono_value_box (mono_domain_get (), klass, mp);
+ *this_arg = mono_value_box_checked (mono_domain_get (), klass, mp, error);
else if (klass->valuetype)
/*
* Calling a vtype method with a vtype receiver