Commit eb629fab authored by John Ericson's avatar John Ericson Committed by Marge Bot

Delete some superfluous helper functions in HscMain

The driver code is some of the nastiest in GHC, and I am worried about
being able to untangle all the tech debt. In `HscMain` we have a number
of helpers which are either not-used or little used. I delete them so we
can reduce cognative load, distilling the essential complexity away from
the cruft.
parent e3b0bd97
......@@ -73,12 +73,12 @@ module HscMain
-- * Low-level exports for hooks
, hscCompileCoreExpr'
-- We want to make sure that we export enough to be able to redefine
-- hscFileFrontEnd in client code
-- hsc_typecheck in client code
, hscParse', hscSimplify', hscDesugar', tcRnModule', doCodeGen
, getHscEnv
, hscSimpleIface'
, oneShotMsg
, hscFileFrontEnd, genericHscFrontend, dumpIfaceStats
, dumpIfaceStats
, ioMsgMaybe
, showModuleIndex
, hscAddSptEntries
......@@ -452,23 +452,17 @@ extract_renamed_stuff mod_summary tc_result = do
-- | Rename and typecheck a module, additionally returning the renamed syntax
hscTypecheckRename :: HscEnv -> ModSummary -> HsParsedModule
-> IO (TcGblEnv, RenamedStuff)
hscTypecheckRename hsc_env mod_summary rdr_module = runHsc hsc_env $ do
tc_result <- hsc_typecheck True mod_summary (Just rdr_module)
rn_info <- extract_renamed_stuff mod_summary tc_result
return (tc_result, rn_info)
hscTypecheckRename hsc_env mod_summary rdr_module = runHsc hsc_env $
hsc_typecheck True mod_summary (Just rdr_module)
-- | Rename and typecheck a module, but don't return the renamed syntax
hscTypecheck :: Bool -- ^ Keep renamed source?
-> ModSummary -> Maybe HsParsedModule
-> Hsc TcGblEnv
hscTypecheck keep_rn mod_summary mb_rdr_module = do
tc_result <- hsc_typecheck keep_rn mod_summary mb_rdr_module
_ <- extract_renamed_stuff mod_summary tc_result
return tc_result
-- | A bunch of logic piled around around @tcRnModule'@, concerning a) backpack
-- b) concerning dumping rename info and hie files. It would be nice to further
-- separate this stuff out, probably in conjunction better separating renaming
-- and type checking (#17781).
hsc_typecheck :: Bool -- ^ Keep renamed source?
-> ModSummary -> Maybe HsParsedModule
-> Hsc TcGblEnv
-> Hsc (TcGblEnv, RenamedStuff)
hsc_typecheck keep_rn mod_summary mb_rdr_module = do
hsc_env <- getHscEnv
let hsc_src = ms_hsc_src mod_summary
......@@ -481,7 +475,7 @@ hsc_typecheck keep_rn mod_summary mb_rdr_module = do
real_loc = realSrcLocSpan $ mkRealSrcLoc (mkFastString src_filename) 1 1
keep_rn' = gopt Opt_WriteHie dflags || keep_rn
MASSERT( moduleUnitId outer_mod == thisPackage dflags )
if hsc_src == HsigFile && not (isHoleModule inner_mod)
tc_result <- if hsc_src == HsigFile && not (isHoleModule inner_mod)
then ioMsgMaybe $ tcRnInstantiateSignature hsc_env outer_mod' real_loc
else
do hpm <- case mb_rdr_module of
......@@ -493,6 +487,10 @@ hsc_typecheck keep_rn mod_summary mb_rdr_module = do
ioMsgMaybe $
tcRnMergeSignatures hsc_env hpm tc_result0 iface
else return tc_result0
-- TODO are we extracting anything when we merely instantiate a signature?
-- If not, try to move this into the "else" case above.
rn_info <- extract_renamed_stuff mod_summary tc_result
return (tc_result, rn_info)
-- wrapper around tcRnModule to handle safe haskell extras
tcRnModule' :: ModSummary -> Bool -> HsParsedModule
......@@ -656,8 +654,8 @@ hscIncrementalFrontend
compile mb_old_hash reason = do
liftIO $ msg reason
result <- genericHscFrontend mod_summary
return $ Right (result, mb_old_hash)
(tc_result, _) <- hsc_typecheck False mod_summary Nothing
return $ Right (FrontendTypecheck tc_result, mb_old_hash)
stable = case source_modified of
SourceUnmodifiedAndStable -> True
......@@ -704,14 +702,6 @@ hscIncrementalFrontend
Just tc_result ->
return $ Right (FrontendTypecheck tc_result, mb_old_hash)
genericHscFrontend :: ModSummary -> Hsc FrontendResult
genericHscFrontend mod_summary =
getHooked hscFrontendHook genericHscFrontend' >>= ($ mod_summary)
genericHscFrontend' :: ModSummary -> Hsc FrontendResult
genericHscFrontend' mod_summary
= FrontendTypecheck `fmap` hscFileFrontEnd mod_summary
--------------------------------------------------------------
-- Compilers
--------------------------------------------------------------
......@@ -919,15 +909,6 @@ batchMsg hsc_env mod_index recomp mod_summary =
(recompileRequired recomp) mod_summary)
++ reason
--------------------------------------------------------------
-- FrontEnds
--------------------------------------------------------------
-- | Given a 'ModSummary', parses and typechecks it, returning the
-- 'TcGblEnv' resulting from type-checking.
hscFileFrontEnd :: ModSummary -> Hsc TcGblEnv
hscFileFrontEnd mod_summary = hscTypecheck False mod_summary Nothing
--------------------------------------------------------------
-- Safe Haskell
--------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment