+ -- Dunno if the above comment is still meaningful now. JRS 001024.
+
+ do { showPass dflags "CodeOutput"
+ ; let filenm = dopt_OutName dflags
+ ; stub_names <- outputForeignStubs dflags c_code h_code
+ ; case dopt_HscLang dflags of
+ HscInterpreted -> return stub_names
+ HscAsm -> outputAsm dflags filenm flat_abstractC
+ >> return stub_names
+ HscC -> outputC dflags filenm flat_abstractC stub_names
+ >> return stub_names
+ HscJava ->
+#ifdef JAVA
+ outputJava dflags filenm mod_name tycons core_binds
+ >> return stub_names
+#else
+ panic "Java support not compiled into this ghc"
+#endif
+ HscILX ->
+#ifdef ILX
+ outputIlx dflags filenm mod_name tycons stg_binds
+ >> return stub_names
+#else
+ panic "ILX support not compiled into this ghc"
+#endif
+ }
+
+doOutput :: String -> (Handle -> IO ()) -> IO ()
+doOutput filenm io_action = bracket (openFile filenm WriteMode) hClose io_action
+\end{code}
+
+
+%************************************************************************
+%* *
+\subsection{C}
+%* *
+%************************************************************************
+
+\begin{code}
+outputC dflags filenm flat_absC (stub_h_exists, _)
+ = do dumpIfSet_dyn dflags Opt_D_dump_realC "Real C" (dumpRealC flat_absC)
+ header <- readIORef v_HCHeader
+ doOutput filenm $ \ h -> do
+ hPutStr h header
+ when stub_h_exists $
+ hPutStrLn h ("#include \"" ++ (hscStubHOutName dflags) ++ "\"")
+ writeRealC h flat_absC
+\end{code}
+
+
+%************************************************************************
+%* *
+\subsection{Assembler}
+%* *
+%************************************************************************
+
+\begin{code}
+outputAsm dflags filenm flat_absC
+
+#ifndef OMIT_NATIVE_CODEGEN