[project @ 2003-01-08 15:28:04 by simonmar]
[ghc-hetmet.git] / ghc / compiler / rename / RnHiFiles.lhs
index 39226b7..e5f83a5 100644 (file)
@@ -14,8 +14,8 @@ module RnHiFiles (
 #include "HsVersions.h"
 
 import DriverState     ( v_GhcMode, isCompManagerMode )
-import DriverUtil      ( splitFilename, replaceFilenameSuffix )
-import CmdLineOpts     ( opt_IgnoreIfacePragmas )
+import DriverUtil      ( replaceFilenameSuffix )
+import CmdLineOpts     ( opt_IgnoreIfacePragmas, verbosity )
 import Parser          ( parseIface )
 import HscTypes                ( ModIface(..), emptyModIface,
                          ExternalPackageState(..), noDependencies,
@@ -69,7 +69,6 @@ import Outputable
 import Bag
 import BinIface                ( readBinIface )
 import Panic
-import Config
 
 import EXCEPTION as Exception
 import DATA_IOREF      ( readIORef )
@@ -225,15 +224,9 @@ loadInterface doc_str mod_name from
                                vers_rules = rule_vers,
                                vers_decls = decls_vers }
 
-       this_mod_name = moduleName this_mod
-       is_loaded m   =  m == this_mod_name 
-                     || maybeToBool (lookupIfaceByModName hpt pit m)
-               -- We treat the currently-being-compiled module as 'loaded' because
-               -- even though it isn't yet in the HIT or PIT; otherwise it gets
-               -- put into iImpModInfo, and then spat out into its own interface
-               -- file as a dependency
-
        -- Now add info about this module to the PIT
+       -- Even home modules loaded by this route (which only 
+       -- happens in OneShot mode) are put in the PIT
        has_orphans = pi_orphan iface
        new_pit   = extendModuleEnv pit mod mod_iface
        mod_iface = ModIface { mi_module = mod, mi_package = pi_pkg iface,
@@ -306,7 +299,7 @@ loadDecl mod (version_map, decls_map) (version, decl)
 
        new_version_map = extendNameEnv version_map main_name version
     in
-    traceRn (text "Loading" <+> ppr full_avail) `thenM_`
+--    traceRn (text "Loading" <+> ppr full_avail) `thenM_`
     returnM (new_version_map, new_decls_map)
 
 
@@ -424,7 +417,7 @@ loadInstDecl mod insts decl@(InstDecl inst_ty _ _ _ _)
        -- (Note that we do let the inst decl in if it mentions 
        --  no tycons at all.  Hence the null free_ty_names.)
     in
-    traceRn ((text "Load instance for" <+> ppr inst_ty') $$ ppr free_tcs)      `thenM_`
+--    traceRn ((text "Load instance for" <+> ppr inst_ty') $$ ppr free_tcs)    `thenM_`
     returnM ((gate_fn, (mod, decl)) `consBag` insts)
 
 
@@ -463,7 +456,7 @@ loadDeprecs (Just (Right prs)) = foldlM loadDeprec emptyNameEnv prs `thenM` \ en
                                 returnM (DeprecSome env)
 loadDeprec deprec_env (n, txt)
   = lookupGlobalOccRn n        `thenM` \ name ->
-    traceRn (text "Loaded deprecation(s) for" <+> ppr name <> colon <+> ppr txt) `thenM_`
+--    traceRn (text "Loaded deprecation(s) for" <+> ppr name <> colon <+> ppr txt) `thenM_`
     returnM (extendNameEnv deprec_env name (name,txt))
 \end{code}
 
@@ -575,11 +568,12 @@ findAndReadIface doc_str mod_name hi_boot_file
     ioToTcRn (findHiFile mod_name hi_boot_file)        `thenM` \ maybe_found ->
 
     case maybe_found of
-      Nothing -> 
+      Left files -> 
        traceRn (ptext SLIT("...not found"))    `thenM_`
-       returnM (Left (noIfaceErr mod_name hi_boot_file))
+       getDOpts                                `thenM` \ dflags ->
+       returnM (Left (noIfaceErr dflags mod_name hi_boot_file files))
 
-      Just (wanted_mod, file_path) -> 
+      Right (wanted_mod, file_path) -> 
        traceRn (ptext SLIT("readIFace") <+> text file_path)    `thenM_` 
 
        readIface wanted_mod file_path hi_boot_file     `thenM` \ read_result ->
@@ -598,7 +592,8 @@ findAndReadIface doc_str mod_name hi_boot_file
                           ppr mod_name <> semi],
                     nest 4 (ptext SLIT("reason:") <+> doc_str)]
 
-findHiFile :: ModuleName -> IsBootInterface -> IO (Maybe (Module, FilePath))
+findHiFile :: ModuleName -> IsBootInterface
+          -> IO (Either [FilePath] (Module, FilePath))
 findHiFile mod_name hi_boot_file
  = do { 
        -- In interactive or --make mode, we are *not allowed* to demand-load
@@ -614,9 +609,9 @@ findHiFile mod_name hi_boot_file
                        else findPackageModule mod_name ;
 
        case maybe_found of {
-         Nothing -> return Nothing ;
+         Left files -> return (Left files) ;
 
-         Just (mod,loc) -> do {
+         Right (mod,loc) -> do {
 
        -- Return the path to M.hi, M.hi-boot, or M.hi-boot-n as appropriate
        let { hi_path            = ml_hi_file loc ;
@@ -625,11 +620,11 @@ findHiFile mod_name hi_boot_file
            };
 
        if not hi_boot_file then
-          return (Just (mod, hi_path))
+          return (Right (mod, hi_path))
        else do {
                hi_ver_exists <- doesFileExist hi_boot_ver_path ;
-               if hi_ver_exists then return (Just (mod, hi_boot_ver_path))
-                                else return (Just (mod, hi_boot_path))
+               if hi_ver_exists then return (Right (mod, hi_boot_ver_path))
+                                else return (Right (mod, hi_boot_path))
        }}}}
 \end{code}
 
@@ -706,12 +701,6 @@ ghcPrimIface = ParsedIface {
 %*********************************************************
 
 \begin{code}
-noIfaceErr mod_name boot_file
-  = ptext SLIT("Could not find interface file for") <+> quotes (ppr mod_name)
-       -- We used to print the search path, but we can't do that
-       -- now, because it's hidden inside the finder.
-       -- Maybe the finder should expose more functions.
-
 badIfaceFile file err
   = vcat [ptext SLIT("Bad interface file:") <+> text file, 
          nest 4 err]