[project @ 2001-10-22 14:47:37 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / DriverPipeline.hs
index 0ba12ac..92f22d0 100644 (file)
@@ -33,7 +33,7 @@ import DriverUtil
 import DriverMkDepend
 import DriverPhases
 import DriverFlags
-import SysTools                ( newTempName, addFilesToClean, getSysMan, unDosifyPath )
+import SysTools                ( newTempName, addFilesToClean, getSysMan )
 import qualified SysTools      
 import HscMain
 import Finder
@@ -135,6 +135,7 @@ genPipeline todo stop_flag persistent_output lang (filename,suffix)
    split      <- readIORef v_Split_object_files
    mangle     <- readIORef v_Do_asm_mangling
    keep_hc    <- readIORef v_Keep_hc_files
+   keep_il    <- readIORef v_Keep_il_files
    keep_raw_s <- readIORef v_Keep_raw_s_files
    keep_s     <- readIORef v_Keep_s_files
    osuf       <- readIORef v_Object_suf
@@ -188,6 +189,9 @@ genPipeline todo stop_flag persistent_output lang (filename,suffix)
 
     stop_phase = case todo of 
                        StopBefore As | split -> SplitAs
+#ifdef ILX
+                                      | real_lang == HscILX -> Ilasm
+#endif
                        StopBefore phase      -> phase
                        DoMkDependHS          -> Ln
                        DoLink                -> Ln
@@ -235,6 +239,9 @@ genPipeline todo stop_flag persistent_output lang (filename,suffix)
                             Mangle | keep_raw_s -> Persistent
                             As     | keep_s     -> Persistent
                             HCc    | keep_hc    -> Persistent
+#ifdef ILX
+                            Ilasm  | keep_il    -> Persistent
+#endif
                             _other              -> Temporary
 
        -- add information about output files to the pipeline
@@ -326,9 +333,7 @@ run_phase :: Phase
 
 run_phase Unlit _basename _suff input_fn output_fn
   = do unlit_flags <- getOpts opt_L
-       -- The -h option passes the file name for unlit to put in a #line directive;
-       -- we undosify it so that it doesn't contain backslashes in Windows, which
-       -- would disappear in error messages
+       -- The -h option passes the file name for unlit to put in a #line directive
        SysTools.runUnlit (map SysTools.Option unlit_flags ++
                                  [ SysTools.Option     "-h"
                          , SysTools.Option     input_fn
@@ -369,7 +374,15 @@ run_phase Cpp basename suff input_fn output_fn
                            ++ map SysTools.Option md_c_flags
                            ++ [ SysTools.Option     "-x"
                               , SysTools.Option     "c"
-                              , SysTools.FileOption "" input_fn
+                              , SysTools.Option     input_fn
+       -- We hackily use Option instead of FileOption here, so that the file
+       -- name is not back-slashed on Windows.  cpp is capable of
+       -- dealing with / in filenames, so it works fine.  Furthermore
+       -- if we put in backslashes, cpp outputs #line directives
+       -- with *double* backslashes.   And that in turn means that
+       -- our error messages get double backslashes in them.
+       -- In due course we should arrange that the lexer deals
+       -- with these \\ escapes properly.
                               , SysTools.Option     "-o"
                               , SysTools.FileOption "" output_fn
                               ])
@@ -1018,6 +1031,7 @@ compile ghci_mode summary source_unchanged have_object
        (basename, _) = splitFilename input_fn
        
    keep_hc <- readIORef v_Keep_hc_files
+   keep_il <- readIORef v_Keep_il_files
    keep_s  <- readIORef v_Keep_s_files
 
    output_fn <- 
@@ -1028,7 +1042,8 @@ compile ghci_mode summary source_unchanged have_object
                   | otherwise -> newTempName (phaseInputExt HCc)
            HscJava             -> newTempName "java" -- ToDo
 #ifdef ILX
-          HscILX              -> return (phaseInputExt Ilx2Il)         
+          HscILX  | keep_il   -> return (basename ++ '.':phaseInputExt Ilasm)
+                   | otherwise -> newTempName (phaseInputExt Ilx2Il)   
 #endif
           HscInterpreted      -> return (error "no output file")
            HscNothing         -> return (error "no output file")