#include <mono/metadata/object.h>
#include <mono/metadata/threads.h>
+#include <mono/metadata/threads-types.h>
#include <mono/metadata/threadpool.h>
#include <mono/metadata/monitor.h>
#include <mono/metadata/reflection.h>
#include <mono/metadata/unicode.h>
#include <mono/metadata/domain-internals.h>
#include <mono/metadata/metadata-internals.h>
+#include <mono/metadata/class-internals.h>
#include <mono/metadata/marshal.h>
#include <mono/metadata/gc-internal.h>
#include <mono/metadata/rand.h>
return FALSE;
}
+static void
+ves_icall_EnumBuilder_setup_enum_type (MonoReflectionType *enumtype,
+ MonoReflectionType *t)
+{
+ enumtype->type = t->type;
+}
+
static MonoReflectionType*
ves_icall_MonoGenericInst_GetParentType (MonoReflectionGenericInst *type)
{
*/
MonoMethod *m = method->method;
int pcount;
+ void *obj = this;
MONO_ARCH_SAVE_REGS;
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 (!(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"));
return (MonoObject*)mono_array_new_full (mono_object_domain (params), m->klass, lengths, lower_bounds);
}
- return mono_runtime_invoke_array (m, this, params, NULL);
+ return mono_runtime_invoke_array (m, obj, params, NULL);
}
static MonoObject *
str = mono_string_to_utf8 (name);
- for (i = 0; i < k->field.count; i++) {
- if (!strcmp (k->fields [i].name, str)) {
- MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
- if (field_klass->valuetype)
- result = mono_value_box (domain, field_klass,
- (char *)this + k->fields [i].offset);
- else
- result = *((gpointer *)((char *)this + k->fields [i].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 (str);
- return NULL;
+ do {
+ for (i = 0; i < k->field.count; i++) {
+ if (!strcmp (k->fields [i].name, str)) {
+ MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
+ if (field_klass->valuetype)
+ result = mono_value_box (domain, field_klass,
+ (char *)this + k->fields [i].offset);
+ else
+ result = *((gpointer *)((char *)this + k->fields [i].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 (str);
+ return NULL;
+ }
}
- }
+ k = k->parent;
+ }
+ while (k != NULL);
g_free (str);
g_assert_not_reached ();
str = mono_string_to_utf8 (name);
- for (i = 0; i < k->field.count; i++) {
- if (!strcmp (k->fields [i].name, str)) {
- MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
- MonoObject *val = mono_array_get (params, gpointer, 2);
-
- if (field_klass->valuetype) {
- size = mono_type_size (k->fields [i].type, &align);
- memcpy ((char *)this + k->fields [i].offset,
- ((char *)val) + sizeof (MonoObject), size);
- } else
- *(MonoObject**)((char *)this + k->fields [i].offset) = val;
-
- out_args = mono_array_new (domain, mono_defaults.object_class, 0);
- *outArgs = out_args;
-
- g_free (str);
- return NULL;
+ do {
+ for (i = 0; i < k->field.count; i++) {
+ if (!strcmp (k->fields [i].name, str)) {
+ MonoClass *field_klass = mono_class_from_mono_type (k->fields [i].type);
+ MonoObject *val = mono_array_get (params, gpointer, 2);
+
+ if (field_klass->valuetype) {
+ size = mono_type_size (k->fields [i].type, &align);
+ memcpy ((char *)this + k->fields [i].offset,
+ ((char *)val) + sizeof (MonoObject), size);
+ } else
+ *(MonoObject**)((char *)this + k->fields [i].offset) = val;
+
+ out_args = mono_array_new (domain, mono_defaults.object_class, 0);
+ *outArgs = out_args;
+
+ g_free (str);
+ return NULL;
+ }
}
- }
+ k = k->parent;
+ }
+ while (k != NULL);
g_free (str);
g_assert_not_reached ();
if (!strcmp (method->method->name, ".ctor"))
g_assert_not_reached ();
+ /* 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);
for (i = 0, j = 0; i < mono_array_length (params); i++) {
MonoAssembly **ptr;
MonoDomain *domain = mono_object_domain (assembly);
int i, count = 0;
+ static MonoMethod *create_culture = NULL;
MONO_ARCH_SAVE_REGS;
for (ptr = assembly->assembly->image->references; ptr && *ptr; ptr++)
count++;
- result = mono_array_new (mono_object_domain (assembly), System_Reflection_AssemblyName, count);
+ result = mono_array_new (domain, System_Reflection_AssemblyName, count);
+
+ if (count > 0) {
+ MonoMethodDesc *desc = mono_method_desc_new (
+ "System.Globalization.CultureInfo:CreateSpecificCulture(string)", TRUE);
+ create_culture = mono_method_desc_search_in_image (desc, mono_defaults.corlib);
+ g_assert (create_culture);
+ mono_method_desc_free (desc);
+ }
for (i = 0; i < count; i++) {
MonoAssembly *assem = assembly->assembly->image->references [i];
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;
+
+ if (create_culture) {
+ gpointer args [1];
+ args [0] = mono_string_new (domain, assem->aname.culture);
+ aname->cultureInfo = mono_runtime_invoke (create_culture, NULL, args, NULL);
+ }
+
+ if (assem->aname.public_key) {
+ guint32 pkey_len;
+ const char *pkey_ptr = 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);
+ }
+
+ /* public key token isn't copied - the class library will
+ automatically generate it from the public key if required */
absolute = g_build_filename (assem->basedir, assem->image->module_name, NULL);
codebase = g_filename_to_uri (absolute, NULL, NULL);
* this code should only be called after obtaining the
* ResourceInfo and handling the other cases.
*/
- g_assert ((impl & IMPLEMENTATION_MASK) == IMPLEMENTATION_FILE);
- file_idx = impl >> IMPLEMENTATION_BITS;
+ g_assert ((impl & MONO_IMPLEMENTATION_MASK) == MONO_IMPLEMENTATION_FILE);
+ file_idx = impl >> MONO_IMPLEMENTATION_BITS;
module = mono_image_load_file_for_image (assembly->assembly->image, file_idx);
if (!module)
info->location = RESOURCE_LOCATION_EMBEDDED | RESOURCE_LOCATION_IN_MANIFEST;
}
else {
- switch (cols [MONO_MANIFEST_IMPLEMENTATION] & IMPLEMENTATION_MASK) {
- case IMPLEMENTATION_FILE:
- i = cols [MONO_MANIFEST_IMPLEMENTATION] >> IMPLEMENTATION_BITS;
+ switch (cols [MONO_MANIFEST_IMPLEMENTATION] & MONO_IMPLEMENTATION_MASK) {
+ case MONO_IMPLEMENTATION_FILE:
+ i = cols [MONO_MANIFEST_IMPLEMENTATION] >> MONO_IMPLEMENTATION_BITS;
table = &assembly->assembly->image->tables [MONO_TABLE_FILE];
mono_metadata_decode_row (table, i - 1, file_cols, MONO_FILE_SIZE);
val = mono_metadata_string_heap (assembly->assembly->image, file_cols [MONO_FILE_NAME]);
info->location = RESOURCE_LOCATION_EMBEDDED;
break;
- case IMPLEMENTATION_ASSEMBLYREF:
- i = cols [MONO_MANIFEST_IMPLEMENTATION] >> IMPLEMENTATION_BITS;
+ case MONO_IMPLEMENTATION_ASSEMBLYREF:
+ i = cols [MONO_MANIFEST_IMPLEMENTATION] >> MONO_IMPLEMENTATION_BITS;
info->assembly = mono_assembly_get_object (mono_domain_get (), assembly->assembly->image->references [i - 1]);
/* Obtain info recursively */
info->location |= RESOURCE_LOCATION_ANOTHER_ASSEMBLY;
break;
- case IMPLEMENTATION_EXP_TYPE:
+ case MONO_IMPLEMENTATION_EXP_TYPE:
g_assert_not_reached ();
break;
}
MONO_ARCH_SAVE_REGS;
if (!domain->entry_assembly)
- domain = mono_root_domain;
+ domain = mono_get_root_domain ();
return mono_assembly_get_object (domain, domain->entry_assembly);
}
iter->args = (char*)iter->args + arg_size;
iter->next_arg++;
- //g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value);
+ /* g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value); */
return res;
}
arg_size = mono_type_stack_size (res.type, &align);
iter->args = (char*)iter->args + arg_size;
iter->next_arg++;
- //g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value);
+ /* g_print ("returning arg %d, type 0x%02x of size %d at %p\n", i, res.type->type, arg_size, res.value); */
return res;
}
- //g_print ("arg type 0x%02x not found\n", res.type->type);
+ /* g_print ("arg type 0x%02x not found\n", res.type->type); */
res.type = NULL;
res.value = NULL;
{"setup_internal_class", mono_reflection_setup_internal_class}
};
+static const IcallEntry enumbuilder_icalls [] = {
+ {"setup_enum_type", ves_icall_EnumBuilder_setup_enum_type}
+};
+
static const IcallEntry runtimehelpers_icalls [] = {
{"GetObjectValue", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetObjectValue},
+ /* REMOVEME: no longer needed, just so we dont break things when not needed */
{"GetOffsetToStringData", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData},
{"InitializeArray", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_InitializeArray},
- {"RunClassConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor}
+ {"RunClassConstructor", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_RunClassConstructor},
+ {"get_OffsetToStringData", ves_icall_System_Runtime_CompilerServices_RuntimeHelpers_GetOffsetToStringData}
};
static const IcallEntry gchandle_icalls [] = {
};
static const IcallEntry mutex_icalls [] = {
- {"CreateMutex_internal", ves_icall_System_Threading_Mutex_CreateMutex_internal},
- {"ReleaseMutex_internal", ves_icall_System_Threading_Mutex_ReleaseMutex_internal}
+ {"CreateMutex_internal(bool,string,bool&)", ves_icall_System_Threading_Mutex_CreateMutex_internal},
+ {"ReleaseMutex_internal(intptr)", ves_icall_System_Threading_Mutex_ReleaseMutex_internal}
};
static const IcallEntry nativeevents_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)},
+ {"System.Reflection.Emit.EnumBuilder", enumbuilder_icalls, G_N_ELEMENTS (enumbuilder_icalls)},
{"System.Reflection.Emit.GenericTypeParameterBuilder", generictypeparambuilder_icalls, G_N_ELEMENTS (generictypeparambuilder_icalls)},
{"System.Reflection.Emit.MethodBuilder", methodbuilder_icalls, G_N_ELEMENTS (methodbuilder_icalls)},
{"System.Reflection.Emit.ModuleBuilder", modulebuilder_icalls, G_N_ELEMENTS (modulebuilder_icalls)},