floating-point fix for x86_64
[ghc-hetmet.git] / ghc / compiler / basicTypes / Unique.lhs
index dbfc12a..8743288 100644 (file)
@@ -18,7 +18,7 @@ Haskell).
 module Unique (
        Unique, Uniquable(..), hasKey,
 
-       pprUnique,
+       pprUnique, 
 
        mkUnique,                       -- Used in UniqSupply
        mkUniqueGrimily,                -- Used in UniqSupply only!
@@ -50,6 +50,7 @@ module Unique (
 #include "HsVersions.h"
 
 import BasicTypes      ( Boxity(..) )
+import PackageConfig   ( PackageId, packageIdFS )
 import FastString      ( FastString, uniqueOfFS )
 import Outputable
 import FastTypes
@@ -158,6 +159,9 @@ x `hasKey` k        = getUnique x == k
 instance Uniquable FastString where
  getUnique fs = mkUniqueGrimily (I# (uniqueOfFS fs))
 
+instance Uniquable PackageId where
+ getUnique pid = getUnique (packageIdFS pid)
+
 instance Uniquable Int where
  getUnique i = mkUniqueGrimily i
 \end{code}
@@ -202,7 +206,7 @@ We do sometimes make strings with @Uniques@ in them:
 pprUnique :: Unique -> SDoc
 pprUnique uniq
   = case unpkUnique uniq of
-      (tag, u) -> finish_ppr tag u (iToBase62 u)
+      (tag, u) -> finish_ppr tag u (text (iToBase62 u))
 
 #ifdef UNUSED
 pprUnique10 :: Unique -> SDoc
@@ -235,19 +239,18 @@ The ``62-its'' are \tr{[0-9a-zA-Z]}.  We don't handle negative Ints.
 Code stolen from Lennart.
 
 \begin{code}
-iToBase62 :: Int -> SDoc
-
-iToBase62 n@(I# n#)
-  = ASSERT(n >= 0)
-    if n# <# 62# then
-       case (indexCharOffAddr# chars62# n#) of { c ->
-       char (C# c) }
-    else
-       case (quotRem n 62)             of { (q, I# r#) ->
-       case (indexCharOffAddr# chars62# r#) of { c  ->
-       (<>) (iToBase62 q) (char (C# c)) }}
+iToBase62 :: Int -> String
+iToBase62 n@(I# n#) 
+  = ASSERT(n >= 0) go n# ""
   where
-     chars62# = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"#
+    go n# cs | n# <# 62# 
+            = case (indexCharOffAddr# chars62# n#) of { c# -> C# c# : cs }
+            | otherwise
+            =  case (quotRem (I# n#) 62)            of { (I# q#, I# r#) ->
+               case (indexCharOffAddr# chars62# r#) of { c#  ->
+               go q# (C# c# : cs) }}
+
+    chars62# = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"#
 \end{code}
 
 %************************************************************************