getKey, -- Used in Var only!
incrUnique, -- Used for renumbering
+ deriveUnique, -- Ditto
initTyVarUnique,
initTidyUniques,
recSelErrIdKey,
recUpdErrorIdKey,
returnMClassOpKey,
+ runSTRepIdKey,
showClassKey,
ioTyConKey,
ioDataConKey,
getKey :: Unique -> Int# -- for Var
incrUnique :: Unique -> Unique
+deriveUnique :: Unique -> Int -> Unique
\end{code}
incrUnique (MkUnique i) = MkUnique (i +# 1#)
+-- deriveUnique uses an 'X' tag so that it won't clash with
+-- any of the uniques produced any other way
+deriveUnique (MkUnique i) delta = mkUnique 'X' (I# i + delta)
+
-- pop the Char in the top 8 bits of the Unique(Supply)
-- No 64-bit bugs here, as long as we have at least 32 bits. --JSM
i2w_s x = (x::Int#)
mkUnique (C# c) (I# i)
- = MkUnique (w2i (((i2w (ord# c)) `shiftL#` (i2w_s 24#)) `or#` (i2w i)))
+ = MkUnique (w2i (tag `or#` bits))
+ where
+ tag = i2w (ord# c) `shiftL#` i2w_s 24#
+ bits = i2w i `and#` (i2w 16777215#){-``0x00ffffff''-}
unpkUnique (MkUnique u)
= let
tag = C# (chr# (w2i ((i2w u) `shiftr` (i2w_s 24#))))
- i = I# (w2i ((i2w u) `and#` (i2w 16777215#){-``0x00ffffff''-}))
+ i = I# (w2i ((i2w u) `and#` (i2w 16777215#){-``0x00ffffff''-}))
in
(tag, i)
where
iToBase62 n@(I# n#)
= ASSERT(n >= 0)
let
+#if __GLASGOW_HASKELL__ < 405
bytes = case chars62 of { BYTE_ARRAY bounds_who_needs_'em bytes -> bytes }
+#else
+ bytes = case chars62 of { BYTE_ARRAY _ _ bytes -> bytes }
+#endif
in
if n# <# 62# then
case (indexCharArray# bytes n#) of { c ->
other a-z: lower case chars for unique supplies (see Main.lhs)
B: builtin
C-E: pseudo uniques (used in native-code generator)
+ X: uniques derived by deriveUnique
_: unifiable tyvars (above)
0-9: prelude things below
\begin{code}
assertIdKey = mkPreludeMiscIdUnique 121
+runSTRepIdKey = mkPreludeMiscIdUnique 122
\end{code}