\begin{code}
module CmLink ( Linkable(..), Unlinked(..),
filterModuleLinkables,
+ findModuleLinkable,
modname_of_linkable, is_package_linkable,
LinkResult(..),
link,
import Interpreter
-import CmStaticInfo ( PackageConfigInfo )
+import CmStaticInfo ( PackageConfigInfo, GhciMode(..) )
import Module ( ModuleName, PackageName )
import Outputable ( SDoc )
-import Digraph ( SCC(..), flattenSCC, flattenSCCs )
+import Digraph ( SCC(..), flattenSCC )
import Outputable
import Panic ( panic )
-import BasicTypes ( GhciMode(..) )
#include "HsVersions.h"
\end{code}
ppr (LM mod_nm unlinkeds) = text "LinkableM" <+> ppr mod_nm <+> ppr unlinkeds
ppr (LP package_nm) = text "LinkableP" <+> ptext package_nm
+findModuleLinkable :: [Linkable] -> ModuleName -> Linkable
+findModuleLinkable lis mod
+ = case [LM nm us | LM nm us <- lis, nm == mod] of
+ [li] -> li
+ other -> pprPanic "findModuleLinkable" (ppr mod)
+
+
emptyPLS :: IO PersistentLinkerState
#ifdef GHCI
emptyPLS = return (PersistentLinkerState { closure_env = emptyFM,
link :: ([String] -> IO ())
-> GhciMode -- interactive or batch
-> Bool -- attempt linking in batch mode?
- -> PackageConfigInfo
- -> [SCC Linkable]
+ -> [Linkable] -- only contains LMs, not LPs
-> PersistentLinkerState
-> IO LinkResult
-- batch mode. It should only be True if the upsweep was
-- successful and someone exports main, i.e., we have good
-- reason to believe that linking will succeed.
-link doLink Batch batch_attempt_linking pci groups pls1
+link doLink Batch batch_attempt_linking linkables pls1
| batch_attempt_linking
= do putStrLn "LINK(batch): linkables are ..."
- putStrLn (showSDoc (vcat (map ppLinkableSCC groups)))
- let o_files = concatMap getOfiles (flattenSCCs groups)
+ putStrLn (showSDoc (vcat (map ppr linkables)))
+ let o_files = concatMap getOfiles linkables
doLink o_files
-- doLink only returns if it succeeds
putStrLn "LINK(batch): done"
putStrLn " -- not doing linking"
return (LinkOK pls1)
where
- getOfiles (LP _) = []
+ getOfiles (LP _) = panic "link.getOfiles: shouldn't get package linkables"
getOfiles (LM _ us) = map nameOfObject (filter isObject us)
-link doLink Interactive batch_attempt_linking pci groups pls1
+link doLink Interactive batch_attempt_linking linkables pls1
= do putStrLn "LINKER(interactive): not yet implemented"
return (LinkOK pls1)