attr_klass = decode_typeid (p, &p, end, NULL, &err);
/* attr_klass can be NULL */
if (err != ERR_NONE)
- return err;
+ goto exit;
cinfo = mono_custom_attrs_from_class_checked (klass, error);
if (!is_ok (error)) {
mono_error_cleanup (error); /* FIXME don't swallow the error message */
- return ERR_LOADER_ERROR;
+ goto loader_error;
}
err = buffer_add_cattrs (buf, domain, m_class_get_image (klass), attr_klass, cinfo);
if (err != ERR_NONE)
- return err;
+ goto exit;
break;
}
case CMD_TYPE_GET_FIELD_CATTRS: {
field = decode_fieldid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
- return err;
+ goto exit;
attr_klass = decode_typeid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
- return err;
+ goto exit;
cinfo = mono_custom_attrs_from_field_checked (klass, field, error);
if (!is_ok (error)) {
mono_error_cleanup (error); /* FIXME don't swallow the error message */
- return ERR_LOADER_ERROR;
+ goto loader_error;
}
err = buffer_add_cattrs (buf, domain, m_class_get_image (klass), attr_klass, cinfo);
if (err != ERR_NONE)
- return err;
+ goto exit;
break;
}
case CMD_TYPE_GET_PROPERTY_CATTRS: {
prop = decode_propertyid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
- return err;
+ goto exit;
attr_klass = decode_typeid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
- return err;
+ goto exit;
cinfo = mono_custom_attrs_from_property_checked (klass, prop, error);
if (!is_ok (error)) {
mono_error_cleanup (error); /* FIXME don't swallow the error message */
- return ERR_LOADER_ERROR;
+ goto loader_error;
}
err = buffer_add_cattrs (buf, domain, m_class_get_image (klass), attr_klass, cinfo);
if (err != ERR_NONE)
- return err;
+ goto exit;
break;
}
case CMD_TYPE_GET_VALUES:
err = get_object (objid, (MonoObject**)&thread_obj);
if (err != ERR_NONE)
- return err;
+ goto exit;
thread = THREAD_TO_INTERNAL (thread_obj);
}
for (i = 0; i < len; ++i) {
f = decode_fieldid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
- return err;
+ goto exit;
if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC))
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
+
special_static_type = mono_class_field_get_special_static_type (f);
if (special_static_type != SPECIAL_STATIC_NONE) {
if (!(thread && special_static_type == SPECIAL_STATIC_THREAD))
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
}
/* Check that the field belongs to the object */
}
}
if (!found)
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
vtable = mono_class_vtable_checked (domain, f->parent, error);
- if (!is_ok (error))
- return ERR_INVALID_FIELDID;
+ goto_if_nok (error, invalid_fieldid);
+
val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type_internal (f->type)));
mono_field_static_get_value_for_thread (thread ? thread : mono_thread_internal_current (), vtable, f, val, error);
- if (!is_ok (error))
- return ERR_INVALID_FIELDID;
+ goto_if_nok (error, invalid_fieldid);
+
buffer_add_value (buf, f->type, val, domain);
g_free (val);
}
for (i = 0; i < len; ++i) {
f = decode_fieldid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
- return err;
+ goto exit;
if (!(f->type->attrs & FIELD_ATTRIBUTE_STATIC))
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
+
if (mono_class_field_is_special_static (f))
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
/* Check that the field belongs to the object */
found = FALSE;
}
}
if (!found)
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
// FIXME: Check for literal/const
vtable = mono_class_vtable_checked (domain, f->parent, error);
- if (!is_ok (error))
- return ERR_INVALID_FIELDID;
+ goto_if_nok (error, invalid_fieldid);
+
val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type_internal (f->type)));
err = decode_value (f->type, domain, val, p, &p, end, TRUE);
if (err != ERR_NONE) {
g_free (val);
- return err;
+ goto exit;
}
if (MONO_TYPE_IS_REFERENCE (f->type))
mono_field_static_set_value_internal (vtable, f, *(gpointer*)val);
MonoObject *o = (MonoObject*)mono_type_get_object_checked (domain, m_class_get_byval_arg (klass), error);
if (!is_ok (error)) {
mono_error_cleanup (error);
- return ERR_INVALID_OBJECT;
+ goto invalid_object;
}
buffer_add_objid (buf, o);
break;
MonoClass *oklass = decode_typeid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
- return err;
+ goto exit;
if (mono_class_is_assignable_from_internal (klass, oklass))
buffer_add_byte (buf, 1);
else
array = mono_class_get_methods_by_name (klass, name, flags & ~BINDING_FLAGS_IGNORE_CASE, mlisttype, TRUE, error);
if (!is_ok (error)) {
mono_error_cleanup (error);
- return ERR_LOADER_ERROR;
+ goto loader_error;
}
buffer_add_int (buf, array->len);
for (i = 0; i < array->len; ++i) {
for (parent = tclass; parent; parent = m_class_get_parent (parent)) {
mono_class_setup_interfaces (parent, error);
- if (!is_ok (error))
- return ERR_LOADER_ERROR;
+ goto_if_nok (error, loader_error);
+
collect_interfaces (parent, iface_hash, error);
- if (!is_ok (error))
- return ERR_LOADER_ERROR;
+ goto_if_nok (error, loader_error);
}
buffer_add_int (buf, g_hash_table_size (iface_hash));
for (tindex = 0; tindex < len; ++tindex) {
iclass = decode_typeid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
- return err;
+ goto exit;
ioffset = mono_class_interface_offset_with_variance (klass, iclass, &variance_used);
if (ioffset == -1)
- return ERR_INVALID_ARGUMENT;
+ goto invalid_argument;
nmethods = mono_class_num_methods (iclass);
buffer_add_int (buf, nmethods);
}
case CMD_TYPE_IS_INITIALIZED: {
MonoVTable *vtable = mono_class_vtable_checked (domain, klass, error);
- if (!is_ok (error))
- return ERR_LOADER_ERROR;
+ goto_if_nok (error, loader_error);
if (vtable)
buffer_add_int (buf, (vtable->initialized || vtable->init_failed) ? 1 : 0);
break;
}
default:
- return ERR_NOT_IMPLEMENTED;
+ err = ERR_NOT_IMPLEMENTED;
+ goto exit;
}
- return ERR_NONE;
+ err = ERR_NONE;
+ goto exit;
+invalid_argument:
+ err = ERR_INVALID_ARGUMENT;
+ goto exit;
+invalid_fieldid:
+ err = ERR_INVALID_FIELDID;
+ goto exit;
+invalid_object:
+ err = ERR_INVALID_OBJECT;
+ goto exit;
+loader_error:
+ err = ERR_LOADER_ERROR;
+ goto exit;
+exit:
+ return err;
}
static ErrorCode
MonoClassField *f;
MonoClass *k;
gboolean found;
+ gboolean remote_obj = FALSE;
if (command == CMD_OBJECT_REF_IS_COLLECTED) {
objid = decode_objid (p, &p, end);
buffer_add_int (buf, 1);
else
buffer_add_int (buf, 0);
- return ERR_NONE;
+ err = ERR_NONE;
+ goto exit;
}
objid = decode_objid (p, &p, end);
err = get_object (objid, &obj);
if (err != ERR_NONE)
- return err;
+ goto exit;
MonoClass *obj_type;
- gboolean remote_obj = FALSE;
obj_type = obj->vtable->klass;
if (mono_class_is_transparent_proxy (obj_type)) {
for (i = 0; i < len; ++i) {
MonoClassField *f = decode_fieldid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
- return err;
+ goto exit;
/* Check that the field belongs to the object */
found = FALSE;
}
}
if (!found)
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) {
guint8 *val;
MonoVTable *vtable;
if (mono_class_field_is_special_static (f))
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC);
vtable = mono_class_vtable_checked (obj->vtable->domain, f->parent, error);
if (!is_ok (error)) {
mono_error_cleanup (error);
- return ERR_INVALID_OBJECT;
+ goto invalid_object;
}
val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type_internal (f->type)));
mono_field_static_get_value_checked (vtable, f, val, error);
if (!is_ok (error)) {
mono_error_cleanup (error); /* FIXME report the error */
- return ERR_INVALID_OBJECT;
+ goto invalid_object;
}
buffer_add_value (buf, f->type, val, obj->vtable->domain);
g_free (val);
field_value = mono_load_remote_field_checked(obj, obj_type, f, &field_storage, error);
if (!is_ok (error)) {
mono_error_cleanup (error); /* FIXME report the error */
- return ERR_INVALID_OBJECT;
+ goto invalid_object;
}
#else
g_assert_not_reached ();
for (i = 0; i < len; ++i) {
f = decode_fieldid (p, &p, end, NULL, &err);
if (err != ERR_NONE)
- return err;
+ goto exit;
/* Check that the field belongs to the object */
found = FALSE;
}
}
if (!found)
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
if (f->type->attrs & FIELD_ATTRIBUTE_STATIC) {
guint8 *val;
MonoVTable *vtable;
if (mono_class_field_is_special_static (f))
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
g_assert (f->type->attrs & FIELD_ATTRIBUTE_STATIC);
vtable = mono_class_vtable_checked (obj->vtable->domain, f->parent, error);
if (!is_ok (error)) {
mono_error_cleanup (error);
- return ERR_INVALID_FIELDID;
+ goto invalid_fieldid;
}
val = (guint8 *)g_malloc (mono_class_instance_size (mono_class_from_mono_type_internal (f->type)));
err = decode_value (f->type, obj->vtable->domain, val, p, &p, end, TRUE);
if (err != ERR_NONE) {
g_free (val);
- return err;
+ goto exit;
}
mono_field_static_set_value_internal (vtable, f, val);
g_free (val);
} else {
err = decode_value (f->type, obj->vtable->domain, (guint8*)obj + f->offset, p, &p, end, TRUE);
if (err != ERR_NONE)
- return err;
+ goto exit;
}
}
break;
buffer_add_domainid (buf, obj->vtable->domain);
break;
default:
- return ERR_NOT_IMPLEMENTED;
+ err = ERR_NOT_IMPLEMENTED;
+ goto exit;
}
- return ERR_NONE;
+ err = ERR_NONE;
+ goto exit;
+invalid_fieldid:
+ err = ERR_INVALID_FIELDID;
+ goto exit;
+invalid_object:
+ err = ERR_INVALID_OBJECT;
+ goto exit;
+exit:
+ return err;
}
static const char*