| codeStyle sty = pprUnique uniq
| debugStyle sty = ppr_occ_name occ <> braces (hsep [text (briefOccNameFlavour occ),
pprUnique uniq])
+ | dumpStyle sty = ppr_occ_name occ <> char '_' <> pprUnique uniq
+ -- For debug dumps, we're not necessarily dumping
+ -- tidied code, so we need to print the uniques.
| otherwise = ppr_occ_name occ -- User style
-- Like Internal, except that we only omit the unique in Iface style
PprStyle, CodeStyle(..), PrintUnqualified, alwaysQualify,
getPprStyle, withPprStyle, withPprStyleDoc, pprDeeper,
- codeStyle, userStyle, debugStyle, asmStyle,
+ codeStyle, userStyle, debugStyle, dumpStyle, asmStyle,
ifPprDebug, unqualStyle,
mkErrStyle, defaultErrStyle,
\begin{code}
data PprStyle
- = PprUser PrintUnqualified Depth -- Pretty-print in a way that will
- -- make sense to the ordinary user;
- -- must be very close to Haskell
- -- syntax, etc.
+ = PprUser PrintUnqualified Depth
+ -- Pretty-print in a way that will make sense to the
+ -- ordinary user; must be very close to Haskell
+ -- syntax, etc.
+ -- Assumes printing tidied code: non-system names are
+ -- printed without uniques.
- | PprCode CodeStyle -- Print code; either C or assembler
+ | PprCode CodeStyle
+ -- Print code; either C or assembler
- | PprDebug -- Standard debugging output
+ | PprDump -- For -ddump-foo; less verbose than PprDebug.
+ -- Does not assume tidied code: non-external names
+ -- are printed with uniques.
+
+ | PprDebug -- Full debugging output
data CodeStyle = CStyle -- The format of labels differs for C and assembler
| AsmStyle
defaultUserStyle = mkUserStyle alwaysQualify AllTheWay
+defaultDumpStyle | opt_PprStyle_Debug = PprDebug
+ | otherwise = PprDump
+
mkErrStyle :: PrintUnqualified -> PprStyle
-- Style for printing error messages
mkErrStyle print_unqual = mkUserStyle print_unqual (PartWay opt_PprUserLength)
asmStyle (PprCode AsmStyle) = True
asmStyle other = False
+dumpStyle :: PprStyle -> Bool
+dumpStyle PprDump = True
+dumpStyle other = False
+
debugStyle :: PprStyle -> Bool
debugStyle PprDebug = True
debugStyle other = False
printDump :: SDoc -> IO ()
printDump doc = do
- Pretty.printDoc PageMode stdout (better_doc defaultUserStyle)
+ Pretty.printDoc PageMode stdout (better_doc defaultDumpStyle)
hFlush stdout
where
better_doc = doc $$ text ""