2001-08-28 Dietmar Maurer <dietmar@ximian.com>
authorDietmar Maurer <dietmar@mono-cvs.ximian.com>
Tue, 28 Aug 2001 10:47:36 +0000 (10:47 -0000)
committerDietmar Maurer <dietmar@mono-cvs.ximian.com>
Tue, 28 Aug 2001 10:47:36 +0000 (10:47 -0000)
* interp.c (ves_exec_method): better check for value types (get
the class to detect if we have a value type), implemented CEE_CONV_U1,
CEE_CONV_U2, CEE_CEQ

* class.c (mono_class_metadata_init): delayed computing of the
class size to mono_class_metadata_init ()

* mono/tests/console.cs: impl.

* mono/tests/box.cs: impl.

* mono/tests/stream-writer.cs: impl.

svn path=/trunk/mono/; revision=655

ChangeLog
mono/interpreter/ChangeLog
mono/interpreter/interp.c
mono/metadata/ChangeLog
mono/metadata/class.c
mono/metadata/object.c
mono/tests/Makefile.am
mono/tests/array.cs
mono/tests/box.cs [new file with mode: 0755]
mono/tests/console.cs [new file with mode: 0755]
mono/tests/stream-writer.cs [new file with mode: 0755]

index aac1badde158088db7eb99f77b26f69b639df33f..be7295c6941f2432d890b676bea65720d52891d4 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2001-08-28  Dietmar Maurer  <dietmar@ximian.com>
+
+       * mono/tests/console.cs: impl.
+
+       * mono/tests/box.cs: impl.
+
+       * mono/tests/stream-writer.cs: impl.
 
 Mon Aug 27 20:24:26 CEST 2001 Paolo Molaro <lupus@ximian.com>
 
index 05d2640a0d55e9f6b23658af79d1aedc2b3fc4d7..e6a5d13b88416e524086c94caec500b495430bfd 100644 (file)
@@ -1,3 +1,9 @@
+2001-08-28  Dietmar Maurer  <dietmar@ximian.com>
+
+       * interp.c (ves_exec_method): better check for value types (get
+       the class to detect if we have a value type), implemented CEE_CONV_U1,
+       CEE_CONV_U2, CEE_CEQ
+       
 
 Mon Aug 27 21:30:30 CEST 2001 Paolo Molaro <lupus@ximian.com>
 
