X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FbasicTypes%2FUnique.lhs;h=aecd37219790545cce74339e7945f9d7f745c40e;hb=2476249a77bde34ea2052910f111a3424c366db6;hp=7a38d4ef1a127f1e724a271adf243486f6520748;hpb=4b484275d83c4956df2ff1a471313ccf14d03cb3;p=ghc-hetmet.git diff --git a/compiler/basicTypes/Unique.lhs b/compiler/basicTypes/Unique.lhs index 7a38d4e..aecd372 100644 --- a/compiler/basicTypes/Unique.lhs +++ b/compiler/basicTypes/Unique.lhs @@ -17,7 +17,11 @@ Haskell). \begin{code} module Unique ( - Unique, Uniquable(..), hasKey, + -- * Main data types + Unique, Uniquable(..), + + -- ** Constructors, desctructors and operations on 'Unique's + hasKey, pprUnique, @@ -32,6 +36,8 @@ module Unique ( isTupleKey, + -- ** Making built-in uniques + -- now all the built-in Uniques (and functions to make them) -- [the Oh-So-Wonderful Haskell module system wins again...] mkAlphaTyVarUnique, @@ -55,7 +61,6 @@ import FastTypes import FastString import Outputable import StaticFlags -import Util #if defined(__GLASGOW_HASKELL__) --just for implementing a fast [0,61) -> Char function @@ -77,6 +82,10 @@ Fast comparison is everything on @Uniques@: \begin{code} --why not newtype Int? + +-- | The type of unique identifiers that are used in many places in GHC +-- for fast ordering and equality tests. You should generate these with +-- the functions from the 'UniqSupply' module data Unique = MkUnique FastInt \end{code} @@ -125,8 +134,8 @@ newTagUnique u c = mkUnique c i where (_,i) = unpkUnique u mkUnique c i = MkUnique (tag `bitOrFastInt` bits) where - tag = fastOrd (cUnbox c) `shiftLFastInt` _ILIT(24) - bits = iUnbox i `bitAndFastInt` _ILIT(16777215){-``0x00ffffff''-} + !tag = fastOrd (cUnbox c) `shiftLFastInt` _ILIT(24) + !bits = iUnbox i `bitAndFastInt` _ILIT(16777215){-``0x00ffffff''-} unpkUnique (MkUnique u) = let @@ -147,6 +156,7 @@ unpkUnique (MkUnique u) %************************************************************************ \begin{code} +-- | Class of things that we can obtain a 'Unique' from class Uniquable a where getUnique :: a -> Unique @@ -201,7 +211,7 @@ We do sometimes make strings with @Uniques@ in them: \begin{code} pprUnique :: Unique -> SDoc pprUnique uniq - | debugIsOn && opt_SuppressUniques + | opt_SuppressUniques = empty -- Used exclusively to suppress uniques so you | otherwise -- can compare output easily = case unpkUnique uniq of @@ -256,7 +266,7 @@ iToBase62 n_ #if defined(__GLASGOW_HASKELL__) --then FastInt == Int# chooseChar62 n = C# (indexCharOffAddr# chars62 n) - chars62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"# + !chars62 = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"# #else --Haskell98 arrays are portable chooseChar62 n = (!) chars62 n @@ -277,6 +287,8 @@ Allocation of unique supply characters: X: uniques derived by deriveUnique _: unifiable tyvars (above) 0-9: prelude things below + (no numbers left any more..) + :: (prelude) parallel array data constructors other a-z: lower case chars for unique supplies. Used so far: @@ -325,8 +337,8 @@ mkTupleDataConUnique Unboxed a = mkUnique '8' (2*a) isTupleKey u = case unpkUnique u of (tag,_) -> tag == '4' || tag == '5' || tag == '7' || tag == '8' -mkPrimOpIdUnique op = mkUnique '9' op -mkPreludeMiscIdUnique i = mkUnique '0' i +mkPrimOpIdUnique op = mkUnique '9' op +mkPreludeMiscIdUnique i = mkUnique '0' i -- No numbers left anymore, so I pick something different for the character -- tag