Skip to content
Browse files

2001-10-10 Dietmar Maurer <dietmar@ximian.com>

        * interp.c (get_virtual_method): use the vtable

        * metadata.c (mono_metadata_interfaces_from_typedef): also return the
        number of interfaces.

        * class.h: merged MonoArrayClass into MonoClass

        * class.c (mono_class_create_from_typedef): compute the vtable size and
        allocate space to include the vtable inside MonoClass
        (mono_class_metadata_init): initialize the vtable

svn path=/trunk/mono/; revision=1128
  • Loading branch information...
1 parent 4909a2d commit b59cb68bab8b9a612c8d0b83d090958b4ccda23a Dietmar Maurer committed
View
3 mono/interpreter/ChangeLog
@@ -1,3 +1,6 @@
+2001-10-10 Dietmar Maurer <dietmar@ximian.com>
+
+ * interp.c (get_virtual_method): use the vtable
Mon Oct 8 16:14:40 CEST 2001 Paolo Molaro <lupus@ximian.com>
View
48 mono/interpreter/interp.c
@@ -118,13 +118,12 @@ init_class (MonoClass *klass)
if (klass->inited)
return;
+
if (klass->parent && !klass->parent->inited)
init_class (klass->parent);
klass->inited = 1;
- klass->data = g_malloc0 (klass->class_size);
-
for (i = 0; i < klass->method.count; ++i) {
method = klass->methods [i];
if ((method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) && (strcmp (".cctor", method->name) == 0)) {
@@ -197,8 +196,6 @@ newobj (MonoImage *image, guint32 token)
g_assert_not_reached ();
}
- if (result)
- init_class (result->klass);
return result;
}
@@ -207,24 +204,19 @@ get_virtual_method (MonoImage *image, MonoMethod *m, stackval *objs)
{
MonoObject *obj;
MonoClass *klass;
- int i;
-
+ MonoMethod **vtable;
+
if ((m->flags & METHOD_ATTRIBUTE_FINAL) || !(m->flags & METHOD_ATTRIBUTE_VIRTUAL))
return m;
+
obj = objs->data.p;
- klass = objs->data.vt.klass ? objs->data.vt.klass: obj->klass;
- if (!(m->klass->flags & TYPE_ATTRIBUTE_INTERFACE) || klass->flags & TYPE_ATTRIBUTE_INTERFACE)
- klass = obj->klass;
- for (; klass ; klass = klass->parent) {
- for (i = 0; i < klass->method.count; ++i) {
- if (!(klass->methods [i]->flags & METHOD_ATTRIBUTE_VIRTUAL))
- continue;
- if (!strcmp(m->name, klass->methods [i]->name) && mono_metadata_signature_equal (m->signature, klass->methods [i]->signature)) {
- return klass->methods [i];
- }
- }
- }
- return m;
+ klass = obj->klass;
+ vtable = (MonoMethod **)klass->vtable;
+
+ if (m->klass->flags & TYPE_ATTRIBUTE_INTERFACE)
+ return vtable [klass->interface_offsets [m->klass->interface_id] + m->slot];
+
+ return vtable [m->slot];
}
static MonoObject*
@@ -539,14 +531,14 @@ ves_array_set (MonoInvocation *frame)
stackval *sp = frame->stack_args;
MonoObject *o;
MonoArray *ao;
- MonoArrayClass *ac;
+ MonoClass *ac;
gint32 i, t, pos, esize;
gpointer ea;
MonoType *mt;
o = frame->obj;
ao = (MonoArray *)o;
- ac = (MonoArrayClass *)o->klass;
+ ac = o->klass;
g_assert (ac->rank >= 1);
@@ -574,14 +566,14 @@ ves_array_get (MonoInvocation *frame)
stackval *sp = frame->stack_args;
MonoObject *o;
MonoArray *ao;
- MonoArrayClass *ac;
+ MonoClass *ac;
gint32 i, pos, esize;
gpointer ea;
MonoType *mt;
o = frame->obj;
ao = (MonoArray *)o;
- ac = (MonoArrayClass *)o->klass;
+ ac = o->klass;
g_assert (ac->rank >= 1);
@@ -2103,6 +2095,7 @@ ves_exec_method (MonoInvocation *frame)
/*
* a constructor returns void, but we need to return the object we created
*/
+
sp->type = VAL_OBJ;
sp->data.p = o;
sp->data.vt.klass = o->klass;
@@ -2512,11 +2505,12 @@ ves_exec_method (MonoInvocation *frame)
THROW_EX (get_exception_index_out_of_range (), ip - 5);
/* check the array element corresponds to token */
- esize = mono_array_element_size ((MonoArrayClass *)o->obj.klass);
+ esize = mono_array_element_size (o->obj.klass);
sp->type = VAL_MP;
sp->data.p = mono_array_addr_with_size (o, esize, sp [1].data.i);
- sp->data.vt.klass = ((MonoArrayClass *)o->obj.klass)->element_class;
+ sp->data.vt.klass = o->obj.klass->element_class;
+
++sp;
BREAK;
}
@@ -2613,7 +2607,7 @@ ves_exec_method (MonoInvocation *frame)
CASE (CEE_STELEM_R8) /* fall through */
CASE (CEE_STELEM_REF) {
MonoArray *o;
- MonoArrayClass *ac;
+ MonoClass *ac;
mono_u aindex;
sp -= 3;
@@ -2624,7 +2618,7 @@ ves_exec_method (MonoInvocation *frame)
THROW_EX (get_exception_null_reference (), ip);
g_assert (MONO_CLASS_IS_ARRAY (o->obj.klass));
- ac = (MonoArrayClass *)o->obj.klass;
+ ac = o->obj.klass;
aindex = sp [1].data.nati;
if (aindex >= mono_array_length (o))
View
2 mono/jit/jit.c
@@ -447,8 +447,6 @@ mono_jit_init_class (MonoClass *klass)
klass->inited = 1;
- klass->data = mono_alloc_static0 (klass->class_size);
-
for (i = 0; i < klass->method.count; ++i) {
method = klass->methods [i];
if ((method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) &&
View
2 mono/jit/testjit.c
@@ -447,8 +447,6 @@ mono_jit_init_class (MonoClass *klass)
klass->inited = 1;
- klass->data = mono_alloc_static0 (klass->class_size);
-
for (i = 0; i < klass->method.count; ++i) {
method = klass->methods [i];
if ((method->flags & METHOD_ATTRIBUTE_SPECIAL_NAME) &&
View
10 mono/metadata/ChangeLog
@@ -1,3 +1,13 @@
+2001-10-10 Dietmar Maurer <dietmar@ximian.com>
+
+ * metadata.c (mono_metadata_interfaces_from_typedef): also return the
+ number of interfaces.
+
+ * class.h: merged MonoArrayClass into MonoClass
+
+ * class.c (mono_class_create_from_typedef): compute the vtable size and
+ allocate space to include the vtable inside MonoClass
+ (mono_class_metadata_init): initialize the vtable
Mon Oct 8 16:12:38 CEST 2001 Paolo Molaro <lupus@ximian.com>
View
292 mono/metadata/class.c
@@ -151,7 +151,11 @@ class_compute_field_layout (MonoClass *class)
void
mono_class_metadata_init (MonoClass *class)
{
- int i;
+ MonoClass *k, *ic;
+ MonoMethod **vtable = (MonoMethod **)class->vtable;
+ int i, max_iid, cur_slot = 0;
+
+ g_assert (class);
if (class->metadata_inited)
return;
@@ -161,6 +165,7 @@ mono_class_metadata_init (MonoClass *class)
mono_class_metadata_init (class->parent);
class->instance_size += class->parent->instance_size;
class->class_size += class->parent->class_size;
+ cur_slot = class->parent->vtable_size;
}
class->metadata_inited = 1;
@@ -173,15 +178,207 @@ mono_class_metadata_init (MonoClass *class)
class_compute_field_layout (class);
}
- if (!class->method.count)
+ /* initialize mothod pointers */
+ class->methods = g_new (MonoMethod*, class->method.count);
+ for (i = 0; i < class->method.count; ++i)
+ class->methods [i] = mono_get_method (class->image,
+ MONO_TOKEN_METHOD_DEF | (i + class->method.first + 1), class);
+
+ if (class->flags & TYPE_ATTRIBUTE_INTERFACE) {
+ for (i = 0; i < class->method.count; ++i)
+ class->methods [i]->slot = i;
return;
+ }
- class->methods = g_new (MonoMethod*, class->method.count);
- for (i = class->method.first; i < class->method.last; ++i)
- class->methods [i - class->method.first] =
- mono_get_method (class->image,
- MONO_TOKEN_METHOD_DEF | (i + 1),
- class);
+ printf ("METAINIT %s.%s\n", class->name_space, class->name);
+
+ /* compute maximum number of slots and maximum interface id */
+ max_iid = 0;
+ for (k = class; k ; k = k->parent) {
+ for (i = 0; i < k->interface_count; i++) {
+ ic = k->interfaces [i];
+
+ if (!ic->metadata_inited)
+ mono_class_metadata_init (ic);
+
+ if (max_iid < ic->interface_id)
+ max_iid = ic->interface_id;
+ }
+ }
+
+ /* compute vtable offset for interfaces */
+ class->interface_offsets = g_malloc (sizeof (gint*) * (max_iid + 1));
+
+ for (i = 0; i <= max_iid; i++)
+ class->interface_offsets [i] = -1;
+
+ for (i = 0; i < class->interface_count; i++) {
+ ic = class->interfaces [i];
+ class->interface_offsets [ic->interface_id] = cur_slot;
+ cur_slot += ic->method.count;
+ }
+
+ for (k = class->parent; k ; k = k->parent) {
+ for (i = 0; i < k->interface_count; i++) {
+ ic = k->interfaces [i];
+ if (class->interface_offsets [ic->interface_id] < 0)
+ class->interface_offsets [ic->interface_id] = k->interface_offsets [ic->interface_id];
+ }
+ }
+
+ if (class->parent && class->parent->vtable_size)
+ memcpy (class->vtable, class->parent->vtable, sizeof (gpointer) * class->parent->vtable_size);
+
+
+ for (k = class; k ; k = k->parent) {
+ for (i = 0; i < k->interface_count; i++) {
+ int j, l, io;
+ ic = k->interfaces [i];
+
+ io = class->interface_offsets [ic->interface_id];
+
+ if (k == class) {
+ for (l = 0; l < ic->method.count; l++) {
+ MonoMethod *im = ic->methods [l];
+ for (j = 0; j < class->method.count; ++j) {
+ MonoMethod *cm = class->methods [j];
+ if (!(cm->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
+ !(cm->flags & METHOD_ATTRIBUTE_PUBLIC) ||
+ !(cm->flags & METHOD_ATTRIBUTE_NEW_SLOT))
+ continue;
+ if (!strcmp(cm->name, im->name) &&
+ mono_metadata_signature_equal (cm->signature, im->signature)) {
+ vtable [io + l] = cm;
+ }
+ }
+ }
+ } else {
+ /* already implemented */
+ if (io >= k->vtable_size)
+ continue;
+ }
+
+ for (l = 0; l < ic->method.count; l++) {
+ MonoMethod *im = ic->methods [l];
+ MonoClass *k1;
+
+ if (vtable [io + l])
+ continue;
+
+ for (k1 = class; k1; k1 = k1->parent) {
+ for (j = 0; j < k1->method.count; ++j) {
+ MonoMethod *cm = k1->methods [j];
+
+ if (!(cm->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
+ !(cm->flags & METHOD_ATTRIBUTE_PUBLIC))
+ continue;
+
+ if (!strcmp(cm->name, im->name) &&
+ mono_metadata_signature_equal (cm->signature, im->signature)) {
+ vtable [io + l] = cm;
+ break;
+ }
+
+ }
+ if (vtable [io + l])
+ break;
+ }
+ }
+
+ for (l = 0; l < ic->method.count; l++) {
+ MonoMethod *im = ic->methods [l];
+ char *qname;
+ if (ic->name_space && ic->name_space [0])
+ qname = g_strconcat (ic->name_space, ".", ic->name, ".", im->name, NULL);
+ else
+ qname = g_strconcat (ic->name, ".", im->name, NULL);
+
+ for (j = 0; j < class->method.count; ++j) {
+ MonoMethod *cm = class->methods [j];
+
+ if (!(cm->flags & METHOD_ATTRIBUTE_VIRTUAL))
+ continue;
+
+ if (!strcmp (cm->name, qname) &&
+ mono_metadata_signature_equal (cm->signature, im->signature)) {
+ vtable [io + l] = cm;
+ break;
+ }
+ }
+ g_free (qname);
+ }
+
+
+ if (!(class->flags & TYPE_ATTRIBUTE_ABSTRACT)) {
+ for (l = 0; l < ic->method.count; l++) {
+ MonoMethod *im = ic->methods [l];
+ if (!vtable [io + l]) {
+ printf ("no implementation for interface method %s.%s::%s in class %s.%s\n",
+ ic->name_space, ic->name, im->name, class->name_space, class->name);
+
+ for (j = 0; j < class->method.count; ++j) {
+ MonoMethod *cm = class->methods [j];
+
+ printf ("METHOD %s\n", cm->name);
+ }
+ g_assert_not_reached ();
+ }
+ }
+ }
+
+ for (l = 0; l < ic->method.count; l++) {
+ MonoMethod *im = vtable [io + l];
+ im->slot = io + l;
+ //printf (" ASLOT%d %s.%s:%s\n", io + l, ic->name_space, ic->name, im->name);
+ }
+ }
+ }
+
+ for (i = 0; i < class->method.count; ++i) {
+ MonoMethod *cm;
+
+ cm = class->methods [i];
+
+ if (!(cm->flags & METHOD_ATTRIBUTE_VIRTUAL) ||
+ (cm->slot >= 0))
+ continue;
+
+ if (!(cm->flags & METHOD_ATTRIBUTE_NEW_SLOT)) {
+ for (k = class->parent; k ; k = k->parent) {
+ int j;
+ for (j = 0; j < k->method.count; ++j) {
+ MonoMethod *m1 = k->methods [j];
+ if (!(m1->flags & METHOD_ATTRIBUTE_VIRTUAL))
+ continue;
+ if (!strcmp(cm->name, m1->name) &&
+ mono_metadata_signature_equal (cm->signature, m1->signature)) {
+ cm->slot = k->methods [j]->slot;
+ break;
+ }
+ }
+ if (cm->slot >= 0)
+ break;
+ }
+ }
+
+ if (cm->slot < 0)
+ cm->slot = cur_slot++;
+
+ vtable [cm->slot] = cm;
+ }
+
+ for (i = 0; i < class->vtable_size; ++i) {
+ MonoMethod *cm;
+
+ cm = vtable [i];
+ if (cm)
+ printf (" METH%d %p %s %d\n", i, cm, cm->name, cm->slot);
+
+ }
+
+ class->data = g_malloc0 (class->class_size);
+
+ printf ("METAEND %s.%s\n", class->name_space, class->name);
}
/**
@@ -192,14 +389,51 @@ static MonoClass *
mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
{
MonoTableInfo *tt = &image->tables [MONO_TABLE_TYPEDEF];
- MonoClass *class;
- guint32 cols [MONO_TYPEDEF_SIZE], parent_token;
+ MonoClass *class, *parent = NULL;
+ guint32 cols [MONO_TYPEDEF_SIZE];
+ guint32 cols_next [MONO_TYPEDEF_SIZE];
guint tidx = mono_metadata_token_index (type_token);
const char *name, *nspace;
-
+ guint vtsize = 0, icount = 0;
+ static guint interface_id = 0;
+ MonoClass **interfaces;
+ int i;
+
g_assert (mono_metadata_token_table (type_token) == MONO_TABLE_TYPEDEF);
+
+ mono_metadata_decode_row (tt, tidx - 1, cols, CSIZE (cols));
+
+ if (tt->rows > tidx) {
+ mono_metadata_decode_row (tt, tidx, cols_next, CSIZE (cols_next));
+ vtsize += cols_next [MONO_TYPEDEF_METHOD_LIST] - cols [MONO_TYPEDEF_METHOD_LIST];
+ } else {
+ vtsize += image->tables [MONO_TABLE_METHOD].rows - cols [MONO_TYPEDEF_METHOD_LIST] + 1;
+ }
+
+ name = mono_metadata_string_heap (image, cols[1]);
+ nspace = mono_metadata_string_heap (image, cols[2]);
+
+ if (!(!strcmp (nspace, "System") && !strcmp (name, "Object")) &&
+ !(cols [0] & TYPE_ATTRIBUTE_INTERFACE)) {
+ parent = mono_class_get (image, mono_metadata_token_from_dor (cols [3]));
+ }
+ interfaces = mono_metadata_interfaces_from_typedef (image, type_token, &icount);
+
+ for (i = 0; i < icount; i++)
+ vtsize += interfaces [i]->method.count;
+
+ if (parent)
+ vtsize += parent->vtable_size;
- class = g_malloc0 (sizeof (MonoClass));
+ if (cols [0] & TYPE_ATTRIBUTE_INTERFACE)
+ vtsize = 0;
+
+ class = g_malloc0 (sizeof (MonoClass) + vtsize * sizeof (gpointer));
+
+ class->parent = parent;
+ class->interfaces = interfaces;
+ class->interface_count = icount;
+ class->vtable_size = vtsize;
class->this_arg.byref = 1;
class->this_arg.data.klass = class;
@@ -207,9 +441,8 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
class->byval_arg.data.klass = class;
class->byval_arg.type = MONO_TYPE_CLASS;
- mono_metadata_decode_row (tt, tidx-1, cols, CSIZE (cols));
- class->name = name = mono_metadata_string_heap (image, cols[1]);
- class->name_space = nspace = mono_metadata_string_heap (image, cols[2]);
+ class->name = name;
+ class->name_space = nspace;
class->image = image;
class->type_token = type_token;
@@ -222,8 +455,7 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
class->parent = NULL;
class->instance_size = sizeof (MonoObject);
} else if (!(cols [0] & TYPE_ATTRIBUTE_INTERFACE)) {
- parent_token = mono_metadata_token_from_dor (cols [3]);
- class->parent = mono_class_get (image, parent_token);
+ class->parent = mono_class_get (image, mono_metadata_token_from_dor (cols [3]));
class->valuetype = class->parent->valuetype;
class->enumtype = class->parent->enumtype;
}
@@ -312,9 +544,7 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
class->field.first = cols [MONO_TYPEDEF_FIELD_LIST] - 1;
class->method.first = cols [MONO_TYPEDEF_METHOD_LIST] - 1;
- if (tt->rows > tidx){
- guint32 cols_next [MONO_TYPEDEF_SIZE];
-
+ if (tt->rows > tidx){
mono_metadata_decode_row (tt, tidx, cols_next, CSIZE (cols_next));
class->field.last = cols_next [MONO_TYPEDEF_FIELD_LIST] - 1;
class->method.last = cols_next [MONO_TYPEDEF_METHOD_LIST] - 1;
@@ -340,7 +570,11 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
g_assert (class->field.count == 0);
}
- class->interfaces = mono_metadata_interfaces_from_typedef (image, type_token);
+ if (class->flags & TYPE_ATTRIBUTE_INTERFACE)
+ class->interface_id = interface_id++;
+
+ //class->interfaces = mono_metadata_interfaces_from_typedef (image, type_token, &class->interface_count);
+
return class;
}
@@ -455,7 +689,6 @@ mono_array_class_get (MonoClass *eclass, guint32 rank)
MonoImage *image;
MonoClass *class;
static MonoClass *parent = NULL;
- MonoArrayClass *aclass;
guint32 key;
g_assert (rank <= 255);
@@ -463,6 +696,9 @@ mono_array_class_get (MonoClass *eclass, guint32 rank)
if (!parent)
parent = mono_defaults.array_class;
+ if (!parent->metadata_inited)
+ mono_class_metadata_init (parent);
+
image = eclass->image;
g_assert (!eclass->type_token ||
@@ -472,9 +708,8 @@ mono_array_class_get (MonoClass *eclass, guint32 rank)
if ((class = g_hash_table_lookup (image->array_cache, GUINT_TO_POINTER (key))))
return class;
- aclass = g_new0 (MonoArrayClass, 1);
- class = (MonoClass *)aclass;
-
+ class = g_malloc0 (sizeof (MonoClass) + parent->vtable_size * sizeof (gpointer));
+
class->image = image;
class->name_space = "System";
class->name = "Array";
@@ -483,9 +718,10 @@ mono_array_class_get (MonoClass *eclass, guint32 rank)
class->parent = parent;
class->instance_size = mono_class_instance_size (class->parent);
class->class_size = 0;
+ class->vtable_size = parent->vtable_size;
- aclass->rank = rank;
- aclass->element_class = eclass;
+ class->rank = rank;
+ class->element_class = eclass;
g_hash_table_insert (image->array_cache, GUINT_TO_POINTER (key), class);
return class;
@@ -677,7 +913,7 @@ mono_class_from_name (MonoImage *image, const char* name_space, const char *name
* Returns: the size of single array element.
*/
gint32
-mono_array_element_size (MonoArrayClass *ac)
+mono_array_element_size (MonoClass *ac)
{
gint32 esize;
View
24 mono/metadata/class.h
@@ -25,16 +25,21 @@ struct _MonoClass {
guint enumtype : 1; /* derives from System.Enum */
MonoClass *parent;
- MonoClass **interfaces;
const char *name;
const char *name_space;
+ guint interface_id; /* unique inderface id (for interfaces) */
+ gint *interface_offsets;
+ guint interface_count;
+ MonoClass **interfaces;
+
/*
* Computed object instance size, total.
*/
int instance_size;
int class_size;
+ int vtable_size; /* number of slots */
/*
* From the TypeDef table
@@ -52,21 +57,18 @@ struct _MonoClass {
MonoMethod **methods;
+ /* for arrays */
+ MonoClass *element_class; /* element class */
+ guint32 rank; /* array dimension */
+
/* used as the type of the this argument and when passing the arg by value */
MonoType this_arg;
MonoType byval_arg;
- /*
- * Static class data
- */
gpointer data;
-};
-typedef struct {
- MonoClass klass;
- MonoClass *element_class; /* element class */
- guint32 rank; /* array dimension */
-} MonoArrayClass;
+ gpointer vtable [0];
+};
MonoClass *
mono_class_get (MonoImage *image, guint32 type_token);
@@ -87,7 +89,7 @@ MonoClassField *
mono_class_get_field_from_name (MonoClass *klass, const char *name);
gint32
-mono_array_element_size (MonoArrayClass *ac);
+mono_array_element_size (MonoClass *ac);
gint32
mono_class_instance_size (MonoClass *klass);
View
26 mono/metadata/icall.c
@@ -19,16 +19,16 @@
static MonoObject *
ves_icall_System_Array_GetValue (MonoObject *this, MonoObject *idxs)
{
+ MonoClass *ac, *ic;
MonoArray *ao, *io;
- MonoArrayClass *ac, *ic;
gint32 i, pos, *ind, esize;
gpointer *ea;
io = (MonoArray *)idxs;
- ic = (MonoArrayClass *)io->obj.klass;
+ ic = (MonoClass *)io->obj.klass;
ao = (MonoArray *)this;
- ac = (MonoArrayClass *)ao->obj.klass;
+ ac = (MonoClass *)ao->obj.klass;
g_assert (ic->rank == 1);
g_assert (io->bounds [0].length == ac->rank);
@@ -54,18 +54,18 @@ ves_icall_System_Array_SetValue (MonoObject *this, MonoObject *value,
MonoObject *idxs)
{
MonoArray *ao, *io, *vo;
- MonoArrayClass *ac, *ic, *vc;
+ MonoClass *ac, *ic, *vc;
gint32 i, pos, *ind, esize;
gpointer *ea;
vo = (MonoArray *)value;
- vc = (MonoArrayClass *)vo->obj.klass;
+ vc = (MonoClass *)vo->obj.klass;
io = (MonoArray *)idxs;
- ic = (MonoArrayClass *)io->obj.klass;
+ ic = (MonoClass *)io->obj.klass;
ao = (MonoArray *)this;
- ac = (MonoArrayClass *)ao->obj.klass;
+ ac = (MonoClass *)ao->obj.klass;
g_assert (ic->rank == 1);
g_assert (io->bounds [0].length == ac->rank);
@@ -82,7 +82,7 @@ ves_icall_System_Array_SetValue (MonoObject *this, MonoObject *value,
ea = ao->vector + (pos * esize);
if (ac->element_class->valuetype) {
- g_assert (vc->klass.valuetype);
+ g_assert (vc->valuetype);
memcpy (ea, (char *)vo + sizeof (MonoObject), esize);
} else
@@ -95,13 +95,13 @@ ves_icall_array_ctor (MonoObject *this, gint32 n1, ...)
{
va_list ap;
MonoArray *ao;
- MonoArrayClass *ac;
+ MonoClass *ac;
gint32 i, s, len, esize;
va_start (ap, n1);
ao = (MonoArray *)this;
- ac = (MonoArrayClass *)this->klass;
+ ac = (MonoClass *)this->klass;
g_assert (ac->rank >= 1);
@@ -124,13 +124,13 @@ ves_icall_array_bound_ctor (MonoObject *this, gint32 n1, ...)
{
va_list ap;
MonoArray *ao;
- MonoArrayClass *ac;
+ MonoClass *ac;
gint32 i, s, len, esize;
va_start (ap, n1);
ao = (MonoArray *)this;
- ac = (MonoArrayClass *)this->klass;
+ ac = (MonoClass *)this->klass;
g_assert (ac->rank >= 1);
@@ -163,7 +163,7 @@ ves_icall_System_Array_CreateInstance ()
static gint32
ves_icall_System_Array_GetRank (MonoObject *this)
{
- return ((MonoArrayClass *)this->klass)->rank;
+ return this->klass->rank;
}
static gint32
View
1 mono/metadata/loader.c
@@ -452,6 +452,7 @@ mono_get_method (MonoImage *image, guint32 token, MonoClass *klass)
else
result = (MonoMethod *)g_new0 (MonoMethodNormal, 1);
+ result->slot = -1;
result->klass = klass;
result->flags = cols [2];
result->iflags = cols [1];
View
1 mono/metadata/loader.h
@@ -10,6 +10,7 @@ typedef struct {
MonoClass *klass;
MonoMethodSignature *signature;
gpointer addr;
+ gint slot;
/* name is useful mostly for debugging */
const char *name;
} MonoMethod;
View
9 mono/metadata/metadata.c
@@ -1694,7 +1694,7 @@ mono_metadata_typedef_from_method (MonoMetadata *meta, guint32 index)
}
MonoClass**
-mono_metadata_interfaces_from_typedef (MonoMetadata *meta, guint32 index)
+mono_metadata_interfaces_from_typedef (MonoMetadata *meta, guint32 index, guint *count)
{
MonoTableInfo *tdef = &meta->tables [MONO_TABLE_INTERFACEIMPL];
locator_t loc;
@@ -1702,6 +1702,8 @@ mono_metadata_interfaces_from_typedef (MonoMetadata *meta, guint32 index)
guint32 cols [MONO_INTERFACEIMPL_SIZE];
MonoClass **result;
+ *count = 0;
+
if (!tdef->base)
return NULL;
@@ -1728,12 +1730,11 @@ mono_metadata_interfaces_from_typedef (MonoMetadata *meta, guint32 index)
mono_metadata_decode_row (tdef, start, cols, MONO_INTERFACEIMPL_SIZE);
if (cols [MONO_INTERFACEIMPL_CLASS] != loc.idx)
break;
- result = g_renew (MonoClass*, result, i + 2);
+ result = g_renew (MonoClass*, result, i + 1);
result [i] = mono_class_get (meta, mono_metadata_token_from_dor (cols [MONO_INTERFACEIMPL_INTERFACE]));
- ++i;
+ *count = ++i;
++start;
}
- result [i] = NULL;
return result;
}
View
2 mono/metadata/metadata.h
@@ -112,7 +112,7 @@ const char *mono_metadata_user_string (MonoMetadata *meta, guint32 index);
guint32 mono_metadata_typedef_from_field (MonoMetadata *meta, guint32 index);
guint32 mono_metadata_typedef_from_method (MonoMetadata *meta, guint32 index);
-MonoClass** mono_metadata_interfaces_from_typedef (MonoMetadata *meta, guint32 index);
+MonoClass** mono_metadata_interfaces_from_typedef (MonoMetadata *meta, guint32 index, guint *count);
/*
* Functions to extract information from the Blobs
View
10 mono/metadata/object.c
@@ -117,18 +117,16 @@ mono_object_clone (MonoObject *obj)
MonoObject *
mono_array_new (MonoClass *eclass, guint32 n)
{
- MonoClass *c;
MonoObject *o;
+ MonoClass *ac;
MonoArray *ao;
- MonoArrayClass *ac;
- c = mono_array_class_get (eclass, 1);
- g_assert (c != NULL);
+ ac = mono_array_class_get (eclass, 1);
+ g_assert (ac != NULL);
- o = mono_object_new (c);
+ o = mono_object_new (ac);
ao = (MonoArray *)o;
- ac = (MonoArrayClass *)c;
ao->bounds = g_malloc0 (sizeof (MonoArrayBounds));
ao->bounds [0].length = n;
View
51 mono/tests/iface2.cs
@@ -1,6 +1,8 @@
interface IA
{
int Add(int i);
+
+ int Add2(int i);
}
interface IB
@@ -8,28 +10,57 @@ interface IB
int Add(int i);
}
-interface IC : IA, IB {}
+interface IC
+{
+ int Add(int i);
+}
-class D : IC
+interface ID : IA, IB {}
+
+class D : ID
{
int IA.Add (int i) {
return 5;
}
- int IB.Add (int i) {
+ int IA.Add2 (int i) {
return 6;
}
+
+ int IB.Add (int i) {
+ return 7;
+ }
+}
+
+
+class E : IC, ID
+{
+ int IC.Add (int i) {
+ return 8;
+ }
+
+ int IA.Add (int i) {
+ return 9;
+ }
+
+ int IA.Add2 (int i) {
+ return 10;
+ }
+
+ int IB.Add (int i) {
+ return 11;
+ }
}
-
+
class C
{
- static int Test(IC n) {
+ static int Test(ID n) {
- if (((IA)n).Add(0) != 5)
+ if (((IA)n).Add2(0) != 6)
return 1;
- if (((IB)n).Add(0) != 6)
+ if (((IB)n).Add(0) != 7)
return 1;
@@ -39,8 +70,12 @@ class C
static int Main()
{
D d = new D();
+ E e = new E();
+
+ if (Test (d) != 0)
+ return 1;
- return Test (d);
+ return 0;
}
}
View
11 mono/tests/iface3.cs
@@ -29,15 +29,20 @@ public class Test {
if (r1.DoIt() != 5)
return 1;
+
+ if (((ICommon)r1).DoIt() != 3)
+ return 2;
+
+ //Console.WriteLine ("TEST {0}", ((ICommon)r1).DoIt ());
if (r2.DoIt() != 5)
- return 2;
+ return 3;
if (r3.DoIt() != 2)
- return 3;
+ return 4;
if (r4.DoIt() != 3)
- return 4;
+ return 5;
return 0;
}
View
9 mono/tests/iface4.cs
@@ -19,9 +19,9 @@ public class Derived1 : Base {
public class Derived2 : Base, IVehicle {
// legal - we redeclared IVehicle support
- int IVehicle.Start () { return 5; }
- // legal - we redeclared IVehicle support
public new int Stop () { return 6; }
+ // legal - we redeclared IVehicle support
+ int IVehicle.Start () { return 5; }
// replaces IVehicle.Turn
int IVehicle.Turn () { return 7; }
// replaces Base.Turn
@@ -48,7 +48,10 @@ public class Test {
if (b2.Turn () != 8)
return 4;
- //Console.WriteLine ("TEST {0}", b2.Turn ());
+ if (((IVehicle)b2).Turn () != 7)
+ return 5;
+
+ //Console.WriteLine ("TEST {0}", ((IVehicle)b2).Turn ());
return 0;
}

0 comments on commit b59cb68

Please sign in to comment.
Something went wrong with that request. Please try again.