+ ; flat_result <- _scc_ "Flattening"
+ flatten hsc_env pcs_tc ds_result
+
+
+ ; let -- Rule-base accumulated from imported packages
+ pkg_rule_base = eps_rule_base (pcs_EPS pcs_tc)
+
+ -- In one-shot mode, ZAP the external package state at
+ -- this point, because we aren't going to need it from
+ -- now on. We keep the name cache, however, because
+ -- tidyCore needs it.
+ pcs_middle
+ | one_shot = pcs_tc{ pcs_EPS = error "pcs_EPS missing" }
+ | otherwise = pcs_tc
+
+ ; pkg_rule_base `seq` pcs_middle `seq` return ()
+
+ -- alive at this point:
+ -- pcs_middle
+ -- flat_result
+ -- pkg_rule_base
+
+ -------------------
+ -- SIMPLIFY
+ -------------------
+ ; simpl_result <- _scc_ "Core2Core"
+ core2core hsc_env pkg_rule_base flat_result
+
+ -------------------
+ -- TIDY
+ -------------------
+ ; (pcs_simpl, tidy_result)
+ <- _scc_ "CoreTidy"
+ tidyCorePgm dflags pcs_middle simpl_result
+
+ -- ZAP the persistent compiler state altogether now if we're
+ -- in one-shot mode, to save space.
+ ; pcs_final <- if one_shot then return (error "pcs_final missing")
+ else return pcs_simpl
+
+ ; emitExternalCore dflags tidy_result
+
+ -- Alive at this point:
+ -- tidy_result, pcs_final
+ -- hsc_env
+
+ -------------------
+ -- BUILD THE NEW ModIface and ModDetails
+ -- and emit external core if necessary
+ -- This has to happen *after* code gen so that the back-end
+ -- info has been set. Not yet clear if it matters waiting
+ -- until after code output
+ ; new_iface <- _scc_ "MkFinalIface"
+ mkIface hsc_env location
+ maybe_checked_iface tidy_result
+
+
+ -- Space leak reduction: throw away the new interface if
+ -- we're in one-shot mode; we won't be needing it any
+ -- more.
+ ; final_iface <-
+ if one_shot then return (error "no final iface")
+ else return new_iface
+
+ -- Build the final ModDetails (except in one-shot mode, where
+ -- we won't need this information after compilation).
+ ; final_details <-
+ if one_shot then return (error "no final details")
+ else return $! ModDetails {
+ md_types = mg_types tidy_result,
+ md_insts = mg_insts tidy_result,
+ md_rules = mg_rules tidy_result }
+
+ -------------------
+ -- CONVERT TO STG and COMPLETE CODE GENERATION
+ ; (stub_h_exists, stub_c_exists, maybe_bcos)
+ <- hscBackEnd dflags tidy_result
+
+ -- and the answer is ...
+ ; return (HscRecomp pcs_final
+ final_details
+ final_iface
+ stub_h_exists stub_c_exists
+ maybe_bcos)
+ }}
+
+hscCoreFrontEnd hsc_env pcs_ch location = do {