[project @ 2000-11-13 16:16:05 by sewardj]
authorsewardj <unknown>
Mon, 13 Nov 2000 16:16:05 +0000 (16:16 +0000)
committersewardj <unknown>
Mon, 13 Nov 2000 16:16:05 +0000 (16:16 +0000)
Implement -ddump-hi.

ghc/compiler/main/CmdLineOpts.lhs
ghc/compiler/main/DriverFlags.hs
ghc/compiler/main/HscMain.lhs

index a1012cd..c2e3614 100644 (file)
@@ -247,6 +247,7 @@ data DynFlag
    | Opt_D_source_stats
    | Opt_D_verbose_core2core
    | Opt_D_verbose_stg2stg
+   | Opt_D_dump_hi
    | Opt_D_dump_hi_diffs
    | Opt_D_dump_minimal_imports
    | Opt_DoCoreLinting
index 75462ca..50e516c 100644 (file)
@@ -1,5 +1,5 @@
 -----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.17 2000/11/10 14:29:21 simonmar Exp $
+-- $Id: DriverFlags.hs,v 1.18 2000/11/13 16:16:05 sewardj Exp $
 --
 -- Driver flags
 --
@@ -18,7 +18,6 @@ import TmpFiles       ( v_TmpDir )
 import CmdLineOpts
 import Config
 import Util
-import CmdLineOpts
 
 import Exception
 import IOExts
@@ -360,6 +359,7 @@ dynamic_flags = [
   ,  ( "dverbose-core2core",     NoArg (setDynFlag Opt_D_verbose_core2core) )
   ,  ( "dverbose-stg2stg",       NoArg (setDynFlag Opt_D_verbose_stg2stg) )
   ,  ( "ddump-hi-diffs",         NoArg (setDynFlag Opt_D_dump_hi_diffs) )
+  ,  ( "ddump-hi",               NoArg (setDynFlag Opt_D_dump_hi) )
   ,  ( "ddump-minimal-imports",  NoArg (setDynFlag Opt_D_dump_minimal_imports) )
   ,  ( "dcore-lint",            NoArg (setDynFlag Opt_DoCoreLinting) )
   ,  ( "dstg-lint",             NoArg (setDynFlag Opt_DoStgLinting) )
index b2ba003..eb10440 100644 (file)
@@ -23,7 +23,7 @@ import Rules          ( emptyRuleBase )
 import PrelInfo                ( wiredInThingEnv, wiredInThings )
 import PrelNames       ( knownKeyNames )
 import MkIface         ( completeIface, mkModDetailsFromIface, mkModDetails,
-                         writeIface )
+                         writeIface, pprIface )
 import TcModule                ( TcResults(..), typecheckModule )
 import InstEnv         ( emptyInstEnv )
 import Desugar         ( deSugar )
@@ -58,6 +58,7 @@ import Name           ( Name, nameModule, nameOccName, getName  )
 import Name            ( emptyNameEnv )
 import Module          ( Module, lookupModuleEnvByName )
 
+import Monad           ( when )
 \end{code}
 
 
@@ -182,7 +183,7 @@ hscRecomp dflags location maybe_checked_iface hst hit pcs_ch
        ; maybe_tc_result <- typecheckModule dflags this_mod pcs_rn hst new_iface 
                                             print_unqualified rn_hs_decls
        ; case maybe_tc_result of {
-            Nothing -> do { hPutStrLn stderr "Typechecked failed" 
+            Nothing -> do { hPutStrLn stderr "Typecheck failed" 
                           ; return (HscFail pcs_rn) } ;
             Just tc_result -> do {
     
@@ -233,12 +234,14 @@ hscRecomp dflags location maybe_checked_iface hst hit pcs_ch
 mkFinalIface dflags location maybe_old_iface new_iface new_details
  = case completeIface maybe_old_iface new_iface new_details of
       (new_iface, Nothing) -- no change in the interfacfe
-         -> do if dopt Opt_D_dump_hi_diffs dflags  then
-                       printDump (text "INTERFACE UNCHANGED")
-                 else  return ()
+         -> do when (dopt Opt_D_dump_hi_diffs dflags)
+                    (printDump (text "INTERFACE UNCHANGED"))
+               dumpIfSet_dyn dflags Opt_D_dump_hi
+                             "UNCHANGED FINAL INTERFACE" (pprIface new_iface)
               return new_iface
-      (new_iface, Just sdoc)
-         -> do dumpIfSet_dyn dflags Opt_D_dump_hi_diffs "NEW INTERFACE" sdoc
+      (new_iface, Just sdoc_diffs)
+         -> do dumpIfSet_dyn dflags Opt_D_dump_hi_diffs "INTERFACE HAS CHANGED" sdoc_diffs
+               dumpIfSet_dyn dflags Opt_D_dump_hi "NEW FINAL INTERFACE" (pprIface new_iface)
                -- Write the interface file
                writeIface (unJust (ml_hi_file location) "hscRecomp:hi") new_iface
                return new_iface