summaryrefslogtreecommitdiff
path: root/compiler/GHC/Utils/Outputable.hs
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/GHC/Utils/Outputable.hs')
-rw-r--r--compiler/GHC/Utils/Outputable.hs26
1 files changed, 16 insertions, 10 deletions
diff --git a/compiler/GHC/Utils/Outputable.hs b/compiler/GHC/Utils/Outputable.hs
index abb3e94615..c0537e4dc0 100644
--- a/compiler/GHC/Utils/Outputable.hs
+++ b/compiler/GHC/Utils/Outputable.hs
@@ -51,7 +51,7 @@ module GHC.Utils.Outputable (
-- * Converting 'SDoc' into strings and outputting it
printSDoc, printSDocLn,
bufLeftRenderSDoc,
- pprCode, mkCodeStyle,
+ pprCode,
showSDocOneLine,
renderWithContext,
@@ -68,7 +68,7 @@ module GHC.Utils.Outputable (
-- * Controlling the style in which output is printed
BindingSite(..),
- PprStyle(..), CodeStyle(..), PrintUnqualified(..),
+ PprStyle(..), LabelStyle(..), PrintUnqualified(..),
QueryQualifyName, QueryQualifyModule, QueryQualifyPackage,
reallyAlwaysQualify, reallyAlwaysQualifyNames,
alwaysQualify, alwaysQualifyNames, alwaysQualifyModules,
@@ -150,11 +150,20 @@ data PprStyle
-- Does not assume tidied code: non-external names
-- are printed with uniques.
- | PprCode CodeStyle
- -- Print code; either C or assembler
+ | PprCode LabelStyle -- ^ Print code; either C or assembler
-data CodeStyle = CStyle -- The format of labels differs for C and assembler
- | AsmStyle
+-- | Style of label pretty-printing.
+--
+-- When we produce C sources or headers, we have to take into account that C
+-- compilers transform C labels when they convert them into symbols. For
+-- example, they can add prefixes (e.g., "_" on Darwin) or suffixes (size for
+-- stdcalls on Windows). So we provide two ways to pretty-print CLabels: C style
+-- or Asm style.
+--
+data LabelStyle
+ = CStyle -- ^ C label style (used by C and LLVM backends)
+ | AsmStyle -- ^ Asm label style (used by NCG backend)
+ deriving (Eq,Ord,Show)
data Depth
= AllTheWay
@@ -556,12 +565,9 @@ bufLeftRenderSDoc :: SDocContext -> BufHandle -> SDoc -> IO ()
bufLeftRenderSDoc ctx bufHandle doc =
Pretty.bufLeftRender bufHandle (runSDoc doc ctx)
-pprCode :: CodeStyle -> SDoc -> SDoc
+pprCode :: LabelStyle -> SDoc -> SDoc
pprCode cs d = withPprStyle (PprCode cs) d
-mkCodeStyle :: CodeStyle -> PprStyle
-mkCodeStyle = PprCode
-
renderWithContext :: SDocContext -> SDoc -> String
renderWithContext ctx sdoc
= let s = Pretty.style{ Pretty.mode = PageMode,