[svn] r6116: nemerle/trunk/ncc: generation/ILEmitter.n testsuite/positive/implicit-conversion.n

nazgul svnadmin at nemerle.org
Sun Feb 12 13:42:54 CET 2006


Log:
Fix unsigned -> double IL conversions

Author: nazgul
Date: Sun Feb 12 13:42:49 2006
New Revision: 6116

Modified:
   nemerle/trunk/ncc/generation/ILEmitter.n
   nemerle/trunk/ncc/testsuite/positive/implicit-conversion.n

Modified: nemerle/trunk/ncc/generation/ILEmitter.n
==============================================================================
--- nemerle/trunk/ncc/generation/ILEmitter.n	(original)
+++ nemerle/trunk/ncc/generation/ILEmitter.n	Sun Feb 12 13:42:49 2006
@@ -1599,8 +1599,8 @@
     {
      def l = l_t.SystemType;
 
-     def is_unsigned (t : System.Type) {
-        match (t.Name [0]) {
+      def is_unsigned_l = 
+        match (l.Name [0]) {
           // UInt32, UInt64, UInt16
           | 'U'
           // Byte
@@ -1609,7 +1609,6 @@
           | 'C'   => true
           | _ => false
         }
-      };
       def fail () {
         Message.Warning (loc, 
                          $ "failed to emit value type conversion from $l_t to $r_t")
@@ -1625,34 +1624,35 @@
               // FIXME: use true underalying type
               if (r.IsEnum) "Int32" else r.Name; 
             def opcode =
+              match (rname) {
+                | "Single" when is_unsigned_l => OpCodes.Conv_R_Un
+                | "Single" => OpCodes.Conv_R4
+                | "Double" when is_unsigned_l => _ilg.Emit (OpCodes.Conv_R_Un); OpCodes.Conv_R8                
+                | "Double" => OpCodes.Conv_R8
+                | _ =>
               if (is_checked) {
                 match (rname) {
-                  | "Int64" when is_unsigned (l) => OpCodes.Conv_Ovf_I8_Un
+                      | "Int64" when is_unsigned_l => OpCodes.Conv_Ovf_I8_Un
                   | "Int64" => OpCodes.Conv_Ovf_I8
-                  | "Int32" when is_unsigned (l) => OpCodes.Conv_Ovf_I4_Un
+                      | "Int32" when is_unsigned_l => OpCodes.Conv_Ovf_I4_Un
                   | "Int32" => OpCodes.Conv_Ovf_I4
-                  | "Int16" when is_unsigned (l) => OpCodes.Conv_Ovf_I2_Un
+                      | "Int16" when is_unsigned_l => OpCodes.Conv_Ovf_I2_Un
                   | "Int16" => OpCodes.Conv_Ovf_I2
-                  | "SByte" when is_unsigned (l) => OpCodes.Conv_Ovf_I1_Un
+                      | "SByte" when is_unsigned_l => OpCodes.Conv_Ovf_I1_Un
                   | "SByte" => OpCodes.Conv_Ovf_I1
-                  | "UInt64" when is_unsigned (l) => OpCodes.Conv_Ovf_U8_Un
+                      | "UInt64" when is_unsigned_l => OpCodes.Conv_Ovf_U8_Un
                   | "UInt64" => OpCodes.Conv_Ovf_U8
-                  | "UInt32" when is_unsigned (l) => OpCodes.Conv_Ovf_U4_Un
+                      | "UInt32" when is_unsigned_l => OpCodes.Conv_Ovf_U4_Un
                   | "UInt32" => OpCodes.Conv_Ovf_U4
-                  | "UInt16" when is_unsigned (l) => OpCodes.Conv_Ovf_U2_Un
+                      | "UInt16" when is_unsigned_l => OpCodes.Conv_Ovf_U2_Un
                   | "UInt16" => OpCodes.Conv_Ovf_U2
-                  | "Boolean" when is_unsigned (l) => OpCodes.Conv_Ovf_U1_Un
+                      | "Boolean" when is_unsigned_l => OpCodes.Conv_Ovf_U1_Un
                   | "Boolean" => OpCodes.Conv_Ovf_U1
-                  | "Byte" when is_unsigned (l) => OpCodes.Conv_Ovf_U1_Un
+                      | "Byte" when is_unsigned_l => OpCodes.Conv_Ovf_U1_Un
                   | "Byte" => OpCodes.Conv_Ovf_U1
-                  | "Char" when is_unsigned (l) => OpCodes.Conv_Ovf_U2_Un
+                      | "Char" when is_unsigned_l => OpCodes.Conv_Ovf_U2_Un
                   | "Char" => OpCodes.Conv_Ovf_U2
 
-                  | "Single" when is_unsigned (l) => OpCodes.Conv_R_Un
-                  | "Single" => OpCodes.Conv_R4
-                  // there is no OpCodes.Conv_R8_Un
-                  | "Double" when !is_unsigned (l) => OpCodes.Conv_R8
-
                   | _ => fail (); OpCodes.Nop
                 }
               }
@@ -1669,13 +1669,10 @@
                   | "Boolean" => OpCodes.Conv_U1
                   | "Char" => OpCodes.Conv_U2
 
-                  | "Single" when is_unsigned (l) => OpCodes.Conv_R_Un
-                  | "Single" => OpCodes.Conv_R4
-                  | "Double" => OpCodes.Conv_R8
-
                   | _ => fail (); OpCodes.Nop
                 }
               }
+              }
             _ilg.Emit (opcode)
           }
           else if (r : object == SystemType.Decimal) {

Modified: nemerle/trunk/ncc/testsuite/positive/implicit-conversion.n
==============================================================================
--- nemerle/trunk/ncc/testsuite/positive/implicit-conversion.n	(original)
+++ nemerle/trunk/ncc/testsuite/positive/implicit-conversion.n	Sun Feb 12 13:42:49 2006
@@ -74,6 +74,21 @@
     });
     
     SharpConsole.Class1.Go ();
+    
+    Bug612.Run ();
+  }
+}
+
+module Bug612 {
+    f(x : double) : void
+    {
+        System.Console.WriteLine("{0}", x);
+    }
+
+    public Run() : void
+    {
+        f(2 : uint);
+        unchecked (f(2 : uint));
   }
 }
 
@@ -226,5 +241,7 @@
 
 
 Hello, from a new thread
+2
+2
 END-OUTPUT
 */



More information about the svn mailing list