X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2Frename%2FRnIfaces.lhs;h=8912a65d4257102343ca77dafb98fcd115897a56;hb=6af6951bef8ba4826103a7170a82d3c70bb16805;hp=f5e5e7783b3f9ad9c8553a3aa27b83308d37c3c1;hpb=87fe9c34612b5149ae8c8307567cb4cf54db82f2;p=ghc-hetmet.git diff --git a/ghc/compiler/rename/RnIfaces.lhs b/ghc/compiler/rename/RnIfaces.lhs index f5e5e77..8912a65 100644 --- a/ghc/compiler/rename/RnIfaces.lhs +++ b/ghc/compiler/rename/RnIfaces.lhs @@ -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, @@ -58,11 +57,11 @@ import SrcLoc ( mkSrcLoc, SrcLoc ) 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 @@ -158,22 +157,22 @@ count_decls decls \begin{code} loadInterface :: SDoc -> Module -> IfaceFlavour -> RnMG Ifaces loadInterface doc_str load_mod as_source - = getIfacesRn `thenRn` \ ifaces -> - let + = getIfacesRn `thenRn` \ ifaces -> + let Ifaces this_mod mod_map decls all_names imp_names (insts, tycls_names) deferred_data_decls inst_mods = ifaces - in + in -- CHECK WHETHER WE HAVE IT ALREADY - case lookupFM mod_map load_mod of { + case lookupFM mod_map load_mod of { Just (hif, _, _, _) | hif `as_good_as` as_source -> -- Already in the cache; don't re-read it returnRn ifaces ; other -> -- READ THE MODULE IN - findAndReadIface doc_str load_mod as_source `thenRn` \ read_result -> - case read_result of { + findAndReadIface doc_str load_mod as_source `thenRn` \ read_result -> + case read_result of { -- Check for not found Nothing -> -- Not found, so add an empty export env to the Ifaces map -- so that we don't look again @@ -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 @@ -1002,7 +1003,13 @@ readIface file_path failWithRn Nothing (cannaeReadFile file_path err) \end{code} -mkSearchPath takes a string consisting of a colon-separated list +%********************************************************* +%* * +\subsection{Utils} +%* * +%********************************************************* + +@mkSearchPath@ takes a string consisting of a colon-separated list of directories and corresponding suffixes, and turns it into a list of (directory, suffix) pairs. For example: