Thu Apr 10 16:27:43 CEST 2003 Paolo Molaro <lupus@ximian.com>
authorPaolo Molaro <lupus@oddwiz.org>
Thu, 10 Apr 2003 14:36:43 +0000 (14:36 -0000)
committerPaolo Molaro <lupus@oddwiz.org>
Thu, 10 Apr 2003 14:36:43 +0000 (14:36 -0000)
* inssel.brg, basic.cs: fixed checked conversions to byte and short.

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

mono/mini/ChangeLog
mono/mini/basic.cs
mono/mini/inssel.brg

index a3264e2afcf230dc868711ded28ef4e0c0572e1b..9812301482e660c670a849c27f43b950564e4bb0 100644 (file)
@@ -1,3 +1,8 @@
+
+Thu Apr 10 16:27:43 CEST 2003 Paolo Molaro <lupus@ximian.com>
+
+       * inssel.brg, basic.cs: fixed checked conversions to byte and short.
+
 2003-04-09  Zoltan Varga  <vargaz@freemail.hu>
 
        * mini.c regalloc.c regalloc.h: Fix memory leak.
index 81d4b72c8ab42d3797adf1d9f4dabb239b1dfefb..39a728ce724ee785841476158174b2676f7ecc66 100644 (file)
@@ -619,4 +619,41 @@ class Tests {
                }
                return 2;
        }
+
+       static int test_0_checked_byte_cast () {
+               int v = 250;
+               int b = checked ((byte) (v));
+
+               if (b != 250)
+                       return 1;
+               return 0;
+       }
+
+       static int test_0_checked_byte_cast_un () {
+               uint v = 250;
+               uint b = checked ((byte) (v));
+
+               if (b != 250)
+                       return 1;
+               return 0;
+       }
+
+       static int test_0_checked_short_cast () {
+               int v = 250;
+               int b = checked ((ushort) (v));
+
+               if (b != 250)
+                       return 1;
+               return 0;
+       }
+
+       static int test_0_checked_short_cast_un () {
+               uint v = 250;
+               uint b = checked ((ushort) (v));
+
+               if (b != 250)
+                       return 1;
+               return 0;
+       }
+
 }
index 80cef24ed0d08b982dc95e0c0c5ce19507ffb4ac..2b8f2ef2194d5aa312f88ced7d15828e55330a33 100644 (file)
@@ -615,14 +615,14 @@ reg: CEE_CONV_OVF_U1 (reg) {
        /* probe value to be within 0 to 255 */
        MONO_EMIT_NEW_COMPARE_IMM (s, state->left->reg1, 255);
        MONO_EMIT_NEW_COND_EXC (s, GT_UN, "OverflowException");
-       MONO_EMIT_BIALU_IMM (s, tree, OP_AND_IMM, state->reg1, state->left->reg1, -(0xff + 1));
+       MONO_EMIT_BIALU_IMM (s, tree, OP_AND_IMM, state->reg1, state->left->reg1, 0xff);
 }
 
 reg: CEE_CONV_OVF_U1_UN (reg) {
        /* probe value to be within 0 to 255 */
        MONO_EMIT_NEW_COMPARE_IMM (s, state->left->reg1, 255);
        MONO_EMIT_NEW_COND_EXC (s, GT_UN, "OverflowException");
-       MONO_EMIT_BIALU_IMM (s, tree, OP_AND_IMM, state->reg1, state->left->reg1, -(0xff + 1));
+       MONO_EMIT_BIALU_IMM (s, tree, OP_AND_IMM, state->reg1, state->left->reg1, 0xff);
 }
 
 reg: CEE_CONV_OVF_I2 (reg) {   
@@ -645,14 +645,14 @@ reg: CEE_CONV_OVF_U2 (reg) {
        /* Probe value to be within 0 and 65535 */
        MONO_EMIT_NEW_COMPARE_IMM (s, state->left->reg1, 0xffff);
        MONO_EMIT_NEW_COND_EXC (s, GT_UN, "OverflowException");
-       MONO_EMIT_BIALU_IMM (s, tree, OP_AND_IMM, state->reg1, state->left->reg1, -(0xffff + 1));
+       MONO_EMIT_BIALU_IMM (s, tree, OP_AND_IMM, state->reg1, state->left->reg1, 0xffff);
 }
 
 reg: CEE_CONV_OVF_U2_UN (reg) {
        /* Probe value to be within 0 and 65535 */
        MONO_EMIT_NEW_COMPARE_IMM (s, state->left->reg1, 0xffff);
        MONO_EMIT_NEW_COND_EXC (s, GT_UN, "OverflowException");
-       MONO_EMIT_BIALU_IMM (s, tree, OP_AND_IMM, state->reg1, state->left->reg1, -(0xffff + 1));
+       MONO_EMIT_BIALU_IMM (s, tree, OP_AND_IMM, state->reg1, state->left->reg1, 0xffff);
 }
 
 #