MONO_ARCH_SAVE_REGS;
+#ifdef __arm__
+ if (*ptr)
+ result = strtod (ptr, &endptr);
+#else
if (*ptr)
result = bsd_strtod (ptr, &endptr);
+#endif
if (!*ptr || (endptr && *endptr))
- mono_raise_exception (mono_exception_from_name (mono_defaults.corlib,
+ mono_raise_exception (mono_exception_from_name (mono_get_corlib (),
"System",
"FormatException"));
return TRUE;
}
+static void
+ves_icall_System_Array_InternalArray_GetGenericValueImpl (MonoObject *this, guint32 pos,
+ gpointer value)
+{
+ MonoClass *ac;
+ MonoArray *ao;
+ gint32 esize;
+ gpointer *ea;
+
+ MONO_ARCH_SAVE_REGS;
+
+ ao = (MonoArray *)this;
+ ac = (MonoClass *)ao->obj.vtable->klass;
+
+ esize = mono_array_element_size (ac);
+ ea = (gpointer*)((char*)ao->vector + (pos * esize));
+
+ memcpy (value, ea, esize);
+}
+
static void
ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray (MonoArray *array, MonoClassField *field_handle)
{
g_free (str);
if (type == NULL){
if (throwOnError)
- mono_raise_exception (mono_get_exception_type_load (name));
+ mono_raise_exception (mono_get_exception_type_load (name, NULL));
}
return type;
return mono_type_get_object (domain, handle);
}
-static guint32
+static MonoBoolean
ves_icall_type_Equals (MonoReflectionType *type, MonoReflectionType *c)
{
MONO_ARCH_SAVE_REGS;
if (type->type && c->type)
return mono_metadata_type_equal (type->type, c->type);
- g_print ("type equals\n");
- return 0;
+ else
+ return FALSE;
}
/* System.TypeCode */
} TypeCode;
static guint32
-ves_icall_type_GetTypeCode (MonoReflectionType *type)
+ves_icall_type_GetTypeCodeInternal (MonoReflectionType *type)
{
int t = type->type->type;
MonoClassField *cf = field->field;
MonoClass *klass;
MonoVTable *vtable;
+ MonoType *t;
MonoDomain *domain = mono_object_domain (field);
gchar *v;
gboolean is_static = FALSE;
mono_class_init (field->klass);
- switch (cf->type->type) {
+ t = mono_type_get_underlying_type (cf->type);
+ switch (t->type) {
case MONO_TYPE_STRING:
case MONO_TYPE_OBJECT:
case MONO_TYPE_CLASS:
case MONO_TYPE_I8:
case MONO_TYPE_R8:
case MONO_TYPE_VALUETYPE:
- is_ref = cf->type->byref;
+ is_ref = t->byref;
break;
default:
g_error ("type 0x%x not handled in "
- "ves_icall_Monofield_GetValue", cf->type->type);
+ "ves_icall_Monofield_GetValue", t->type);
return NULL;
}
case MONO_TYPE_SZARRAY:
/* Do nothing */
break;
+ case MONO_TYPE_GENERICINST: {
+ MonoGenericClass *gclass = cf->type->data.generic_class;
+ g_assert (!gclass->inst->is_open);
+ if (gclass->container_class->valuetype && (v != NULL))
+ v += sizeof (MonoObject);
+ break;
+ }
default:
g_error ("type 0x%x not handled in "
"ves_icall_FieldInfo_SetValueInternal", cf->type->type);
}
static MonoReflectionType*
-ves_icall_Type_BindGenericParameters (MonoReflectionType *type, MonoArray *type_array)
+ves_icall_Type_MakeGenericType (MonoReflectionType *type, MonoArray *type_array)
{
MonoType *geninst, **types;
int i, count;
}
geninst = mono_reflection_bind_generic_parameters (type, count, types);
+ if (!geninst)
+ return NULL;
return mono_type_get_object (mono_object_domain (type), geninst);
}
return klass->generic_class != NULL;
}
+static gboolean
+ves_icall_Type_get_IsGenericType (MonoReflectionType *type)
+{
+ MonoClass *klass;
+ MONO_ARCH_SAVE_REGS;
+
+ klass = mono_class_from_mono_type (type->type);
+ return klass->generic_class != NULL || klass->generic_container != NULL;
+}
+
static gint32
ves_icall_Type_GetGenericParameterPosition (MonoReflectionType *type)
{
return res;
}
-static MonoBoolean
-ves_icall_MonoType_get_HasGenericArguments (MonoReflectionType *type)
-{
- MonoClass *klass;
- MONO_ARCH_SAVE_REGS;
-
- klass = mono_class_from_mono_type (type->type);
- if (klass->generic_container || klass->generic_class)
- return TRUE;
- return FALSE;
-}
-
static MonoBoolean
ves_icall_MonoType_get_IsGenericParameter (MonoReflectionType *type)
{
static MonoReflectionType*
ves_icall_MonoGenericClass_GetParentType (MonoReflectionGenericClass *type)
{
- MonoGenericClass *gclass;
+ MonoDynamicGenericClass *gclass;
MonoClass *klass;
MONO_ARCH_SAVE_REGS;
- gclass = type->type.type->data.generic_class;
- if (!gclass || !gclass->parent || (gclass->parent->type != MONO_TYPE_GENERICINST))
+ g_assert (type->type.type->data.generic_class->is_dynamic);
+ gclass = (MonoDynamicGenericClass *) type->type.type->data.generic_class;
+
+ if (!gclass->parent || (gclass->parent->type != MONO_TYPE_GENERICINST))
return NULL;
klass = mono_class_from_mono_type (gclass->parent);
ves_icall_MonoGenericClass_GetInterfaces (MonoReflectionGenericClass *type)
{
static MonoClass *System_Reflection_MonoGenericClass;
- MonoGenericClass *gclass;
+ MonoDynamicGenericClass *gclass;
MonoDomain *domain;
MonoClass *klass;
MonoArray *res;
domain = mono_object_domain (type);
- gclass = type->type.type->data.generic_class;
- if (!gclass || !gclass->ifaces)
+ g_assert (type->type.type->data.generic_class->is_dynamic);
+ gclass = (MonoDynamicGenericClass *) type->type.type->data.generic_class;
+ if (!gclass->ifaces)
return mono_array_new (domain, System_Reflection_MonoGenericClass, 0);
- klass = gclass->container_class;
+ klass = gclass->generic_class.generic_class.container_class;
res = mono_array_new (domain, System_Reflection_MonoGenericClass, gclass->count_ifaces);
return res;
}
+
+static MonoReflectionMethod*
+ves_icall_MonoGenericClass_GetCorrespondingInflatedMethod (MonoReflectionGenericClass *type,
+ MonoReflectionMethod* generic)
+{
+ MonoGenericClass *gclass;
+ MonoDynamicGenericClass *dgclass;
+ MonoDomain *domain;
+ int i;
+
+ MONO_ARCH_SAVE_REGS;
+
+ gclass = type->type.type->data.generic_class;
+ g_assert (gclass->is_dynamic);
+
+ dgclass = (MonoDynamicGenericClass *) gclass;
+
+ domain = mono_object_domain (type);
+
+ for (i = 0; i < dgclass->count_methods; i++)
+ if (generic->method->token == dgclass->methods [i]->token)
+ return mono_method_get_object (domain, dgclass->methods [i], NULL);
+
+ return NULL;
+}
+
+static MonoReflectionMethod*
+ves_icall_MonoGenericClass_GetCorrespondingInflatedConstructor (MonoReflectionGenericClass *type,
+ MonoReflectionMethod* generic)
+{
+ MonoGenericClass *gclass;
+ MonoDynamicGenericClass *dgclass;
+ MonoDomain *domain;
+ int i;
+
+ MONO_ARCH_SAVE_REGS;
+
+ gclass = type->type.type->data.generic_class;
+ g_assert (gclass->is_dynamic);
+
+ dgclass = (MonoDynamicGenericClass *) gclass;
+
+ domain = mono_object_domain (type);
+
+ for (i = 0; i < dgclass->count_ctors; i++)
+ if (generic->method->token == dgclass->ctors [i]->token)
+ return mono_method_get_object (domain, dgclass->ctors [i], NULL);
+
+ return NULL;
+}
+
+
+static MonoReflectionField*
+ves_icall_MonoGenericClass_GetCorrespondingInflatedField (MonoReflectionGenericClass *type,
+ MonoString* generic_name)
+{
+ MonoGenericClass *gclass;
+ MonoDynamicGenericClass *dgclass;
+ MonoDomain *domain;
+ MonoClass *refclass;
+ char *utf8_name = mono_string_to_utf8 (generic_name);
+ int i;
+
+ MONO_ARCH_SAVE_REGS;
+
+ gclass = type->type.type->data.generic_class;
+ g_assert (gclass->is_dynamic);
+
+ dgclass = (MonoDynamicGenericClass *) gclass;
+
+ refclass = mono_class_from_mono_type (type->type.type);
+
+ domain = mono_object_domain (type);
+
+ for (i = 0; i < dgclass->count_fields; i++)
+ if (strcmp (utf8_name, dgclass->fields [i].name) == 0) {
+ g_free (utf8_name);
+ return mono_field_get_object (domain, refclass, &dgclass->fields [i]);
+ }
+
+ g_free (utf8_name);
+
+ return NULL;
+}
+
+
+static MonoReflectionMethod*
+ves_icall_MonoType_GetCorrespondingInflatedMethod (MonoReflectionType *type,
+ MonoReflectionMethod* generic)
+{
+ MonoDomain *domain;
+ MonoClass *klass;
+ MonoMethod *method;
+ gpointer iter;
+
+ MONO_ARCH_SAVE_REGS;
+
+ domain = ((MonoObject *)type)->vtable->domain;
+
+ klass = mono_class_from_mono_type (type->type);
+
+ iter = NULL;
+ while ((method = mono_class_get_methods (klass, &iter))) {
+ if (method->token == generic->method->token)
+ return mono_method_get_object (domain, method, klass);
+ }
+
+ return NULL;
+}
+
static MonoArray*
ves_icall_MonoGenericClass_GetMethods (MonoReflectionGenericClass *type,
MonoReflectionType *reflected_type)
if (attr->charset == 1)
attr->charset = 2;
attr->exact_spelling = (flags & 0x1) != 0;
- attr->set_last_error = (flags & 0x4) != 0;
- attr->best_fit_mapping = (flags & 0x10) != 0;
- attr->throw_on_unmappable = (flags & 0x1000) != 0;
+ attr->set_last_error = (flags & 0x40) != 0;
+ attr->best_fit_mapping = (flags & 0x30) == 0x10;
+ attr->throw_on_unmappable = (flags & 0x3000) == 0x1000;
attr->preserve_sig = FALSE;
return attr;
MONO_ARCH_SAVE_REGS;
- if (this) {
- if (!mono_object_isinst (this, m->klass))
+ if (!(m->flags & METHOD_ATTRIBUTE_STATIC)) {
+ if (this) {
+ if (!mono_object_isinst (this, m->klass))
+ mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
+ m = mono_object_get_virtual_method (this, m);
+ /* must pass the pointer to the value for valuetype methods */
+ if (m->klass->valuetype)
+ obj = mono_object_unbox (this);
+ } else if (strcmp (m->name, ".ctor") && !m->wrapper_type)
mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
- m = mono_object_get_virtual_method (this, m);
- /* must pass the pointer to the value for valuetype methods */
- if (m->klass->valuetype)
- obj = mono_object_unbox (this);
- } else if (!(m->flags & METHOD_ATTRIBUTE_STATIC) && strcmp (m->name, ".ctor") && !m->wrapper_type)
- mono_raise_exception (mono_exception_from_name (mono_defaults.corlib, "System.Reflection", "TargetException"));
+ }
pcount = params? mono_array_length (params): 0;
if (pcount != mono_method_signature (m)->param_count)
else
result = *((gpointer *)((char *)this + field->offset));
- g_assert (result);
out_args = mono_array_new (domain, mono_defaults.object_class, 1);
*outArgs = out_args;
mono_array_set (out_args, gpointer, 0, result);
}
g_free (utf8_name);
- return mono_field_get_object (domain, startklass, field);
+ return mono_field_get_object (domain, klass, field);
}
if (!(bflags & BFLAGS_DeclaredOnly) && (klass = klass->parent))
goto handle_parent;
memset (method_slots, 0, sizeof (method_slots_default));
}
handle_parent:
+ mono_class_setup_vtable (klass);
iter = NULL;
while ((method = mono_class_get_methods (klass, &iter))) {
match = 0;
memset (method_slots, 0, sizeof (method_slots_default));
}
handle_parent:
+ mono_class_setup_vtable (klass);
iter = NULL;
while ((prop = mono_class_get_properties (klass, &iter))) {
match = 0;
g_list_free (info.modifiers);
g_list_free (info.nested);
if (throwOnError) /* uhm: this is a parse error, though... */
- mono_raise_exception (mono_get_exception_type_load (name));
+ mono_raise_exception (mono_get_exception_type_load (name, NULL));
/*g_print ("failed parse\n");*/
return NULL;
}
g_list_free (info.nested);
if (!type) {
if (throwOnError)
- mono_raise_exception (mono_get_exception_type_load (name));
+ mono_raise_exception (mono_get_exception_type_load (name, NULL));
/* g_print ("failed find\n"); */
return NULL;
}
return result;
}
+static MonoObject*
+create_version (MonoDomain *domain, guint32 major, guint32 minor, guint32 build, guint32 revision)
+{
+ static MonoClass *System_Version = NULL;
+ static MonoMethod *create_version = NULL;
+ MonoObject *result;
+ gpointer args [4];
+
+ 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);
+ g_assert (create_version);
+ mono_method_desc_free (desc);
+ }
+
+ args [0] = &major;
+ args [1] = &minor;
+ args [2] = &build;
+ args [3] = &revision;
+ result = mono_object_new (domain, System_Version);
+ mono_runtime_invoke (create_version, result, args, NULL);
+
+ return result;
+}
+
static MonoArray*
ves_icall_System_Reflection_Assembly_GetReferencedAssemblies (MonoReflectionAssembly *assembly)
{
MonoDomain *domain = mono_object_domain (assembly);
int i, count = 0;
static MonoMethod *create_culture = NULL;
+ MonoImage *image = assembly->assembly->image;
MonoTableInfo *t;
MONO_ARCH_SAVE_REGS;
}
for (i = 0; i < count; i++) {
- MonoAssembly *assem;
MonoReflectionAssemblyName *aname;
+ guint32 cols [MONO_ASSEMBLYREF_SIZE];
- /* FIXME: There is no need to load the assemblies themselves */
- mono_assembly_load_reference (assembly->assembly->image, i);
-
- assem = assembly->assembly->image->references [i];
- if (assem == (gpointer)-1) {
- char *msg = g_strdup_printf ("Assembly %d referenced from assembly %s not found ", i, assembly->assembly->image->name);
- MonoException *ex = mono_get_exception_file_not_found2 (msg, NULL);
- g_free (msg);
- mono_raise_exception (ex);
- }
+ mono_metadata_decode_row (t, i, cols, MONO_ASSEMBLYREF_SIZE);
aname = (MonoReflectionAssemblyName *) mono_object_new (
domain, System_Reflection_AssemblyName);
- aname->name = mono_string_new (domain, assem->aname.name);
+ aname->name = mono_string_new (domain, mono_metadata_string_heap (image, cols [MONO_ASSEMBLYREF_NAME]));
- aname->major = assem->aname.major;
- aname->minor = assem->aname.minor;
- aname->build = assem->aname.build;
- aname->revision = assem->aname.revision;
- aname->revision = assem->aname.revision;
- aname->hashalg = assem->aname.hash_alg;
- aname->flags = assem->aname.flags;
+ aname->major = cols [MONO_ASSEMBLYREF_MAJOR_VERSION];
+ aname->minor = cols [MONO_ASSEMBLYREF_MINOR_VERSION];
+ aname->build = cols [MONO_ASSEMBLYREF_BUILD_NUMBER];
+ aname->revision = cols [MONO_ASSEMBLYREF_REV_NUMBER];
+ aname->flags = cols [MONO_ASSEMBLYREF_FLAGS];
aname->versioncompat = 1; /* SameMachine (default) */
+ aname->hashalg = ASSEMBLY_HASH_SHA1; /* SHA1 (default) */
+ aname->version = create_version (domain, aname->major, aname->minor, aname->build, aname->revision);
if (create_culture) {
gpointer args [1];
- args [0] = mono_string_new (domain, assem->aname.culture);
+ args [0] = mono_string_new (domain, mono_metadata_string_heap (image, cols [MONO_ASSEMBLYREF_CULTURE]));
aname->cultureInfo = mono_runtime_invoke (create_culture, NULL, args, NULL);
}
-
- if (assem->aname.public_key) {
- guint32 pkey_len;
- const char *pkey_ptr = (char*)assem->aname.public_key;
- pkey_len = mono_metadata_decode_blob_size (pkey_ptr, &pkey_ptr);
-
- aname->publicKey = mono_array_new (domain, mono_defaults.byte_class, pkey_len);
- memcpy (mono_array_addr (aname->publicKey, guint8, 0), pkey_ptr, pkey_len);
+
+ if (cols [MONO_ASSEMBLYREF_PUBLIC_KEY]) {
+ const gchar *pkey_ptr = mono_metadata_blob_heap (image, cols [MONO_ASSEMBLYREF_PUBLIC_KEY]);
+ guint32 pkey_len = mono_metadata_decode_blob_size (pkey_ptr, &pkey_ptr);
+
+ if ((cols [MONO_ASSEMBLYREF_FLAGS] & ASSEMBLYREF_FULL_PUBLIC_KEY_FLAG)) {
+ /* public key token isn't copied - the class library will
+ automatically generate it from the public key if required */
+ aname->publicKey = mono_array_new (domain, mono_defaults.byte_class, pkey_len);
+ memcpy (mono_array_addr (aname->publicKey, guint8, 0), pkey_ptr, pkey_len);
+ } else {
+ aname->keyToken = mono_array_new (domain, mono_defaults.byte_class, pkey_len);
+ memcpy (mono_array_addr (aname->keyToken, guint8, 0), pkey_ptr, pkey_len);
+ }
}
-
- /* public key token isn't copied - the class library will
- automatically generate it from the public key if required */
-
+
/* note: this function doesn't return the codebase on purpose (i.e. it can
be used under partial trust as path information isn't present). */
real_module_count = module_count;
modules = g_new0 (MonoImage*, module_count);
- for (i = 0; i < mono_array_length (assemblyb->modules); ++i) {
- modules [i] =
- mono_array_get (assemblyb->modules, MonoReflectionModuleBuilder*, i)->module.image;
+ if (assemblyb->modules) {
+ for (i = 0; i < mono_array_length (assemblyb->modules); ++i) {
+ modules [i] =
+ mono_array_get (assemblyb->modules, MonoReflectionModuleBuilder*, i)->module.image;
+ }
}
}
else {
}
static MonoString *
-ves_icall_System_MonoType_getFullName (MonoReflectionType *object, gboolean full_name)
+ves_icall_System_MonoType_getFullName (MonoReflectionType *object, gboolean full_name,
+ gboolean assembly_qualified)
{
MonoDomain *domain = mono_object_domain (object);
+ MonoTypeNameFormat format;
MonoString *res;
gchar *name;
MONO_ARCH_SAVE_REGS;
-
if (full_name)
- name = mono_type_get_full_name (object->type);
+ format = assembly_qualified ?
+ MONO_TYPE_NAME_FORMAT_ASSEMBLY_QUALIFIED :
+ MONO_TYPE_NAME_FORMAT_FULL_NAME;
else
- name = mono_type_get_name (object->type);
+ format = MONO_TYPE_NAME_FORMAT_REFLECTION;
+
+ name = mono_type_get_name_full (object->type, format);
+ if (!name)
+ return NULL;
+
res = mono_string_new (domain, name);
g_free (name);
}
static void
-fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute)
+fill_reflection_assembly_name (MonoDomain *domain, MonoReflectionAssemblyName *aname, MonoAssemblyName *name, const char *absolute, gboolean by_default_version)
{
static MonoMethod *create_culture = NULL;
gpointer args [1];
aname->build = name->build;
aname->revision = name->revision;
aname->hashalg = name->hash_alg;
-
+ if (by_default_version)
+ aname->version = create_version (domain, name->major, name->minor, name->build, name->revision);
+
codebase = g_filename_to_uri (absolute, NULL, NULL);
if (codebase) {
aname->codebase = mono_string_new (domain, codebase);
mono_method_desc_free (desc);
}
- args [0] = mono_string_new (domain, name->culture);
- aname->cultureInfo =
- mono_runtime_invoke (create_culture, NULL, args, NULL);
+ if (name->culture) {
+ args [0] = mono_string_new (domain, name->culture);
+ aname->cultureInfo = mono_runtime_invoke (create_culture, NULL, args, NULL);
+ }
if (name->public_key) {
pkey_ptr = (char*)name->public_key;
absolute = g_build_filename (assembly->assembly->basedir, assembly->assembly->image->module_name, NULL);
fill_reflection_assembly_name (mono_object_domain (assembly), aname,
- &assembly->assembly->aname, absolute);
+ &assembly->assembly->aname, absolute, TRUE);
g_free (absolute);
}
mono_raise_exception (mono_get_exception_argument ("assemblyFile", "The file does not contain a manifest"));
}
- fill_reflection_assembly_name (mono_domain_get (), aname, &name, filename);
+ fill_reflection_assembly_name (mono_domain_get (), aname, &name, filename, TRUE);
g_free (filename);
mono_image_close (image);
return res;
}
+static gboolean
+ves_icall_System_Reflection_AssemblyName_ParseName (MonoReflectionAssemblyName *name, MonoString *assname)
+{
+ MonoAssemblyName aname;
+ MonoDomain *domain = mono_object_domain (name);
+ char *val;
+ gboolean is_version_defined;
+
+ val = mono_string_to_utf8 (assname);
+ if (!mono_assembly_name_parse_full (val, &aname, TRUE, &is_version_defined))
+ return FALSE;
+
+ fill_reflection_assembly_name (domain, name, &aname, "", is_version_defined);
+
+ mono_assembly_name_free (&aname);
+ g_free ((guint8*) aname.public_key);
+ g_free (val);
+
+ return TRUE;
+}
+
static MonoReflectionType*
ves_icall_System_Reflection_Module_GetGlobalType (MonoReflectionModule *module)
{
MONO_ARCH_SAVE_REGS;
mono_runtime_set_shutting_down ();
+
/* Suspend all managed threads since the runtime is going away */
mono_thread_suspend_all_other_threads ();
ves_icall_System_Environment_GetLogicalDrives (void)
{
gunichar2 buf [128], *ptr, *dname;
- gchar *u8;
+ gunichar2 *u16;
gint initial_size = 127, size = 128;
gint ndrives;
MonoArray *result;
MonoString *drivestr;
MonoDomain *domain = mono_domain_get ();
+ gint len;
MONO_ARCH_SAVE_REGS;
result = mono_array_new (domain, mono_defaults.string_class, ndrives);
ndrives = 0;
do {
- u8 = g_utf16_to_utf8 (dname, -1, NULL, NULL, NULL);
- drivestr = mono_string_new (domain, u8);
- g_free (u8);
+ len = 0;
+ u16 = dname;
+ while (*u16) { u16++; len ++; }
+ drivestr = mono_string_new_utf16 (domain, dname, len);
mono_array_set (result, gpointer, ndrives++, drivestr);
while (*dname++);
} while (*dname);
*to_upper_data_high = ToUpperDataHigh;
}
-static MonoString *
-ves_icall_MonoDebugger_check_runtime_version (MonoString *fname)
-{
- gchar *filename, *error = NULL;
-
- MONO_ARCH_SAVE_REGS;
-
- filename = mono_string_to_utf8 (fname);
- error = mono_debugger_check_runtime_version (filename);
- g_free (filename);
-
- if (error)
- return mono_string_new (mono_domain_get (), error);
- else
- return NULL;
-}
-
static gint32
-ves_icall_MonoDebugger_GetMethodIndex (MonoReflectionMethod *rmethod)
-{
- guint32 index;
-
- MONO_ARCH_SAVE_REGS;
-
- index = mono_method_get_index (rmethod->method);
- if (!index)
- return -1;
-
- return index - rmethod->method->klass->method.first;
-}
-
-static MonoReflectionType*
-ves_icall_MonoDebugger_MakeArrayType (MonoReflectionType *type, int rank)
+ves_icall_MonoDebugger_GetMethodToken (MonoReflectionMethod *method)
{
- MonoClass *klass, *aklass;
-
- MONO_ARCH_SAVE_REGS;
-
- klass = mono_class_from_mono_type (type->type);
- aklass = mono_array_class_get (klass, rank);
-
- return mono_type_get_object (mono_object_domain (type), &aklass->byval_arg);
-}
-
-static int
-ves_icall_MonoDebugger_GetTypeToken (MonoObject *obj)
-{
- MONO_ARCH_SAVE_REGS;
-
- return mono_reflection_get_token (obj);
+ return method->method->token;
}
static MonoBoolean
return found;
}
+static MonoArray*
+custom_attrs_get_by_type (MonoObject *obj, MonoReflectionType *attr_type)
+{
+ return mono_reflection_get_custom_attrs_by_type (obj, attr_type ? mono_class_from_mono_type (attr_type->type) : NULL);
+}
+
static MonoBoolean
GCHandle_CheckCurrentDomain (guint32 gchandle)
{
return mono_gchandle_is_in_domain (gchandle, mono_domain_get ());
}
+static MonoString*
+ves_icall_Mono_Runtime_GetDisplayName (void)
+{
+ char *display_name_str = g_strdup_printf ("Mono %s", VERSION);
+ MonoString *display_name = mono_string_new (mono_domain_get (), display_name_str);
+ g_free (display_name_str);
+ return display_name;
+}
+
+static guchar dbase64 [] = {
+ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
+ 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 62, 128, 128, 128, 63,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 128, 128, 128, 0, 128, 128,
+ 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 128, 128, 128, 128, 128,
+ 128, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51
+ };
+
+static MonoArray *
+base64_to_byte_array (gunichar2 *start, gint ilength, MonoBoolean allowWhitespaceOnly)
+{
+ gint ignored;
+ gint i;
+ gunichar2 c;
+ gunichar2 last, prev_last;
+ gint olength;
+ MonoArray *result;
+ guchar *res_ptr;
+ gint a [4], b [4];
+ MonoException *exc;
+
+ ignored = 0;
+ last = prev_last = 0;
+ for (i = 0; i < ilength; i++) {
+ c = start [i];
+ if (c >= sizeof (dbase64)) {
+ exc = mono_exception_from_name_msg (mono_get_corlib (),
+ "System", "FormatException",
+ "Invalid character found.");
+ mono_raise_exception (exc);
+ } else if (isspace (c)) {
+ ignored++;
+ } else {
+ prev_last = last;
+ last = c;
+ }
+ }
+
+ olength = ilength - ignored;
+
+ if (allowWhitespaceOnly && olength == 0) {
+ return mono_array_new (mono_domain_get (), mono_defaults.byte_class, 0);
+ }
+
+ if ((olength & 3) != 0 || olength <= 0) {
+ exc = mono_exception_from_name_msg (mono_get_corlib (), "System",
+ "FormatException", "Invalid length.");
+ mono_raise_exception (exc);
+ }
+
+ olength = (olength * 3) / 4;
+ if (last == '=')
+ olength--;
+
+ if (prev_last == '=')
+ olength--;
+
+ result = mono_array_new (mono_domain_get (), mono_defaults.byte_class, olength);
+ res_ptr = mono_array_addr (result, guchar, 0);
+ for (i = 0; i < ilength; ) {
+ int k;
+
+ for (k = 0; k < 4 && i < ilength;) {
+ c = start [i++];
+ if (isspace (c))
+ continue;
+
+ a [k] = (guchar) c;
+ if (((b [k] = dbase64 [c]) & 0x80) != 0) {
+ exc = mono_exception_from_name_msg (mono_get_corlib (),
+ "System", "FormatException",
+ "Invalid character found.");
+ mono_raise_exception (exc);
+ }
+ k++;
+ }
+
+ *res_ptr++ = (b [0] << 2) | (b [1] >> 4);
+ if (a [2] != '=')
+ *res_ptr++ = (b [1] << 4) | (b [2] >> 2);
+ if (a [3] != '=')
+ *res_ptr++ = (b [2] << 6) | b [3];
+
+ while (i < ilength && isspace (start [i]))
+ i++;
+ }
+
+ return result;
+}
+
+static MonoArray *
+InternalFromBase64String (MonoString *str, MonoBoolean allowWhitespaceOnly)
+{
+ MONO_ARCH_SAVE_REGS;
+
+ return base64_to_byte_array (mono_string_chars (str),
+ mono_string_length (str), allowWhitespaceOnly);
+}
+
+static MonoArray *
+InternalFromBase64CharArray (MonoArray *input, gint offset, gint length)
+{
+ MONO_ARCH_SAVE_REGS;
+
+ return base64_to_byte_array (mono_array_addr (input, gunichar2, offset),
+ length, FALSE);
+}
+
/* icall map */
typedef struct {
const char *method;
const int size;
} IcallMap;
+static const IcallEntry runtime_icalls [] = {
+ {"GetDisplayName", ves_icall_Mono_Runtime_GetDisplayName}
+};
+
static const IcallEntry activator_icalls [] = {
{"CreateInstanceInternal", ves_icall_System_Activator_CreateInstanceInternal}
};
{"Isatty", ves_icall_System_ConsoleDriver_Isatty },
{"SetBreak", ves_icall_System_ConsoleDriver_SetBreak },
{"SetEcho", ves_icall_System_ConsoleDriver_SetEcho },
- {"TtySetup", ves_icall_System_ConsoleDriver_TtySetup },
+ {"TtySetup", ves_icall_System_ConsoleDriver_TtySetup }
+};
+
+static const IcallEntry convert_icalls [] = {
+ {"InternalFromBase64CharArray", InternalFromBase64CharArray },
+ {"InternalFromBase64String", InternalFromBase64String }
};
static const IcallEntry timezone_icalls [] = {
{"internal_is_lcid_neutral", ves_icall_System_Globalization_CultureInfo_internal_is_lcid_neutral}
};
+static const IcallEntry regioninfo_icalls [] = {
+ {"construct_internal_region_from_lcid", ves_icall_System_Globalization_RegionInfo_construct_internal_region_from_lcid},
+ {"construct_internal_region_from_name", ves_icall_System_Globalization_RegionInfo_construct_internal_region_from_name}
+};
+
static const IcallEntry compareinfo_icalls [] = {
{"assign_sortkey(object,string,System.Globalization.CompareOptions)", ves_icall_System_Globalization_CompareInfo_assign_sortkey},
{"construct_compareinfo(string)", ves_icall_System_Globalization_CompareInfo_construct_compareinfo},
{"CreateDirectory(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_CreateDirectory},
{"CreatePipe(intptr&,intptr&)", ves_icall_System_IO_MonoIO_CreatePipe},
{"DeleteFile(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_DeleteFile},
- {"FindClose(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindClose},
- {"FindFirstFile(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindFirstFile},
- {"FindNextFile(intptr,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_FindNextFile},
{"Flush(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_Flush},
{"GetCurrentDirectory(System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetCurrentDirectory},
{"GetFileAttributes(string,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileAttributes},
{"GetFileStat(string,System.IO.MonoIOStat&,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileStat},
+ {"GetFileSystemEntries", ves_icall_System_IO_MonoIO_GetFileSystemEntries},
{"GetFileType(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetFileType},
{"GetLength(intptr,System.IO.MonoIOError&)", ves_icall_System_IO_MonoIO_GetLength},
{"GetTempPath(string&)", ves_icall_System_IO_MonoIO_GetTempPath},
};
static const IcallEntry customattrs_icalls [] = {
- {"GetCustomAttributesInternal", mono_reflection_get_custom_attrs},
+ {"GetCustomAttributesDataInternal", mono_reflection_get_custom_attrs_data},
+ {"GetCustomAttributesInternal", custom_attrs_get_by_type},
{"IsDefinedInternal", custom_attrs_defined_internal}
};
{"GetArrayRank", ves_icall_MonoType_GetArrayRank},
{"GetConstructors", ves_icall_Type_GetConstructors_internal},
{"GetConstructors_internal", ves_icall_Type_GetConstructors_internal},
+ {"GetCorrespondingInflatedConstructor", ves_icall_MonoType_GetCorrespondingInflatedMethod},
+ {"GetCorrespondingInflatedMethod", ves_icall_MonoType_GetCorrespondingInflatedMethod},
{"GetElementType", ves_icall_MonoType_GetElementType},
{"GetEvents_internal", ves_icall_Type_GetEvents_internal},
{"GetField", ves_icall_Type_GetField},
{"get_BaseType", ves_icall_get_type_parent},
{"get_DeclaringMethod", ves_icall_MonoType_get_DeclaringMethod},
{"get_DeclaringType", ves_icall_MonoType_get_DeclaringType},
- {"get_HasGenericArguments", ves_icall_MonoType_get_HasGenericArguments},
{"get_IsGenericParameter", ves_icall_MonoType_get_IsGenericParameter},
{"get_Module", ves_icall_MonoType_get_Module},
{"get_Name", ves_icall_MonoType_get_Name},
/*
* Private icalls for the Mono Debugger
*/
- {"MonoDebugger_CheckRuntimeVersion", ves_icall_MonoDebugger_check_runtime_version},
- {"MonoDebugger_GetLocalTypeFromSignature", ves_icall_MonoDebugger_GetLocalTypeFromSignature},
- {"MonoDebugger_GetMethod", ves_icall_MonoDebugger_GetMethod},
- {"MonoDebugger_GetMethodIndex", ves_icall_MonoDebugger_GetMethodIndex},
{"MonoDebugger_GetMethodToken", ves_icall_MonoDebugger_GetMethodToken},
- {"MonoDebugger_GetType", ves_icall_MonoDebugger_GetType},
- {"MonoDebugger_GetTypeToken", ves_icall_MonoDebugger_GetTypeToken},
- {"MonoDebugger_MakeArrayType", ves_icall_MonoDebugger_MakeArrayType},
/* normal icalls again */
{"get_EntryPoint", ves_icall_System_Reflection_Assembly_get_EntryPoint},
{"load_with_partial_name", ves_icall_System_Reflection_Assembly_load_with_partial_name}
};
+static const IcallEntry assembly_name_icalls [] = {
+ {"ParseName", ves_icall_System_Reflection_AssemblyName_ParseName}
+};
+
static const IcallEntry methodbase_icalls [] = {
{"GetCurrentMethod", ves_icall_GetCurrentMethod},
{"GetMethodBodyInternal", ves_icall_System_Reflection_MethodBase_GetMethodBodyInternal},
static const IcallEntry monogenericclass_icalls [] = {
{"GetConstructors_internal", ves_icall_MonoGenericClass_GetConstructors},
+ {"GetCorrespondingInflatedConstructor", ves_icall_MonoGenericClass_GetCorrespondingInflatedConstructor},
+ {"GetCorrespondingInflatedField", ves_icall_MonoGenericClass_GetCorrespondingInflatedField},
+ {"GetCorrespondingInflatedMethod", ves_icall_MonoGenericClass_GetCorrespondingInflatedMethod},
{"GetEvents_internal", ves_icall_MonoGenericClass_GetEvents},
{"GetFields_internal", ves_icall_MonoGenericClass_GetFields},
{"GetInterfaces_internal", ves_icall_MonoGenericClass_GetInterfaces},
};
static const IcallEntry monomethod_icalls [] = {
- {"BindGenericParameters", mono_reflection_bind_generic_method_parameters},
{"GetDllImportAttribute", ves_icall_MonoMethod_GetDllImportAttribute},
{"GetGenericArguments", ves_icall_MonoMethod_GetGenericArguments},
{"GetGenericMethodDefinition_impl", ves_icall_MonoMethod_GetGenericMethodDefinition},
{"InternalInvoke", ves_icall_InternalInvoke},
+ {"MakeGenericMethod", mono_reflection_bind_generic_method_parameters},
{"get_HasGenericParameters", ves_icall_MonoMethod_get_HasGenericParameters},
{"get_IsGenericMethodDefinition", ves_icall_MonoMethod_get_IsGenericMethodDefinition},
{"get_Mono_IsInflatedMethod", ves_icall_MonoMethod_get_Mono_IsInflatedMethod},
{"Receive_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&)", ves_icall_System_Net_Sockets_Socket_Receive_internal},
{"RecvFrom_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress&,int&)", ves_icall_System_Net_Sockets_Socket_RecvFrom_internal},
{"RemoteEndPoint_internal(intptr,int&)", ves_icall_System_Net_Sockets_Socket_RemoteEndPoint_internal},
- {"Select_internal(System.Net.Sockets.Socket[]&,System.Net.Sockets.Socket[]&,System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal},
+ {"Select_internal(System.Net.Sockets.Socket[]&,int,int&)", ves_icall_System_Net_Sockets_Socket_Select_internal},
{"SendTo_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,System.Net.SocketAddress,int&)", ves_icall_System_Net_Sockets_Socket_SendTo_internal},
{"Send_internal(intptr,byte[],int,int,System.Net.Sockets.SocketFlags,int&)", ves_icall_System_Net_Sockets_Socket_Send_internal},
{"SetSocketOption_internal(intptr,System.Net.Sockets.SocketOptionLevel,System.Net.Sockets.SocketOptionName,object,byte[],int,int&)", ves_icall_System_Net_Sockets_Socket_SetSocketOption_internal},
};
static const IcallEntry methodbuilder_icalls [] = {
- {"BindGenericParameters", mono_reflection_bind_generic_method_parameters}
+ {"MakeGenericMethod", mono_reflection_bind_generic_method_parameters}
};
static const IcallEntry modulebuilder_icalls [] = {
static const IcallEntry thread_icalls [] = {
{"Abort_internal(object)", ves_icall_System_Threading_Thread_Abort},
+ {"ClrState", ves_icall_System_Threading_Thread_ClrState},
{"CurrentThread_internal", mono_thread_current},
{"GetCachedCurrentCulture", ves_icall_System_Threading_Thread_GetCachedCurrentCulture},
{"GetCachedCurrentUICulture", ves_icall_System_Threading_Thread_GetCachedCurrentUICulture},
{"GetName_internal", ves_icall_System_Threading_Thread_GetName_internal},
{"GetSerializedCurrentCulture", ves_icall_System_Threading_Thread_GetSerializedCurrentCulture},
{"GetSerializedCurrentUICulture", ves_icall_System_Threading_Thread_GetSerializedCurrentUICulture},
+ {"GetState", ves_icall_System_Threading_Thread_GetState},
{"Join_internal", ves_icall_System_Threading_Thread_Join_internal},
+ {"MemoryBarrier", ves_icall_System_Threading_Thread_MemoryBarrier},
{"ResetAbort_internal()", ves_icall_System_Threading_Thread_ResetAbort},
{"Resume_internal()", ves_icall_System_Threading_Thread_Resume},
{"SetCachedCurrentCulture", ves_icall_System_Threading_Thread_SetCachedCurrentCulture},
{"SetName_internal", ves_icall_System_Threading_Thread_SetName_internal},
{"SetSerializedCurrentCulture", ves_icall_System_Threading_Thread_SetSerializedCurrentCulture},
{"SetSerializedCurrentUICulture", ves_icall_System_Threading_Thread_SetSerializedCurrentUICulture},
+ {"SetState", ves_icall_System_Threading_Thread_SetState},
{"Sleep_internal", ves_icall_System_Threading_Thread_Sleep_internal},
- {"Start_internal", ves_icall_System_Threading_Thread_Start_internal},
{"Suspend_internal", ves_icall_System_Threading_Thread_Suspend},
{"Thread_free_internal", ves_icall_System_Threading_Thread_Thread_free_internal},
{"Thread_internal", ves_icall_System_Threading_Thread_Thread_internal},
};
static const IcallEntry type_icalls [] = {
- {"BindGenericParameters", ves_icall_Type_BindGenericParameters},
{"Equals", ves_icall_type_Equals},
{"GetGenericParameterAttributes", ves_icall_Type_GetGenericParameterAttributes},
{"GetGenericParameterConstraints_impl", ves_icall_Type_GetGenericParameterConstraints},
{"GetGenericTypeDefinition_impl", ves_icall_Type_GetGenericTypeDefinition_impl},
{"GetInterfaceMapData", ves_icall_Type_GetInterfaceMapData},
{"GetPacking", ves_icall_Type_GetPacking},
- {"GetTypeCode", ves_icall_type_GetTypeCode},
+ {"GetTypeCode", ves_icall_type_GetTypeCodeInternal},
+ {"GetTypeCodeInternal", ves_icall_type_GetTypeCodeInternal},
{"IsArrayImpl", ves_icall_Type_IsArrayImpl},
{"IsInstanceOfType", ves_icall_type_IsInstanceOfType},
+ {"MakeGenericType", ves_icall_Type_MakeGenericType},
{"MakePointerType", ves_icall_Type_MakePointerType},
{"get_IsGenericInstance", ves_icall_Type_get_IsGenericInstance},
+ {"get_IsGenericType", ves_icall_Type_get_IsGenericType},
{"get_IsGenericTypeDefinition", ves_icall_Type_get_IsGenericTypeDefinition},
{"internal_from_handle", ves_icall_type_from_handle},
{"internal_from_name", ves_icall_type_from_name},
{"set_SecurityEnabled", ves_icall_System_Security_SecurityManager_set_SecurityEnabled}
};
+static const IcallEntry generic_array_icalls [] = {
+ {"GetGenericValueImpl", ves_icall_System_Array_InternalArray_GetGenericValueImpl}
+};
+
/* proto
static const IcallEntry array_icalls [] = {
};
/* keep the entries all sorted */
static const IcallMap icall_entries [] = {
+ {"Mono.Runtime", runtime_icalls, G_N_ELEMENTS (runtime_icalls)},
{"Mono.Security.Cryptography.KeyPairPersistence", keypair_icalls, G_N_ELEMENTS (keypair_icalls)},
{"System.Activator", activator_icalls, G_N_ELEMENTS (activator_icalls)},
{"System.AppDomain", appdomain_icalls, G_N_ELEMENTS (appdomain_icalls)},
{"System.ArgIterator", argiterator_icalls, G_N_ELEMENTS (argiterator_icalls)},
{"System.Array", array_icalls, G_N_ELEMENTS (array_icalls)},
+ {"System.Array/InternalArray`1", generic_array_icalls, G_N_ELEMENTS (generic_array_icalls)},
{"System.Buffer", buffer_icalls, G_N_ELEMENTS (buffer_icalls)},
{"System.Char", char_icalls, G_N_ELEMENTS (char_icalls)},
{"System.Configuration.DefaultConfig", defaultconf_icalls, G_N_ELEMENTS (defaultconf_icalls)},
{"System.ConsoleDriver", consoledriver_icalls, G_N_ELEMENTS (consoledriver_icalls)},
+ {"System.Convert", convert_icalls, G_N_ELEMENTS (convert_icalls)},
{"System.CurrentTimeZone", timezone_icalls, G_N_ELEMENTS (timezone_icalls)},
{"System.DateTime", datetime_icalls, G_N_ELEMENTS (datetime_icalls)},
#ifndef DISABLE_DECIMAL
{"System.GC", gc_icalls, G_N_ELEMENTS (gc_icalls)},
{"System.Globalization.CompareInfo", compareinfo_icalls, G_N_ELEMENTS (compareinfo_icalls)},
{"System.Globalization.CultureInfo", cultureinfo_icalls, G_N_ELEMENTS (cultureinfo_icalls)},
+ {"System.Globalization.RegionInfo", regioninfo_icalls, G_N_ELEMENTS (regioninfo_icalls)},
{"System.IO.FAMWatcher", famwatcher_icalls, G_N_ELEMENTS (famwatcher_icalls)},
{"System.IO.FileSystemWatcher", filewatcher_icalls, G_N_ELEMENTS (filewatcher_icalls)},
{"System.IO.MonoIO", monoio_icalls, G_N_ELEMENTS (monoio_icalls)},
{"System.Net.Sockets.SocketException", socketex_icalls, G_N_ELEMENTS (socketex_icalls)},
{"System.Object", object_icalls, G_N_ELEMENTS (object_icalls)},
{"System.Reflection.Assembly", assembly_icalls, G_N_ELEMENTS (assembly_icalls)},
+ {"System.Reflection.AssemblyName", assembly_name_icalls, G_N_ELEMENTS (assembly_name_icalls)},
{"System.Reflection.Emit.AssemblyBuilder", assemblybuilder_icalls, G_N_ELEMENTS (assemblybuilder_icalls)},
{"System.Reflection.Emit.CustomAttributeBuilder", customattrbuilder_icalls, G_N_ELEMENTS (customattrbuilder_icalls)},
{"System.Reflection.Emit.DynamicMethod", dynamicmethod_icalls, G_N_ELEMENTS (dynamicmethod_icalls)},
g_assert (method != NULL);
- typelen = concat_class_name (mname, sizeof (mname), method->klass);
- if (!typelen)
- return NULL;
+ if (method->klass->nested_in) {
+ int pos = concat_class_name (mname, sizeof (mname)-2, method->klass->nested_in);
+ if (!pos)
+ return NULL;
+
+ mname [pos++] = '/';
+ mname [pos] = 0;
+
+ typelen = concat_class_name (mname+pos, sizeof (mname)-pos-1, method->klass);
+ if (!typelen)
+ return NULL;
+
+ typelen += pos;
+ } else {
+ typelen = concat_class_name (mname, sizeof (mname), method->klass);
+ if (!typelen)
+ return NULL;
+ }
imap = find_class_icalls (mname);