diff options
author | Greg Weber <greg@gregweber.info> | 2015-01-12 05:16:37 -0600 |
---|---|---|
committer | Austin Seipp <austin@well-typed.com> | 2015-01-13 10:10:38 -0600 |
commit | 07ace5c221adbb1675413a0fac300a9f7913c234 (patch) | |
tree | d00e7a658680ce0e2488f40ccbb4297708af1820 /compiler/main | |
parent | 0fa4240249058f327cfd283f9da2deb8dff664f1 (diff) | |
download | haskell-07ace5c221adbb1675413a0fac300a9f7913c234.tar.gz |
add -th-file which generates a th.hs file
Summary:
see Trac #8624
similar functionality is now available
with -ddump-to-file -ddump-splices
However, users are already accustomed to -ddump-splices
having a particular format, and this format is not completely valid code
The goal of -th-file is to dump valid Haskell code
Additionally, the convention of -ddump-to-file is to name the file after
the flag, so the file is .dump-splices
Given that the goal of the new flag is to generate valid Haskell,
The extension should be .hs
Additionally, -ddump-to-file effects all other dump flags
Test Plan:
look at the output of using the -th-file flag
and compare it to the output of using -ddump-to-file and -ddump-splices
I want to add test cases, but just need some pointers on getting started there
Reviewers: thomie, goldfire, simonpj, austin
Reviewed By: simonpj, austin
Subscribers: thomie, carter
Differential Revision: https://phabricator.haskell.org/D518
GHC Trac Issues: #8624
Diffstat (limited to 'compiler/main')
-rw-r--r-- | compiler/main/DynFlags.hs | 4 | ||||
-rw-r--r-- | compiler/main/ErrUtils.hs | 3 |
2 files changed, 6 insertions, 1 deletions
diff --git a/compiler/main/DynFlags.hs b/compiler/main/DynFlags.hs index c18b868d33..8dfd5321b8 100644 --- a/compiler/main/DynFlags.hs +++ b/compiler/main/DynFlags.hs @@ -287,6 +287,7 @@ data DumpFlag | Opt_D_dump_if_trace | Opt_D_dump_vt_trace | Opt_D_dump_splices + | Opt_D_th_dec_file | Opt_D_dump_BCOs | Opt_D_dump_vect | Opt_D_dump_ticked @@ -1685,6 +1686,7 @@ dopt f dflags = (fromEnum f `IntSet.member` dumpFlags dflags) enableIfVerbose Opt_D_verbose_core2core = False enableIfVerbose Opt_D_verbose_stg2stg = False enableIfVerbose Opt_D_dump_splices = False + enableIfVerbose Opt_D_th_dec_file = False enableIfVerbose Opt_D_dump_rule_firings = False enableIfVerbose Opt_D_dump_rule_rewrites = False enableIfVerbose Opt_D_dump_simpl_trace = False @@ -2477,6 +2479,8 @@ dynamic_flags = [ setDumpFlag' Opt_D_dump_cs_trace)) , defGhcFlag "ddump-vt-trace" (setDumpFlag Opt_D_dump_vt_trace) , defGhcFlag "ddump-splices" (setDumpFlag Opt_D_dump_splices) + , defGhcFlag "dth-dec-file" (setDumpFlag Opt_D_th_dec_file) + , defGhcFlag "ddump-rn-stats" (setDumpFlag Opt_D_dump_rn_stats) , defGhcFlag "ddump-opt-cmm" (setDumpFlag Opt_D_dump_opt_cmm) , defGhcFlag "ddump-simpl-stats" (setDumpFlag Opt_D_dump_simpl_stats) diff --git a/compiler/main/ErrUtils.hs b/compiler/main/ErrUtils.hs index 20d628f312..82587d28bc 100644 --- a/compiler/main/ErrUtils.hs +++ b/compiler/main/ErrUtils.hs @@ -301,7 +301,7 @@ dumpSDoc dflags print_unqual flag hdr doc chooseDumpFile :: DynFlags -> DumpFlag -> Maybe String chooseDumpFile dflags flag - | gopt Opt_DumpToFile dflags + | gopt Opt_DumpToFile dflags || flag == Opt_D_th_dec_file , Just prefix <- getPrefix = Just $ setDir (prefix ++ (beautifyDumpName flag)) @@ -325,6 +325,7 @@ chooseDumpFile dflags flag -- | Build a nice file name from name of a GeneralFlag constructor beautifyDumpName :: DumpFlag -> String +beautifyDumpName Opt_D_th_dec_file = "th.hs" beautifyDumpName flag = let str = show flag suff = case stripPrefix "Opt_D_" str of |