#ifdef __CYGWIN__
#define mono_map_dll(name) (name)
#else
-static char *dll_map[] = {
+static const char *dll_map[] = {
"libc", "libc.so.6",
"libm", "libm.so.6",
"cygwin1.dll", "libc.so.6",
}
#endif
-void
-mono_init (void)
-{
- static gboolean initialized = FALSE;
- MonoAssembly *ass;
- enum MonoImageOpenStatus status = MONO_IMAGE_OK;
-
- if (initialized)
- return;
-
- /* find the corlib */
- ass = mono_assembly_open (CORLIB_NAME, NULL, &status);
- g_assert (status == MONO_IMAGE_OK);
- g_assert (ass != NULL);
- mono_defaults.corlib = ass->image;
-
- mono_defaults.object_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Object");
- g_assert (mono_defaults.object_class != 0);
-
- mono_defaults.void_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Void");
- g_assert (mono_defaults.void_class != 0);
-
- mono_defaults.boolean_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Boolean");
- g_assert (mono_defaults.boolean_class != 0);
-
- mono_defaults.byte_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Byte");
- g_assert (mono_defaults.byte_class != 0);
-
- mono_defaults.sbyte_class = mono_class_from_name (
- mono_defaults.corlib, "System", "SByte");
- g_assert (mono_defaults.sbyte_class != 0);
-
- mono_defaults.int16_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Int16");
- g_assert (mono_defaults.int16_class != 0);
-
- mono_defaults.uint16_class = mono_class_from_name (
- mono_defaults.corlib, "System", "UInt16");
- g_assert (mono_defaults.uint16_class != 0);
-
- mono_defaults.int32_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Int32");
- g_assert (mono_defaults.int32_class != 0);
-
- mono_defaults.uint32_class = mono_class_from_name (
- mono_defaults.corlib, "System", "UInt32");
- g_assert (mono_defaults.uint32_class != 0);
-
- mono_defaults.uint_class = mono_class_from_name (
- mono_defaults.corlib, "System", "UIntPtr");
- g_assert (mono_defaults.uint_class != 0);
-
- mono_defaults.int_class = mono_class_from_name (
- mono_defaults.corlib, "System", "IntPtr");
- g_assert (mono_defaults.int_class != 0);
-
- mono_defaults.int64_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Int64");
- g_assert (mono_defaults.int64_class != 0);
-
- mono_defaults.uint64_class = mono_class_from_name (
- mono_defaults.corlib, "System", "UInt64");
- g_assert (mono_defaults.uint64_class != 0);
-
- mono_defaults.single_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Single");
- g_assert (mono_defaults.single_class != 0);
-
- mono_defaults.double_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Double");
- g_assert (mono_defaults.double_class != 0);
-
- mono_defaults.char_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Char");
- g_assert (mono_defaults.char_class != 0);
-
- mono_defaults.string_class = mono_class_from_name (
- mono_defaults.corlib, "System", "String");
- g_assert (mono_defaults.string_class != 0);
-
- mono_defaults.enum_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Enum");
- g_assert (mono_defaults.enum_class != 0);
-
- mono_defaults.array_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Array");
- g_assert (mono_defaults.array_class != 0);
-
- mono_defaults.delegate_class = mono_class_from_name (
- mono_defaults.corlib, "System", "Delegate");
- g_assert (mono_defaults.delegate_class != 0);
-
- mono_defaults.typehandle_class = mono_class_from_name (
- mono_defaults.corlib, "System", "RuntimeTypeHandle");
- g_assert (mono_defaults.typehandle_class != 0);
-
- mono_defaults.methodhandle_class = mono_class_from_name (
- mono_defaults.corlib, "System", "RuntimeMethodHandle");
- g_assert (mono_defaults.methodhandle_class != 0);
-
- mono_defaults.fieldhandle_class = mono_class_from_name (
- mono_defaults.corlib, "System", "RuntimeFieldHandle");
- g_assert (mono_defaults.fieldhandle_class != 0);
-
- mono_defaults.monotype_class = mono_class_from_name (
- mono_defaults.corlib, "System", "MonoType");
- g_assert (mono_defaults.monotype_class != 0);
-}
-
static GHashTable *icall_hash = NULL;
void
-mono_add_internal_call (const char *name, gpointer method)
+mono_add_internal_call (const char *name, gconstpointer method)
{
if (!icall_hash) {
dummy_icall = FALSE;
}
static void
-ves_icall_dummy ()
+ves_icall_dummy (void)
{
g_warning ("the mono runtime is not initialized");
g_assert_not_reached ();
guint32 nindex, class, i;
const char *fname, *name, *nspace;
const char *ptr;
- guint32 index = mono_metadata_token_index (token);
+ guint32 idx = mono_metadata_token_index (token);
- mono_metadata_decode_row (&tables [MONO_TABLE_MEMBERREF], index-1, cols, MONO_MEMBERREF_SIZE);
+ mono_metadata_decode_row (&tables [MONO_TABLE_MEMBERREF], idx-1, cols, MONO_MEMBERREF_SIZE);
nindex = cols [MONO_MEMBERREF_CLASS] >> MEMBERREF_PARENT_BITS;
class = cols [MONO_MEMBERREF_CLASS] & MEMBERREF_PARENT_MASK;
mimage = image->references [scopeindex-1]->image;
klass = mono_class_from_name (mimage, nspace, name);
- mono_class_metadata_init (klass);
+ mono_class_init (klass);
/* mostly dumb search for now */
for (i = 0; i < klass->field.count; ++i) {
}
static MonoMethod *
-method_from_memberref (MonoImage *image, guint32 index)
+method_from_memberref (MonoImage *image, guint32 idx)
{
MonoImage *mimage;
MonoClass *klass;
MonoMethodSignature *sig;
const char *ptr;
- mono_metadata_decode_row (&tables [MONO_TABLE_MEMBERREF], index-1, cols, 3);
+ mono_metadata_decode_row (&tables [MONO_TABLE_MEMBERREF], idx-1, cols, 3);
nindex = cols [MONO_MEMBERREF_CLASS] >> MEMBERREF_PARENT_BITS;
class = cols [MONO_MEMBERREF_CLASS] & MEMBERREF_PARENT_MASK;
/*g_print ("methodref: 0x%x 0x%x %s\n", class, nindex,
mimage = image->references [scopeindex-1]->image;
klass = mono_class_from_name (mimage, nspace, name);
- mono_class_metadata_init (klass);
-
- /*
- * FIXME: this is a workaround for the different signatures
- * in delegates constructors you get in user code (native int)
- * and in mscorlib (native unsigned int)
- */
- if (klass->parent && klass->parent->parent == mono_defaults.delegate_class) {
- for (i = 0; i < klass->method.count; ++i) {
- MonoMethod *m = klass->methods [i];
- if (!strcmp (mname, m->name)) {
- if (!strcmp (mname, ".ctor")) {
- /* we assume signature is correct */
- mono_metadata_free_method_signature (sig);
- return m;
- }
- if (mono_metadata_signature_equal (sig, m->signature)) {
- mono_metadata_free_method_signature (sig);
- return m;
- }
- }
- }
+ if (!klass) {
+ g_warning ("Missing method %s.%s::%s", nspace, name, mname);
+ mono_metadata_free_method_signature (sig);
+ return NULL;
}
+ mono_class_init (klass);
+
/* mostly dumb search for now */
for (i = 0; i < klass->method.count; ++i) {
MonoMethod *m = klass->methods [i];
return result;
}
+ if (!strcmp (mname, "Address")) {
+ g_assert (sig->hasthis);
+ g_assert (type->data.array->rank == sig->param_count);
+
+ result->addr = mono_lookup_internal_call ("__array_Address");
+ return result;
+ }
+
g_assert_not_reached ();
break;
}
}
static void
-fill_pinvoke_info (MonoImage *image, MonoMethodPInvoke *piinfo, int index)
+fill_pinvoke_info (MonoImage *image, MonoMethodPInvoke *piinfo, int idx)
{
MonoMethod *mh = &piinfo->method;
MonoTableInfo *tables = image->tables;
mono_metadata_decode_row (im, i, im_cols, 4);
- if ((im_cols[1] >> 1) == index + 1) {
+ if ((im_cols[1] >> 1) == idx + 1) {
import = mono_metadata_string_heap (image, im_cols [2]);
{
MonoMethod *result;
int table = mono_metadata_token_table (token);
- int index = mono_metadata_token_index (token);
+ int idx = mono_metadata_token_index (token);
MonoTableInfo *tables = image->tables;
const char *loc, *sig = NULL;
char *name;
return result;
if (table != MONO_TABLE_METHOD) {
+ if (table != MONO_TABLE_MEMBERREF)
+ g_print("got wrong token: 0x%08x\n", token);
g_assert (table == MONO_TABLE_MEMBERREF);
- result = method_from_memberref (image, index);
+ result = method_from_memberref (image, idx);
g_hash_table_insert (image->method_cache, GINT_TO_POINTER (token), result);
return result;
}
- mono_metadata_decode_row (&tables [table], index - 1, cols, 6);
+ mono_metadata_decode_row (&tables [table], idx - 1, cols, 6);
if ((cols [2] & METHOD_ATTRIBUTE_PINVOKE_IMPL) ||
(cols [1] & METHOD_IMPL_ATTRIBUTE_INTERNAL_CALL))
g_free (name);
result->flags |= METHOD_ATTRIBUTE_PINVOKE_IMPL;
} else if (cols [2] & METHOD_ATTRIBUTE_PINVOKE_IMPL) {
- fill_pinvoke_info (image, (MonoMethodPInvoke *)result, index - 1);
+ fill_pinvoke_info (image, (MonoMethodPInvoke *)result, idx - 1);
} else {
/* if this is a methodref from another module/assembly, this fails */
loc = mono_cli_rva_map ((MonoCLIImageInfo *)image->image_info, cols [0]);
for (i = 0; i < method->signature->param_count; ++i)
names [i] = "";
- mono_class_metadata_init (klass);
+ mono_class_init (klass);
if (!klass->methods)
return;
for (i = 0; i < klass->method.count; ++i) {
if (method == klass->methods [i]) {
- guint32 index = klass->method.first + i;
+ guint32 idx = klass->method.first + i;
guint32 cols [MONO_PARAM_SIZE];
- guint param_index = mono_metadata_decode_row_col (methodt, index, MONO_METHOD_PARAMLIST);
+ guint param_index = mono_metadata_decode_row_col (methodt, idx, MONO_METHOD_PARAMLIST);
- if (index < methodt->rows)
- lastp = mono_metadata_decode_row_col (methodt, index + 1, MONO_METHOD_PARAMLIST);
+ if (idx < methodt->rows)
+ lastp = mono_metadata_decode_row_col (methodt, idx + 1, MONO_METHOD_PARAMLIST);
else
lastp = paramt->rows;
for (i = param_index; i < lastp; ++i) {