diff options
author | Ian Lynagh <ian@well-typed.com> | 2013-03-02 19:16:38 +0000 |
---|---|---|
committer | Ian Lynagh <ian@well-typed.com> | 2013-03-02 19:16:38 +0000 |
commit | 9579fd5d69a031cf8726aa8d5ce8b031dcbaca6f (patch) | |
tree | 425d0ec5351853015359c09fe35687ecdac7bd24 | |
parent | 253b0f2e0464b6c6bd0292319daa976148d43a80 (diff) | |
download | haskell-9579fd5d69a031cf8726aa8d5ce8b031dcbaca6f.tar.gz |
Simplify the definition of getOutputFilename
-rw-r--r-- | compiler/main/DriverPipeline.hs | 85 |
1 files changed, 41 insertions, 44 deletions
diff --git a/compiler/main/DriverPipeline.hs b/compiler/main/DriverPipeline.hs index 577cb61cf9..ff486e4c17 100644 --- a/compiler/main/DriverPipeline.hs +++ b/compiler/main/DriverPipeline.hs @@ -711,50 +711,47 @@ pipeLoop phase input_fn = do getOutputFilename :: Phase -> PipelineOutput -> String -> DynFlags -> Phase{-next phase-} -> Maybe ModLocation -> IO FilePath -getOutputFilename stop_phase output basename - = func - where - func dflags next_phase maybe_location - | is_last_phase, Persistent <- output = persistent_fn - | is_last_phase, SpecificFile f <- output = return f - | keep_this_output = persistent_fn - | otherwise = newTempName dflags suffix - where - hcsuf = hcSuf dflags - odir = objectDir dflags - osuf = objectSuf dflags - keep_hc = gopt Opt_KeepHcFiles dflags - keep_s = gopt Opt_KeepSFiles dflags - keep_bc = gopt Opt_KeepLlvmFiles dflags - - myPhaseInputExt HCc = hcsuf - myPhaseInputExt MergeStub = osuf - myPhaseInputExt StopLn = osuf - myPhaseInputExt other = phaseInputExt other - - is_last_phase = next_phase `eqPhase` stop_phase - - -- sometimes, we keep output from intermediate stages - keep_this_output = - case next_phase of - As | keep_s -> True - LlvmOpt | keep_bc -> True - HCc | keep_hc -> True - _other -> False - - suffix = myPhaseInputExt next_phase - - -- persistent object files get put in odir - persistent_fn - | StopLn <- next_phase = return odir_persistent - | otherwise = return persistent - - persistent = basename <.> suffix - - odir_persistent - | Just loc <- maybe_location = ml_obj_file loc - | Just d <- odir = d </> persistent - | otherwise = persistent +getOutputFilename stop_phase output basename dflags next_phase maybe_location + | is_last_phase, Persistent <- output = persistent_fn + | is_last_phase, SpecificFile f <- output = return f + | keep_this_output = persistent_fn + | otherwise = newTempName dflags suffix + where + hcsuf = hcSuf dflags + odir = objectDir dflags + osuf = objectSuf dflags + keep_hc = gopt Opt_KeepHcFiles dflags + keep_s = gopt Opt_KeepSFiles dflags + keep_bc = gopt Opt_KeepLlvmFiles dflags + + myPhaseInputExt HCc = hcsuf + myPhaseInputExt MergeStub = osuf + myPhaseInputExt StopLn = osuf + myPhaseInputExt other = phaseInputExt other + + is_last_phase = next_phase `eqPhase` stop_phase + + -- sometimes, we keep output from intermediate stages + keep_this_output = + case next_phase of + As | keep_s -> True + LlvmOpt | keep_bc -> True + HCc | keep_hc -> True + _other -> False + + suffix = myPhaseInputExt next_phase + + -- persistent object files get put in odir + persistent_fn + | StopLn <- next_phase = return odir_persistent + | otherwise = return persistent + + persistent = basename <.> suffix + + odir_persistent + | Just loc <- maybe_location = ml_obj_file loc + | Just d <- odir = d </> persistent + | otherwise = persistent -- ----------------------------------------------------------------------------- |