[project @ 2000-10-16 15:16:59 by simonmar]
[ghc-hetmet.git] / ghc / compiler / main / HscTypes.lhs
index 6426da4..9ebbbee 100644 (file)
@@ -6,18 +6,23 @@
 \begin{code}
 module HscTypes ( 
        ModDetails(..), GlobalSymbolTable, 
+       HomeSymbolTable, PackageSymbolTable,
 
        TyThing(..), lookupTypeEnv,
 
        WhetherHasOrphans, ImportVersion, ExportItem,
        PersistentRenamerState(..), IsBootInterface, Avails, DeclsMap,
-       IfaceInsts, IfaceRules, DeprecationEnv, OrigNameEnv, AvailEnv,
+       IfaceInsts, IfaceRules, DeprecationEnv, OrigNameEnv, 
+       AvailEnv, AvailInfo, GenAvailInfo(..),
+       PersistentCompilerState(..),
 
        InstEnv, 
 
-               -- Provenance
+       GlobalRdrEnv, RdrAvailInfo,
+
+       -- Provenance
        Provenance(..), ImportReason(..), PrintUnqualified,
-        pprProvenance, hasBetterProv
+        pprNameProvenance, hasBetterProv
 
     ) where
 
@@ -25,7 +30,8 @@ module HscTypes (
 
 import Name            ( Name, NameEnv, NamedThing,
                          unitNameEnv, extendNameEnv, plusNameEnv, 
-                         lookupNameEnv, emptyNameEnv, getName, nameModule )
+                         lookupNameEnv, emptyNameEnv, getName, nameModule,
+                         nameSrcLoc )
 import Module          ( Module, ModuleName,
                          extendModuleEnv, lookupModuleEnv )
 import Class           ( Class )
@@ -50,6 +56,8 @@ import NameSet                ( NameSet )
 import Type            ( Type )
 import VarSet          ( TyVarSet )
 import Panic           ( panic )
+import Outputable
+import SrcLoc          ( SrcLoc, isGoodSrcLoc )
 \end{code}
 
 %************************************************************************
@@ -287,13 +295,13 @@ data WhatsImported name  = NothingAtAll                           -- The module is below us in the
 \begin{code}
 data PersistentCompilerState 
    = PCS {
-        pcsPST :: PackageSymbolTable,          -- Domain = non-home-package modules
-                                               --   except that the InstEnv components is empty
-       pcsInsts :: InstEnv,                    -- The total InstEnv accumulated from all
-                                               --   the non-home-package modules
-       pcsRules :: RuleEnv,                    -- Ditto RuleEnv
+        pcs_PST :: PackageSymbolTable, -- Domain = non-home-package modules
+                                       --   except that the InstEnv components is empty
+       pcs_insts :: InstEnv,           -- The total InstEnv accumulated from all
+                                       --   the non-home-package modules
+       pcs_rules :: RuleEnv,           -- Ditto RuleEnv
 
-        pcsPRS :: PersistentRenamerState
+        pcs_PRS :: PersistentRenamerState
      }
 \end{code}
 
@@ -304,7 +312,7 @@ It contains:
   * A name supply, which deals with allocating unique names to
     (Module,OccName) original names, 
  
-  * An accumulated InstEnv from all the modules in pcsPST
+  * An accumulated InstEnv from all the modules in pcs_PST
     The point is that we don't want to keep recreating it whenever
     we compile a new module.  The InstEnv component of pcPST is empty.
     (This means we might "see" instances that we shouldn't "really" see;
@@ -386,16 +394,16 @@ data CompResult
 -- generate Linkables.
 
 data HscResult
-   = HscOK   ModDetails                -- new details (HomeSymbolTable additions)
-            (Maybe ModIFace)           -- new iface (if any compilation was done)
-            (Maybe String)             -- generated stub_h
-            (Maybe String)             -- generated stub_c
-             PersistentCompilerState   -- updated PCS
-             [SDoc]                    -- warnings
+   = HscOK   ModDetails             -- new details (HomeSymbolTable additions)
+            (Maybe ModIFace)        -- new iface (if any compilation was done)
+            (Maybe String)          -- generated stub_h filename (in /tmp)
+            (Maybe String)          -- generated stub_c filename (in /tmp)
+             PersistentCompilerState -- updated PCS
+             [SDoc]                  -- warnings
 
-   | HscErrs PersistentCompilerState   -- updated PCS
-             [SDoc]                    -- errors
-             [SDoc]                    -- warnings
+   | HscErrs PersistentCompilerState -- updated PCS
+             [SDoc]                  -- errors
+             [SDoc]                  -- warnings
 
        
 -- These two are only here to avoid recursion between CmCompile and
@@ -432,6 +440,16 @@ data Provenance
        ImportReason
        PrintUnqualified
 
+{-
+Moved here from Name.
+pp_prov (LocalDef _ Exported)          = char 'x'
+pp_prov (LocalDef _ NotExported)       = char 'l'
+pp_prov (NonLocalDef ImplicitImport _) = char 'j'
+pp_prov (NonLocalDef (UserImport _ _ True ) _) = char 'I'      -- Imported by name
+pp_prov (NonLocalDef (UserImport _ _ False) _) = char 'i'      -- Imported by ..
+pp_prov SystemProv                    = char 's'
+-}
+
 data ImportReason
   = UserImport Module SrcLoc Bool      -- Imported from module M on line L
                                        -- Note the M may well not be the defining module
@@ -464,8 +482,8 @@ hasBetterProv (NonLocalDef (UserImport _ _ _   ) _) (NonLocalDef ImplicitImport
 hasBetterProv _                                            _                              = False
 
 pprNameProvenance :: Name -> Provenance -> SDoc
-pprProvenance name LocalDef           = ptext SLIT("defined at") <+> ppr (nameSrcLoc name)
-pprProvenance name (NonLocalDef why _) = sep [ppr_reason why, 
+pprNameProvenance name LocalDef               = ptext SLIT("defined at") <+> ppr (nameSrcLoc name)
+pprNameProvenance name (NonLocalDef why _) = sep [ppr_reason why, 
                                              nest 2 (parens (ppr_defn (nameSrcLoc name)))]
 
 ppr_reason ImplicitImport        = ptext SLIT("implicitly imported")