import SrcLoc ( noSrcLoc, wiredInSrcLoc, SrcLoc )
import Unique ( Unique, Uniquable(..), getKey, pprUnique )
import Maybes ( orElse, isJust )
import SrcLoc ( noSrcLoc, wiredInSrcLoc, SrcLoc )
import Unique ( Unique, Uniquable(..), getKey, pprUnique )
import Maybes ( orElse, isJust )
isImplicitName :: Name -> Bool
-- An Implicit Name is one has a parent; that is, one whose definition
isImplicitName :: Name -> Bool
-- An Implicit Name is one has a parent; that is, one whose definition
isImplicitName name = isJust (nameParent_maybe name)
nameModule name = nameModule_maybe name `orElse` pprPanic "nameModule" (ppr name)
isImplicitName name = isJust (nameParent_maybe name)
nameModule name = nameModule_maybe name `orElse` pprPanic "nameModule" (ppr name)
mkSystemName uniq occ = Name { n_uniq = uniq, n_sort = System,
n_occ = occ, n_loc = noSrcLoc }
mkSystemName uniq occ = Name { n_uniq = uniq, n_sort = System,
n_occ = occ, n_loc = noSrcLoc }
-mkSystemVarName :: Unique -> UserFS -> Name
-mkSystemVarName uniq fs = mkSystemName uniq (mkVarOcc fs)
+mkSystemVarName :: Unique -> FastString -> Name
+mkSystemVarName uniq fs = mkSystemName uniq (mkVarOccFS fs)
--- Use this version when the string is already encoded. Avoids duplicating
--- the string each time a new name is created.
-mkSystemVarNameEncoded :: Unique -> EncodedFS -> Name
-mkSystemVarNameEncoded uniq fs = mkSystemName uniq (mkSysOccFS varName fs)
+mkSysTvName :: Unique -> FastString -> Name
+mkSysTvName uniq fs = mkSystemName uniq (mkOccNameFS tvName fs)
-- The encoded string completely describes the ccall
mkFCallName uniq str = Name { n_uniq = uniq, n_sort = Internal,
-- The encoded string completely describes the ccall
mkFCallName uniq str = Name { n_uniq = uniq, n_sort = Internal,
-- In code style, always qualify
-- ToDo: maybe we could print all wired-in things unqualified
-- in code style, to reduce symbol table bloat?
| debugStyle sty = ppr mod <> dot <> ppr_occ_name occ
<> braces (hsep [if is_wired then ptext SLIT("(w)") else empty,
-- In code style, always qualify
-- ToDo: maybe we could print all wired-in things unqualified
-- in code style, to reduce symbol table bloat?
| debugStyle sty = ppr mod <> dot <> ppr_occ_name occ
<> braces (hsep [if is_wired then ptext SLIT("(w)") else empty,
pprUnique uniq])
| dumpStyle sty = ppr_occ_name occ <> char '_' <> pprUnique uniq
-- For debug dumps, we're not necessarily dumping
pprUnique uniq])
| dumpStyle sty = ppr_occ_name occ <> char '_' <> pprUnique uniq
-- For debug dumps, we're not necessarily dumping
| otherwise = ppr_occ_name occ <> char '_' <> pprUnique uniq
-- If the tidy phase hasn't run, the OccName
-- is unlikely to be informative (like 's'),
-- so print the unique
| otherwise = ppr_occ_name occ <> char '_' <> pprUnique uniq
-- If the tidy phase hasn't run, the OccName
-- is unlikely to be informative (like 's'),
-- so print the unique
-- Don't use pprOccName; instead, just print the string of the OccName;
-- we print the namespace in the debug stuff above
-- Don't use pprOccName; instead, just print the string of the OccName;
-- we print the namespace in the debug stuff above
+
+-- In code style, we Z-encode the strings. The results of Z-encoding each FastString are
+-- cached behind the scenes in the FastString implementation.
+ppr_z_occ_name occ = ftext (zEncodeFS (occNameFS occ))
+ppr_z_module mod = ftext (zEncodeFS (moduleFS mod))
+