index eb4f6bff2e084360afa59475451c6081149b2f1c..73925ce1cac627476ea528cc2d88b3fdbd9086e5 100644 (file)
@@ -878,17 +878,19 @@ ves_exec_method (MonoInvocation *frame)
                        BREAK;
                CASE (CEE_LDARGA_S) {
                        MonoType *t;
+                       MonoClass *c;
+
                        ++ip;
                        t = ARG_TYPE (signature, *ip);
-                       if (t->type == MONO_TYPE_VALUETYPE) {
+                       c = mono_class_from_mono_type (t);
+                       sp->data.vt.klass = c;
+                       sp->data.vt.vt = ARG_POS (*ip);
+
+                       if (c->valuetype)
                                sp->type = VAL_VALUETA;
-                               sp->data.vt.vt = ARG_POS (*ip);
-                               sp->data.vt.klass = t->data.klass;
-                       } else {
+                       else
                                sp->type = VAL_TP;
-                               sp->data.p = ARG_POS (*ip);
-                               sp->data.vt.klass = mono_class_from_mono_type (t);
-                       }
+
                        ++sp;
                        ++ip;
                        BREAK;
@@ -909,17 +911,19 @@ ves_exec_method (MonoInvocation *frame)
                        BREAK;
                CASE (CEE_LDLOCA_S) {
                        MonoType *t;
+                       MonoClass *c;
+
                        ++ip;
                        t = LOCAL_TYPE (header, *ip);
-                       if (t->type == MONO_TYPE_VALUETYPE) {
+                       c =  mono_class_from_mono_type (t);
+                       sp->data.vt.klass = c;
+                       sp->data.p = LOCAL_POS (*ip);
+
+                       if (c->valuetype)
                                sp->type = VAL_VALUETA;
-                               sp->data.vt.vt = LOCAL_POS (*ip);
-                               sp->data.vt.klass = t->data.klass;
-                       } else {
+                       else 
                                sp->type = VAL_TP;
-                               sp->data.p = LOCAL_POS (*ip);
-                               sp->data.vt.klass = mono_class_from_mono_type (t);
-                       }
+
                        ++sp;
                        ++ip;
                        BREAK;
@@ -1040,7 +1044,6 @@ ves_exec_method (MonoInvocation *frame)
                                child_frame.method = mono_get_method (image, token, NULL);
                        csignature = child_frame.method->signature;
                        g_assert (csignature->call_convention == MONO_CALL_DEFAULT);
-
                        /* decrement by the actual number of args */
                        if (csignature->param_count) {
                                sp -= csignature->param_count;
@@ -1669,6 +1672,7 @@ ves_exec_method (MonoInvocation *frame)
                        else if (sp->type == VAL_NATI)
                                sp->data.p = (gpointer)(~ (int)sp->data.p);
                        BREAK;
+               CASE (CEE_CONV_U1) // fall through
                CASE (CEE_CONV_I1) {
                        ++ip;
                        switch (sp [-1].type) {
@@ -1690,6 +1694,7 @@ ves_exec_method (MonoInvocation *frame)
                        sp [-1].type = VAL_I32;
                        BREAK;
                }
+               CASE (CEE_CONV_U2) // fall through
                CASE (CEE_CONV_I2) {
                        ++ip;
                        switch (sp [-1].type) {
@@ -1816,8 +1821,7 @@ ves_exec_method (MonoInvocation *frame)
                        name = mono_metadata_user_string (image, index);
                        len = mono_metadata_decode_blob_size (name, &name);
 
-                       o = mono_new_utf16_string (name, len);
-
+                       o = mono_new_utf16_string (name, len >> 1);
                        sp->type = VAL_OBJ;
                        sp->data.p = o;
                        sp->data.vt.klass = NULL;
@@ -1970,12 +1974,13 @@ ves_exec_method (MonoInvocation *frame)
                                offset = field->offset - sizeof (MonoObject);
                        }
                        if (load_addr) {
-                               sp->type = VAL_TP;
-                               sp->data.p = (char*)obj + offset;
-                               sp->data.vt.klass = mono_class_from_mono_type (field->type);
+                               sp [-1].type = VAL_TP;
+                               sp [-1].data.p = (char*)obj + offset;
+                               sp [-1].data.vt.klass = mono_class_from_mono_type (field->type);
                        } else {
                                vt_alloc (field->type, &sp [-1]);
                                stackval_from_data (field->type, &sp [-1], (char*)obj + offset);
+                               
                        }
                        BREAK;
                }
@@ -2000,6 +2005,7 @@ ves_exec_method (MonoInvocation *frame)
                                field = mono_class_get_field (sp [0].data.vt.klass, token);
                                offset = field->offset - sizeof (MonoObject);
                        }
+
                        stackval_to_data (field->type, &sp [1], (char*)obj + offset);
                        vt_free (&sp [1]);
                        BREAK;
@@ -2345,8 +2351,6 @@ ves_exec_method (MonoInvocation *frame)
                CASE (CEE_UNUSED66) 
                CASE (CEE_UNUSED67) ves_abort(); BREAK;
                CASE (CEE_LDTOKEN)
-               CASE (CEE_CONV_U2) ves_abort(); BREAK;
-               CASE (CEE_CONV_U1) ves_abort(); BREAK;
                //CASE (CEE_CONV_I) ves_abort(); BREAK;
                CASE (CEE_CONV_OVF_I) ves_abort(); BREAK;
                CASE (CEE_CONV_OVF_U) ves_abort(); BREAK;
@@ -2430,7 +2434,26 @@ ves_exec_method (MonoInvocation *frame)
                        ++ip;
                        switch (*ip) {
                        case CEE_ARGLIST: ves_abort(); break;
-                       case CEE_CEQ: ves_abort(); break;
+                       case CEE_CEQ: {
+                               gint32 result;
+                               ++ip;
+                               sp -= 2;
+
+                               if (sp->type == VAL_I32)
+                                       result = sp [0].data.i == GET_NATI (sp [1]);
+                               else if (sp->type == VAL_I64)
+                                       result = sp [0].data.l == sp [1].data.l;
+                               else if (sp->type == VAL_DOUBLE)
+                                       result = sp [0].data.f == sp [1].data.f;
+                               else
+                                       result = GET_NATI (sp [0]) == GET_NATI (sp [1]);
+                               sp->type = VAL_I32;
+                               sp->data.i = result;
+
+                               sp++;
+                                               
+                               break;
+                       }
                        case CEE_CGT: ves_abort(); break;
                        case CEE_CGT_UN: ves_abort(); break;
                        case CEE_CLT: ves_abort(); break;
@@ -2471,20 +2494,22 @@ ves_exec_method (MonoInvocation *frame)
                        }
                        case CEE_LDLOCA: {
                                MonoType *t;
+                               MonoClass *c;
                                guint32 loc_pos;
+
                                ++ip;
                                loc_pos = read32 (ip);
                                ip += 4;
                                t = LOCAL_TYPE (header, loc_pos);
-                               if (t->type == MONO_TYPE_VALUETYPE) {
+                               c =  mono_class_from_mono_type (t);
+                               sp->data.vt.vt = LOCAL_POS (loc_pos);
+                               sp->data.vt.klass = c;
+
+                               if (c->valuetype) 
                                        sp->type = VAL_VALUETA;
-                                       sp->data.vt.vt = LOCAL_POS (loc_pos);
-                                       sp->data.vt.klass = t->data.klass;
-                               } else {
+                               else
                                        sp->type = VAL_TP;
-                                       sp->data.p = LOCAL_POS (loc_pos);
-                                       sp->data.vt.klass = mono_class_from_mono_type (t);
-                               }
+
                                ++sp;
                                break;
                        }
index b8cdbca389bceca6ae914d6b3470456a44345d19..d9121f015046abc596aa35abea5169888f167b59 100644 (file)
@@ -1,3 +1,7 @@
+2001-08-28  Dietmar Maurer  <dietmar@ximian.com>
+
+       * class.c (mono_class_metadata_init): delayed computing of the
+       class size to mono_class_metadata_init ()
 
 Tue Aug 28 15:47:15 CEST 2001 Paolo Molaro <lupus@ximian.com>
 
index a27b152809b110c60638a27d749e4b95f35d343e..49a7c9e3e2d9068cd335f81ab53d5e2513d70a21 100644 (file)
@@ -156,12 +156,15 @@ mono_class_metadata_init (MonoClass *class)
        if (class->metadata_inited)
                return;
 
-       if (class->parent && !class->parent->metadata_inited)
-                mono_class_metadata_init (class->parent);
+       if (class->parent) {
+               if (!class->parent->metadata_inited)
+                       mono_class_metadata_init (class->parent);
+               class->instance_size = class->parent->instance_size;
+               class->class_size = class->parent->class_size;
+       }
 
        class->metadata_inited = 1;
 
-
        /*
         * Computes the size used by the fields, and their locations
         */
@@ -210,20 +213,17 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
        class->type_token = type_token;
        class->flags = cols [0];
 
-
        /*g_print ("Init class %s\n", name);*/
 
        /* if root of the hierarchy */
        if (!strcmp (nspace, "System") && !strcmp (name, "Object")) {
-               class->instance_size = sizeof (MonoObject);
                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->instance_size = class->parent->instance_size;
                class->valuetype = class->parent->valuetype;
                class->enumtype = class->parent->enumtype;
-               g_assert (class->instance_size);
        }
 
        if (!strcmp (nspace, "System")) {
@@ -269,7 +269,6 @@ mono_class_create_from_typedef (MonoImage *image, guint32 type_token)
        if (!strcmp (nspace, "System") && !strcmp (name, "Array")) {
                class->instance_size += 2 * sizeof (gpointer);
                g_assert (class->field.count == 0);
-               g_assert (class->instance_size == sizeof (MonoArrayObject));
        }
 
        class->interfaces = mono_metadata_interfaces_from_typedef (image, type_token);
index f8f0afba0521f0957c19e59c3490b671e0b8d813..46db336e96b9f76839176402782b9336f2bf166a 100644 (file)
@@ -131,7 +131,7 @@ mono_new_szarray (MonoClass *eclass, guint32 n)
        ao->bounds = g_malloc0 (sizeof (MonoArrayBounds));
        ao->bounds [0].length = n;
        ao->bounds [0].lower_bound = 0;
-       
+
        ao->vector = g_malloc0 (n * mono_array_element_size (ac));
 
        return o;
index 896c06ea622a886bf1d45cf41f38fb0a30af1a05..3c0d7127a673e7b49f98cac961490a6a655104db 100644 (file)
@@ -14,15 +14,18 @@ TESTSRC=                    \
        exception3.cs           \
        exception4.cs           \
        struct.cs               \
-       static-constructor.cs           \
+       static-constructor.cs   \
        pinvoke.cs              \
+       box.cs                  \
        array.cs                \
-       enum.cs         \
+       enum.cs                 \
        property.cs             \
        interface.cs            \
-       virtual-method.cs               \
-       intptrcast.cs   \
-       stream.cs
+       virtual-method.cs       \
+       intptrcast.cs           \
+       stream.cs               \
+       stream-writer.cs        \
+       console.cs
 
 TESTS=$(TESTSRC:.cs=.exe)
 TESTBS=$(BENCHSRC:.cs=.exe)
index 9f587eea3b82b6a9b004f47eaf5051d1eca599f4..502ae749e9b2c5f0bbdc1c71383d0a474f819882 100755 (executable)
@@ -95,23 +95,9 @@ public class Test {
                return 0;
        }
        
-       public static int boxtest ()
-       {
-               int i = 123;
-               object o = i;
-               int j = (int) o;
-
-               if (i != j)
-                       return 1;
-               
-               return 0;
-       }
 
        public static int Main () {
-              
-               if (boxtest () != 0)
-                       return 1;
-              
+                      
                if (atest () != 0)
                        return 1;
                
diff --git a/mono/tests/box.cs b/mono/tests/box.cs
new file mode 100755 (executable)
index 0000000..0050060
--- /dev/null
@@ -0,0 +1,32 @@
+using System;
+using System.IO;
+
+public class Test {
+
+       public static int boxtest ()
+       {
+               int i = 123;
+               object o = i;
+               int j = (int) o;
+
+               if (i != j)
+                       return 1;
+               
+               return 0;
+       }
+
+       public static int Main () {
+               string t = 123.ToString();
+
+               if (t != "123")
+                       return 1;
+
+               if (boxtest () != 0)
+                       return 1;
+
+               
+               return 0;
+       }
+}
+
+
diff --git a/mono/tests/console.cs b/mono/tests/console.cs
new file mode 100755 (executable)
index 0000000..d0546f1
--- /dev/null
@@ -0,0 +1,13 @@
+using System;
+
+public class Test {
+
+       public static int Main () {
+               
+               Console.WriteLine ("We can now write to the console");
+
+               return 0;
+       }
+}
+
+
diff --git a/mono/tests/stream-writer.cs b/mono/tests/stream-writer.cs
new file mode 100755 (executable)
index 0000000..116bf93
--- /dev/null
@@ -0,0 +1,19 @@
+using System;
+using System.IO;
+
+public class Test {
+
+       public static int Main () {
+               FileStream s = new FileStream ((IntPtr)1, FileAccess.Write);
+               StreamWriter sw = new StreamWriter (s);
+               string ts = "This is another test";
+
+               sw.WriteLine (ts);
+
+               sw.WriteLine (123456);
+
+               return 0;
+       }
+}
+
+