[project @ 2002-10-25 21:59:51 by simonpj]
authorsimonpj <unknown>
Fri, 25 Oct 2002 21:59:52 +0000 (21:59 +0000)
committersimonpj <unknown>
Fri, 25 Oct 2002 21:59:52 +0000 (21:59 +0000)
Put findLinkable in Finder.lhs, where it can be found in non-ghci stage1 compilers!

ghc/compiler/compMan/CompManager.lhs
ghc/compiler/ghci/Linker.lhs
ghc/compiler/main/Finder.lhs

index 313da96..f026f5b 100644 (file)
@@ -93,7 +93,7 @@ import Id             ( idType )
 import Type            ( tidyType )
 import VarEnv          ( emptyTidyEnv )
 import BasicTypes      ( Fixity, FixitySig(..), defaultFixity )
-import Linker          ( HValue, unload, extendLinkEnv, findLinkable )
+import Linker          ( HValue, unload, extendLinkEnv )
 import GHC.Exts                ( unsafeCoerce# )
 import Foreign
 import Control.Exception as Exception ( Exception, try )
index b2e07e3..f123ded 100644 (file)
@@ -16,7 +16,6 @@ necessary.
 {-# OPTIONS -optc-DNON_POSIX_SOURCE #-}
 
 module Linker ( HValue, initLinker, showLinkerState,
-               findLinkable,
                linkLibraries, linkExpr,
                unload, extendLinkEnv, 
                LibrarySpec(..)
@@ -34,8 +33,7 @@ import ByteCodeAsm    ( CompiledByteCode(..), bcosFreeNames,
 import Packages                ( PackageConfig(..), PackageName, PackageConfigMap, lookupPkg,
                          packageDependents, packageNameString )
 import DriverState     ( v_Library_paths, v_Cmdline_libraries, getPackageConfigMap )
-import DriverUtil      ( splitFilename3 )
-import Finder          ( findModule )
+import Finder          ( findModule, findLinkable )
 import HscTypes                ( Linkable(..), isObjectLinkable, nameOfObject, byteCodeOfObject,
                          Unlinked(..), isInterpretable, isObject, Dependencies(..),
                          HscEnv(..), PersistentCompilerState(..), ExternalPackageState(..),
@@ -789,24 +787,6 @@ findFile mk_file_path (dir:dirs)
             return (Just file_path)
          else
             findFile mk_file_path dirs }
-
-
-findLinkable :: ModuleName -> ModLocation -> IO (Maybe Linkable)
-findLinkable mod locn
-   | Just obj_fn <- ml_obj_file locn
-   = do obj_exist <- doesFileExist obj_fn
-        if not obj_exist 
-         then return Nothing 
-         else 
-         do let stub_fn = case splitFilename3 obj_fn of
-                             (dir, base, ext) -> dir ++ "/" ++ base ++ ".stub_o"
-            stub_exist <- doesFileExist stub_fn
-            obj_time <- getModificationTime obj_fn
-            if stub_exist
-             then return (Just (LM obj_time mod [DotO obj_fn, DotO stub_fn]))
-             else return (Just (LM obj_time mod [DotO obj_fn]))
-   | otherwise
-   = return Nothing
 \end{code}
 
 \begin{code}
index 74ecc06..3491a72 100644 (file)
@@ -14,6 +14,8 @@ module Finder (
     mkHomeModLocation, -- :: ModuleName -> String -> FilePath 
                        --      -> IO ModLocation
 
+    findLinkable,      -- :: ModuleName -> ModLocation -> IO (Maybe Linkable)
+
     hiBootExt,         -- :: String
     hiBootVerExt,      -- :: String
 
@@ -24,8 +26,9 @@ module Finder (
 import Module
 import UniqFM          ( filterUFM )
 import Packages                ( PackageConfig(..) )
+import HscTypes                ( Linkable(..), Unlinked(..) )
 import DriverState
-import DriverUtil      ( split_longest_prefix )
+import DriverUtil      ( split_longest_prefix, splitFilename3 )
 import FastString
 import Config
 import Util
@@ -310,3 +313,26 @@ mkHomeModLocation mod_name is_root path basename extension = do
    addToFinderCache mod_name result
    return result
 \end{code}
+
+-- -----------------------------------------------------------------------------
+-- findLinkable isn't related to the other stuff in here, 
+-- but there' no other obvious place for it
+
+\begin{code}
+findLinkable :: ModuleName -> ModLocation -> IO (Maybe Linkable)
+findLinkable mod locn
+   | Just obj_fn <- ml_obj_file locn
+   = do obj_exist <- doesFileExist obj_fn
+        if not obj_exist 
+         then return Nothing 
+         else 
+         do let stub_fn = case splitFilename3 obj_fn of
+                             (dir, base, ext) -> dir ++ "/" ++ base ++ ".stub_o"
+            stub_exist <- doesFileExist stub_fn
+            obj_time <- getModificationTime obj_fn
+            if stub_exist
+             then return (Just (LM obj_time mod [DotO obj_fn, DotO stub_fn]))
+             else return (Just (LM obj_time mod [DotO obj_fn]))
+   | otherwise
+   = return Nothing
+\end{code}
\ No newline at end of file