where
import StgInterp ( linkIModules, ClosureEnv, ItblEnv )
-
+import Linker ( loadObj, resolveObjs )
import CmStaticInfo ( PackageConfigInfo )
import Module ( ModuleName, PackageName )
import InterpSyn ( UnlinkedIBind, HValue, binder )
import Module ( Module )
import Outputable ( SDoc )
import FiniteMap ( emptyFM )
-import Digraph ( SCC(..) )
+import Digraph ( SCC(..), flattenSCC )
import Outputable
import Panic ( panic )
-> PersistentLinkerState
-> IO LinkResult
+#ifndef GHCI_NOTYET
+--link = panic "CmLink.link: not implemented"
+link pci groups pls1
+ = do putStrLn "Hello from the Linker!"
+ putStrLn (showSDoc (vcat (map ppLinkableSCC groups)))
+ putStrLn "Bye-bye from the Linker!"
+ return (LinkOK pls1)
+
+ppLinkableSCC :: SCC Linkable -> SDoc
+ppLinkableSCC = ppr . flattenSCC
+
+#else
+
+
link pci [] pls = return (LinkOK pls)
-link pci (group:groups) pls = do
+link pci (groupSCC:groups) pls = do
+ let group = flattenSCC groupSCC
-- the group is either all objects or all interpretable, for now
if all isObject group
then do mapM loadObj [ file | DotO file <- group ]
itbl_env=new_itbl_env})
else
return (LinkErrs pls (ptext SLIT("linker: group must contain all objects or all interpreted modules")))
+#endif
+
modname_of_linkable (LM nm _) = nm
modname_of_linkable (LP _) = panic "modname_of_linkable: package"
else simple_transitive_closure graph set2
-flattenSCCs :: [SCC a] -> [a]
-flattenSCCs = concatMap flatten
-
-flatten (AcyclicSCC v) = [v]
-flatten (CyclicSCC vs) = vs
-
-- For each module in mods_to_group, extract the relevant linkable
-- out of UI, and arrange these linkables in SCCs as defined by modGraph.
-- All this is so that we can pass SCCified Linkable groups to the
#if __GLASGOW_HASKELL__ <= 408
-import Panic ( panic )
-type ItblEnv = ()
-type ClosureEnv = ()
+import Panic ( panic )
+import RdrName ( RdrName )
+import PrelAddr ( Addr )
+import FiniteMap ( FiniteMap )
+import InterpSyn ( HValue )
+
+type ItblEnv = FiniteMap RdrName Addr
+type ClosureEnv = FiniteMap RdrName HValue
linkIModules = panic "StgInterp.linkIModules: this hsc was not built with an interpreter"
stgToInterpSyn = panic "StgInterp.linkIModules: this hsc was not built with an interpreter"
module Digraph(
-- At present the only one with a "nice" external interface
- stronglyConnComp, stronglyConnCompR, SCC(..),
+ stronglyConnComp, stronglyConnCompR, SCC(..), flattenSCC, flattenSCCs,
Graph, Vertex,
graphFromEdges, buildG, transposeG, reverseE, outdegree, indegree,
data SCC vertex = AcyclicSCC vertex
| CyclicSCC [vertex]
+flattenSCCs :: [SCC a] -> [a]
+flattenSCCs = concatMap flattenSCC
+
+flattenSCC (AcyclicSCC v) = [v]
+flattenSCC (CyclicSCC vs) = vs
+\end{code}
+
+\begin{code}
stronglyConnComp
:: Ord key
=> [(node, key, [key])] -- The graph; its ok for the
#endif
, global
- , myProcessID
+ , myGetProcessID
#if __GLASGOW_HASKELL__ <= 408
, catchJust
#endif
#ifdef mingw32_TARGET_OS
-foreign import "_getpid" myProcessID :: IO Int
+foreign import "_getpid" myGetProcessID :: IO Int
#else
-myProcessID :: IO Int
-myProcessID = do hPutStrLn stderr "Warning:myProcessID"
- return 12345
+myGetProcessID :: IO Int
+myGetProcessID = do hPutStrLn stderr "Warning:faking process ID in myGetProcessID"
+ return 12345
#endif
\end{code}