diff options
author | Sylvain Henry <sylvain@haskus.fr> | 2020-05-20 16:49:01 +0200 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2020-06-13 02:13:03 -0400 |
commit | 28d804e1e12a6be9bcd94b4667e27ba73beade38 (patch) | |
tree | 5c8c4e0e38fc742c717bbfc54f8b5bf16a1c6ebf /compiler | |
parent | 4274688a6333abffdfe7c7bda252c566f947afdf (diff) | |
download | haskell-28d804e1e12a6be9bcd94b4667e27ba73beade38.tar.gz |
Create helper upd_wired_in_home_instantiations
Diffstat (limited to 'compiler')
-rw-r--r-- | compiler/GHC/Unit/State.hs | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/compiler/GHC/Unit/State.hs b/compiler/GHC/Unit/State.hs index f6ad6371af..e568912310 100644 --- a/compiler/GHC/Unit/State.hs +++ b/compiler/GHC/Unit/State.hs @@ -594,16 +594,13 @@ initUnits dflags = do FormatText (pprModuleMap (moduleNameProvidersMap state)) - -- Some wired units can be used to instantiate the home unit. We need to - -- replace their unit keys by their wired unit ids. - let wiringMap = wireMap state - unwiredInsts = homeUnitInstantiations dflags - wiredInsts = map (fmap (upd_wired_in_mod wiringMap)) unwiredInsts + let dflags' = dflags + { unitDatabases = Just dbs + , unitState = state + } + dflags'' = upd_wired_in_home_instantiations dflags' - return (dflags{ unitDatabases = Just dbs, - unitState = state, - homeUnitInstantiations = wiredInsts }, - (preloadUnits state)) + return (dflags'', preloadUnits state) -- ----------------------------------------------------------------------------- -- Reading the unit database(s) @@ -1161,6 +1158,17 @@ findWiredInUnits printer prec_map pkgs vis_map = do -- For instance, base-4.9.0.0 will be rewritten to just base, to match -- what appears in GHC.Builtin.Names. +-- | Some wired units can be used to instantiate the home unit. We need to +-- replace their unit keys with their wired unit ids. +upd_wired_in_home_instantiations :: DynFlags -> DynFlags +upd_wired_in_home_instantiations dflags = dflags { homeUnitInstantiations = wiredInsts } + where + state = unitState dflags + wiringMap = wireMap state + unwiredInsts = homeUnitInstantiations dflags + wiredInsts = map (fmap (upd_wired_in_mod wiringMap)) unwiredInsts + + upd_wired_in_mod :: WiringMap -> Module -> Module upd_wired_in_mod wiredInMap (Module uid m) = Module (upd_wired_in_uid wiredInMap uid) m |