X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Fmain%2FCodeOutput.lhs;h=3ff665e422956ec48602f5842a62284d50bc3435;hb=50027272414438955dbc41696541cbd25da55883;hp=33357fcbc2ddd16fb491601c034c8003d289d8c6;hpb=788faebb40b51d37e73ed94dfc99460d39a1a811;p=ghc-hetmet.git diff --git a/ghc/compiler/main/CodeOutput.lhs b/ghc/compiler/main/CodeOutput.lhs index 33357fc..3ff665e 100644 --- a/ghc/compiler/main/CodeOutput.lhs +++ b/ghc/compiler/main/CodeOutput.lhs @@ -20,6 +20,7 @@ import IlxGen ( ilxGen ) import JavaGen ( javaGen ) import qualified PrintJava +import DriverState ( v_HCHeader ) import TyCon ( TyCon ) import Id ( Id ) import CoreSyn ( CoreBind ) @@ -34,8 +35,8 @@ import Outputable import CmdLineOpts ( DynFlags, HscLang(..), dopt_OutName ) import TmpFiles ( newTempName ) -import IO ( IOMode(..), hClose, openFile, Handle ) -import IO ( hPutStr, stderr) -- Debugging +import IOExts +import IO \end{code} @@ -82,8 +83,7 @@ codeOutput dflags mod_name tycons core_binds stg_binds doOutput :: String -> (Handle -> IO ()) -> IO () doOutput filenm io_action - = (do hPutStr stderr ("Writing to" ++ filenm) - handle <- openFile filenm WriteMode + = (do handle <- openFile filenm WriteMode io_action handle hClose handle) `catch` (\err -> pprPanic "Failed to open or write code output file" @@ -100,7 +100,10 @@ doOutput filenm io_action \begin{code} outputC dflags filenm flat_absC = do dumpIfSet_dyn dflags Opt_D_dump_realC "Real C" (dumpRealC flat_absC) - doOutput filenm (\ h -> writeRealC h flat_absC) + header <- readIORef v_HCHeader + doOutput filenm $ \ h -> do + hPutStr h header + writeRealC h flat_absC \end{code}