- -- Compilation "succeeded", but didn't return a new
- -- linkable, meaning that compilation wasn't needed, and the
- -- new details were manufactured from the old iface.
- CompOK pcs2 new_details new_iface Nothing
- -> do let hst2 = addToUFM hst1 mod_name new_details
- hit2 = addToUFM hit1 mod_name new_iface
- threaded2 = CmThreaded pcs2 hst2 hit2
-
- if ghci_mode == Interactive && verb >= 1 then
- -- if we're using an object file, tell the user
- case old_linkable of
- (LM _ _ objs@(DotO _:_))
- -> do hPutStrLn stderr (showSDoc (space <>
- parens (hsep (text "using":
- punctuate comma
- [ text o | DotO o <- objs ]))))
- _ -> return ()
- else
- return ()
-
- return (threaded2, Just old_linkable)
-
- -- Compilation really did happen, and succeeded. A new
- -- details, iface and linkable are returned.
- CompOK pcs2 new_details new_iface (Just new_linkable)
- -> do let hst2 = addToUFM hst1 mod_name new_details
- hit2 = addToUFM hit1 mod_name new_iface
- threaded2 = CmThreaded pcs2 hst2 hit2
-
- return (threaded2, Just new_linkable)
-
- -- Compilation failed. compile may still have updated
- -- the PCS, tho.
- CompErrs pcs2
- -> do let threaded2 = CmThreaded pcs2 hst1 hit1
- return (threaded2, Nothing)
-
--- Remove unwanted modules from the top level envs (HST, HIT, UI).
-removeFromTopLevelEnvs :: [ModuleName]
- -> (HomeSymbolTable, HomeIfaceTable, UnlinkedImage)
- -> (HomeSymbolTable, HomeIfaceTable, UnlinkedImage)
-removeFromTopLevelEnvs zap_these (hst, hit, ui)
- = (delListFromUFM hst zap_these,
- delListFromUFM hit zap_these,
- filterModuleLinkables (`notElem` zap_these) ui
- )
-
-retainInTopLevelEnvs :: [ModuleName]
- -> (HomeSymbolTable, HomeIfaceTable)
- -> (HomeSymbolTable, HomeIfaceTable)
-retainInTopLevelEnvs keep_these (hst, hit)
- = (retainInUFM hst keep_these,
- retainInUFM hit keep_these
- )
- where
- retainInUFM :: Uniquable key => UniqFM elt -> [key] -> UniqFM elt
- retainInUFM ufm keys_to_keep
- = listToUFM (concatMap (maybeLookupUFM ufm) keys_to_keep)
- maybeLookupUFM ufm u
- = case lookupUFM ufm u of Nothing -> []; Just val -> [(u, val)]
+ -- Compilation "succeeded", and may or may not have returned a new
+ -- linkable (depending on whether compilation was actually performed
+ -- or not).
+ CompOK pcs2 new_details new_iface maybe_new_linkable
+ -> do let
+ new_linkable = maybe_new_linkable `orElse` old_linkable
+ new_info = HomeModInfo { hm_iface = new_iface,
+ hm_details = new_details,
+ hm_linkable = new_linkable }
+ hpt2 = extendModuleEnv hpt1 this_mod new_info
+
+ return (Succeeded, CmThreaded pcs2 hpt2)
+
+ -- Compilation failed. Compile may still have updated the PCS, tho.
+ CompErrs pcs2 -> return (Failed, CmThreaded pcs2 hpt1)
+
+-- Filter modules in the HPT
+retainInTopLevelEnvs :: [ModuleName] -> HomePackageTable -> HomePackageTable
+retainInTopLevelEnvs keep_these hpt
+ = listToUFM (concatMap (maybeLookupUFM hpt) keep_these)
+ where
+ maybeLookupUFM ufm u = case lookupUFM ufm u of
+ Nothing -> []
+ Just val -> [(u, val)]