- ; cg_info_ref <- newIORef Nothing ;
- ; let cg_info :: CgInfoEnv
- cg_info = unsafePerformIO $ do {
- maybe_cg_env <- readIORef cg_info_ref ;
- case maybe_cg_env of
- Just env -> return env
- Nothing -> do { printError "Urk! Looked at CgInfo too early!";
- return emptyNameEnv } }
- -- cg_info_ref will be filled in just after restOfCodeGeneration
- -- Meanwhile, tidyCorePgm is careful not to look at cg_info!
-
- ; (pcs_simpl, tidy_details)
- <- _scc_ "CoreTidy"
- tidyCorePgm dflags this_mod pcs_middle cg_info simpl_details
-
- ; pcs_final <- if ghci_mode == OneShot then initPersistentCompilerState
- else return pcs_simpl
+ (tc_msgs, maybe_tc_result)
+ <- _scc_ "Typecheck-Rename"
+ tcRnModule hsc_env (ms_hsc_src mod_summary)
+ True{-save renamed syntax-}
+ rdr_module
+
+ ; msg_act tc_msgs
+ ; case maybe_tc_result of {
+ Nothing -> return (HscChecked rdr_module Nothing Nothing);
+ Just tc_result -> do
+ let md = ModDetails {
+ md_types = tcg_type_env tc_result,
+ md_exports = tcg_exports tc_result,
+ md_insts = tcg_insts tc_result,
+ md_rules = [panic "no rules"] }
+ -- Rules are CoreRules, not the
+ -- RuleDecls we get out of the typechecker
+ return (HscChecked rdr_module
+ (tcg_rn_decls tc_result)
+ (Just (tcg_binds tc_result,
+ tcg_rdr_env tc_result,
+ md)))
+ }}}}
+
+------------------------------
+hscBootBackEnd :: HscEnv -> ModSummary -> Maybe ModIface -> Maybe ModGuts -> IO HscResult
+-- For hs-boot files, there's no code generation to do
+
+hscBootBackEnd hsc_env mod_summary maybe_old_iface Nothing
+ = return HscFail
+hscBootBackEnd hsc_env mod_summary maybe_old_iface (Just ds_result)
+ = do { (_cg_guts, details) <- simpleTidyPgm hsc_env ds_result
+
+ ; (new_iface, no_change)
+ <- {-# SCC "MkFinalIface" #-}
+ mkIface hsc_env maybe_old_iface ds_result details
+
+ ; writeIfaceFile hsc_env (ms_location mod_summary) new_iface no_change
+
+ ; let { final_details = ModDetails { md_types = mg_types ds_result,
+ md_exports = mg_exports ds_result,
+ md_insts = mg_insts ds_result,
+ md_rules = mg_rules ds_result } }
+ -- And the answer is ...
+ ; dumpIfaceStats hsc_env
+
+ ; return (HscRecomp final_details
+ new_iface
+ False False Nothing)
+ }
+
+------------------------------
+hscBackEnd :: HscEnv -> ModSummary -> Maybe ModIface -> Maybe ModGuts -> IO HscResult
+
+hscBackEnd hsc_env mod_summary maybe_old_iface Nothing
+ = return HscFail
+
+hscBackEnd hsc_env mod_summary maybe_old_iface (Just ds_result)
+ = do { -- OMITTED:
+ -- ; seqList imported_modules (return ())
+
+ let one_shot = isOneShot (ghcMode dflags)
+ dflags = hsc_dflags hsc_env
+
+ -------------------
+ -- FLATTENING
+ -------------------
+ ; flat_result <- {-# SCC "Flattening" #-}
+ flatten hsc_env ds_result
+
+
+{- TEMP: need to review space-leak fixing here
+ NB: even the code generator can force one of the
+ thunks for constructor arguments, for newtypes in particular
+
+ ; let -- Rule-base accumulated from imported packages
+ pkg_rule_base = eps_rule_base (hsc_EPS hsc_env)
+
+ -- 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 ()
+-}