[project @ 1998-02-09 12:58:10 by sof]
[ghc-hetmet.git] / ghc / compiler / rename / RnIfaces.lhs
index 9a3bbc2..d52d886 100644 (file)
@@ -20,31 +20,30 @@ module RnIfaces (
 #include "HsVersions.h"
 
 import CmdLineOpts     ( opt_PruneTyDecls,  opt_PruneInstDecls, 
-                         opt_IgnoreIfacePragmas
+                         opt_D_show_rn_imports, opt_IgnoreIfacePragmas
                        )
 import HsSyn           ( HsDecl(..), TyDecl(..), ClassDecl(..), InstDecl(..), IfaceSig(..), 
                          HsType(..), ConDecl(..), IE(..), ConDetails(..), Sig(..),
                          hsDeclName
                        )
-import HsPragmas       ( noGenPragmas )
 import BasicTypes      ( Version, NewOrData(..), IfaceFlavour(..) )
 import RdrHsSyn                ( RdrNameHsDecl, RdrNameInstDecl, RdrNameTyDecl,
                          RdrName(..), rdrNameOcc
                        )
-import RnEnv           ( newImportedGlobalName, addImplicitOccsRn, ifaceFlavour,
-                         availName, availNames, addAvailToNameSet, pprAvail
+import RnEnv           ( newImportedGlobalName, addImplicitOccsRn,
+                         ifaceFlavour, availName, availNames, addAvailToNameSet
                        )
 import RnSource                ( rnHsSigType )
 import RnMonad
 import RnHsSyn          ( RenamedHsDecl )
 import ParseIface      ( parseIface, IfaceStuff(..) )
 
-import FiniteMap       ( FiniteMap, sizeFM, emptyFM, unitFM,  delFromFM,
+import FiniteMap       ( FiniteMap, sizeFM, emptyFM, delFromFM,
                          lookupFM, addToFM, addToFM_C, addListToFM, 
-                         fmToList, eltsFM 
+                         fmToList
                        )
 import Name            ( Name {-instance NamedThing-}, Provenance, OccName(..),
-                         nameModule, occNameString, moduleString, pprModule, isLocallyDefined,
+                         nameModule, moduleString, pprModule, isLocallyDefined,
                          NameSet(..), emptyNameSet, unionNameSets, nameSetToList,
                          minusNameSet, mkNameSet, elemNameSet, nameUnique, addOneToNameSet,
                          isWiredInName, maybeWiredInTyConName, maybeWiredInIdName,
@@ -55,14 +54,14 @@ import TyCon                ( TyCon, tyConDataCons, isSynTyCon, getSynTyConDefn )
 import Type            ( namesOfType )
 import TyVar           ( GenTyVar )
 import SrcLoc          ( mkSrcLoc, SrcLoc )
-import PrelMods                ( gHC__ )
+import PrelMods                ( pREL_GHC )
 import PrelInfo                ( cCallishTyKeys )
 import Bag
-import Maybes          ( MaybeErr(..), expectJust, maybeToBool )
+import Maybes          ( MaybeErr(..), maybeToBool )
 import ListSetOps      ( unionLists )
 import Outputable
 import Unique          ( Unique )
-import StringBuffer     ( StringBuffer, hGetStringBuffer, freeStringBuffer )
+import StringBuffer     ( StringBuffer, hGetStringBuffer )
 import FastString      ( mkFastString )
 import Outputable
 
@@ -509,7 +508,7 @@ getWiredInDecl name mode
        mod        = nameModule main_name
        doc_str    = sep [ptext SLIT("need home module for wired in thing"), ppr name]
     in
-    (if not main_is_tc || mod == gHC__ then
+    (if not main_is_tc || mod == pREL_GHC then
        returnRn ()             
     else
        loadInterface doc_str mod (ifaceFlavour main_name)      `thenRn_`
@@ -978,22 +977,24 @@ findAndReadIface doc_str mod_name as_source
          file_path = dir ++ '/' : moduleString mod_name ++ (mod_suffix hisuf)
 \end{code}
 
-@readIface@ trys just one file.
+@readIface@ tries just the one file.
 
 \begin{code}
 readIface :: String -> RnMG (Maybe ParsedIface)        
        -- Nothing <=> file not found, or unreadable, or illegible
        -- Just x  <=> successfully found and parsed 
 readIface file_path
-  = ioToRnMG (hGetStringBuffer file_path)                       `thenRn` \ read_result ->
-    --traceRn (hcat[ptext SLIT("Opening...."), text file_path])   `thenRn_`
+  = ioToRnMG (hGetStringBuffer file_path)       `thenRn` \ read_result ->
     case read_result of
        Right contents    -> 
              case parseIface contents (mkSrcLoc (mkFastString file_path) 1) of
-                 Failed err      ->
-                    failWithRn Nothing err 
+                 Failed err      -> failWithRn Nothing err 
                  Succeeded (PIface iface) -> 
-                    returnRn (Just iface)
+                       if opt_D_show_rn_imports then
+                          putDocRn (hcat[ptext SLIT("Read "), text file_path]) `thenRn_`
+                          returnRn (Just iface)
+                       else
+                          returnRn (Just iface)
 
         Left err ->
          if isDoesNotExistError err then