Commit e0445ffa authored by simonpj's avatar simonpj

[project @ 2002-10-24 14:17:46 by simonpj]

------------------------------------------
	1. New try and module and package dependencies
	2. OrigNameCache always contains final info
	------------------------------------------

These things nearly complete sorting out the incremental
linking problem that started us off!

1. This commit separates two kinds of information:

  (a) HscTypes.Dependencies:
	What (i)  home-package modules, and
	     (ii) other packages
      this module depends on, transitively.

      That is, to link the module, it should be enough
      to link the dependent modules and packages (plus
      any C stubs etc).

      Along with this info we record whether the dependent module
      is (a) a boot interface or (b) an orphan module.  So in
      fact (i) can contain non-home-package modules, namely the
      orphan ones in other packages (sigh).

  (b) HscTypes.Usage:
      What version of imported things were used to
      actually compile the module.  This info is used for
      recompilation control only.



2. The Finder now returns a correct Module (incl package indicator)
first time, so we can install the absolutely final Name in the
OrigNameCache when we first come across an occurrence of that name,
even if it's only an occurrence in an unfolding in some other interface
file.  This is much tidier.

As a result Module.lhs is much cleaner
	No DunnoYet
	No mkVanillaModule
ALl very joyful stuff.
parent 04a63774
......@@ -56,9 +56,8 @@ module Module
, moduleString -- :: Module -> EncodedString
, moduleUserString -- :: Module -> UserString
, mkVanillaModule -- :: ModuleName -> Module
, isVanillaModule -- :: Module -> Bool
, mkPrelModule -- :: UserString -> Module
, mkBasePkgModule -- :: UserString -> Module
, mkThPkgModule -- :: UserString -> Module
, mkHomeModule -- :: ModuleName -> Module
, isHomeModule -- :: Module -> Bool
, mkPackageModule -- :: ModuleName -> Module
......@@ -84,7 +83,7 @@ module Module
#include "HsVersions.h"
import OccName
import Outputable
import Packages ( PackageName, preludePackage )
import Packages ( PackageName, basePackage, thPackage )
import CmdLineOpts ( opt_InPackage )
import FastString ( FastString )
import Unique ( Uniquable(..) )
......@@ -118,24 +117,13 @@ renamer href here.)
\begin{code}
data Module = Module ModuleName !PackageInfo
instance Binary Module where
put_ bh (Module m p) = put_ bh m
get bh = do m <- get bh; return (Module m DunnoYet)
data PackageInfo
= ThisPackage -- A module from the same package
-- as the one being compiled
| AnotherPackage -- A module from a different package
| DunnoYet -- This is used when we don't yet know
-- Main case: we've come across Foo.x in an interface file
-- but we havn't yet opened Foo.hi. We need a Name for Foo.x
-- Later on (in RnEnv.newTopBinder) we'll update the cache
-- to have the right PackageName
packageInfoPackage :: PackageInfo -> PackageName
packageInfoPackage ThisPackage = opt_InPackage
packageInfoPackage DunnoYet = FSLIT("<?>")
packageInfoPackage AnotherPackage = FSLIT("<pkg>")
instance Outputable PackageInfo where
......@@ -274,13 +262,21 @@ pprModule (Module mod p) = getPprStyle $ \ sty ->
\begin{code}
mkPrelModule :: ModuleName -> Module
mkPrelModule mod_nm
mkBasePkgModule :: ModuleName -> Module
mkBasePkgModule mod_nm
= Module mod_nm pack_info
where
pack_info
| opt_InPackage == basePackage = ThisPackage
| otherwise = AnotherPackage
mkThPkgModule :: ModuleName -> Module
mkThPkgModule mod_nm
= Module mod_nm pack_info
where
pack_info
| opt_InPackage == preludePackage = ThisPackage
| otherwise = AnotherPackage
| opt_InPackage == thPackage = ThisPackage
| otherwise = AnotherPackage
mkHomeModule :: ModuleName -> Module
mkHomeModule mod_nm = Module mod_nm ThisPackage
......@@ -292,16 +288,6 @@ isHomeModule _ = False
mkPackageModule :: ModuleName -> Module
mkPackageModule mod_nm = Module mod_nm AnotherPackage
-- Used temporarily when we first come across Foo.x in an interface
-- file, but before we've opened Foo.hi.
-- (Until we've opened Foo.hi we don't know what the Package is.)
mkVanillaModule :: ModuleName -> Module
mkVanillaModule name = Module name DunnoYet
isVanillaModule :: Module -> Bool
isVanillaModule (Module nm DunnoYet) = True
isVanillaModule _ = False
moduleString :: Module -> EncodedString
moduleString (Module (ModuleName fs) _) = unpackFS fs
......
......@@ -34,7 +34,7 @@ module Name (
#include "HsVersions.h"
import OccName -- All of it
import Module ( Module, ModuleName, moduleName, mkVanillaModule, isHomeModule )
import Module ( Module, ModuleName, moduleName, isHomeModule )
import CmdLineOpts ( opt_Static )
import SrcLoc ( noSrcLoc, isWiredInLoc, wiredInSrcLoc, SrcLoc )
import Unique ( Unique, Uniquable(..), getKey, pprUnique )
......@@ -177,11 +177,11 @@ mkInternalName uniq occ loc = Name { n_uniq = uniq, n_sort = Internal, n_occ = o
mkExternalName :: Unique -> Module -> OccName -> SrcLoc -> Name
mkExternalName uniq mod occ loc = Name { n_uniq = uniq, n_sort = External mod,
n_occ = occ, n_loc = loc }
n_occ = occ, n_loc = loc }
mkKnownKeyExternalName :: ModuleName -> OccName -> Unique -> Name
mkKnownKeyExternalName :: Module -> OccName -> Unique -> Name
mkKnownKeyExternalName mod occ uniq
= mkExternalName uniq (mkVanillaModule mod) occ noSrcLoc
= mkExternalName uniq mod occ noSrcLoc
mkWiredInName :: Module -> OccName -> Unique -> Name
mkWiredInName mod occ uniq = mkExternalName uniq mod occ wiredInSrcLoc
......
......@@ -15,7 +15,7 @@ import HscTypes ( ModGuts(..), ModGuts, HscEnv(..), ExternalPackageState(..),
import HsSyn ( MonoBinds, RuleDecl(..), RuleBndr(..),
HsExpr(..), HsBinds(..), MonoBinds(..) )
import TcHsSyn ( TypecheckedRuleDecl, TypecheckedHsExpr )
import TcRnTypes ( TcGblEnv(..), ImportAvails(imp_mods) )
import TcRnTypes ( TcGblEnv(..), ImportAvails(..) )
import MkIface ( mkUsageInfo )
import Id ( Id )
import CoreSyn
......@@ -89,9 +89,11 @@ deSugar hsc_env pcs
(printDump (ppr_ds_rules ds_rules))
; let
deps = (moduleEnvElts (dep_mods imports), dep_pkgs imports)
mod_guts = ModGuts {
mg_module = mod,
mg_exports = exports,
mg_deps = deps,
mg_usages = mkUsageInfo hsc_env eps imports usages,
mg_dir_imps = [m | (m,_) <- moduleEnvElts (imp_mods imports)],
mg_rdr_env = rdr_env,
......
This diff is collapsed.
......@@ -18,7 +18,7 @@ module HsDecls (
tyClDeclName, tyClDeclNames, tyClDeclTyVars,
isClassDecl, isSynDecl, isDataDecl, isIfaceSigDecl,
isTypeOrClassDecl, countTyClDecls,
isSourceInstDecl, ifaceRuleDeclName,
isSourceInstDecl, instDeclDFun, ifaceRuleDeclName,
conDetailsTys,
collectRuleBndrSigTys, isSrcRule
) where
......@@ -649,6 +649,9 @@ data InstDecl name
isSourceInstDecl :: InstDecl name -> Bool
isSourceInstDecl (InstDecl _ _ _ maybe_dfun _) = isNothing maybe_dfun
instDeclDFun :: InstDecl name -> Maybe name
instDeclDFun (InstDecl _ _ _ df _) = df -- A Maybe, but that's ok
\end{code}
\begin{code}
......
......@@ -31,7 +31,7 @@ import Name ( nameModule, nameOccName, isExternalName, isInternalName, NamedThi
import Subst ( substTyWith )
import Module ( Module, PackageName, ModuleName, moduleName,
modulePackage, preludePackage,
modulePackage, basePackage,
isHomeModule, isVanillaModule,
pprModuleName, mkHomeModule, mkModuleName
)
......@@ -168,7 +168,7 @@ importsName env n
importsPrelude | inPrelude = addModuleImpInfo (mkModuleName "PrelGHC")
| otherwise = addPackageImpInfo preludePackage
| otherwise = addPackageImpInfo basePackage
importsType :: IlxEnv -> Type -> ImportsInfo -> ImportsInfo
......@@ -1465,7 +1465,7 @@ nameReference env n
-- gets things working for the scenario "standard library linked as one
-- assembly with multiple modules + a one module program running on top of this"
-- Same applies to all other mentions of Vailla modules in this file
| isVanillaModule (nameModule n) && not inPrelude = preludePackageReference
| isVanillaModule (nameModule n) && not inPrelude = basePackageReference
| isVanillaModule (nameModule n) && inPrelude = moduleNameReference (moduleName (nameModule n))
-- end hack
| otherwise = packageReference (modulePackage (nameModule n))
......@@ -1477,13 +1477,13 @@ moduleReference env m
| ilxEnvModule env == m = text ""
| isHomeModule m = moduleNameReference (moduleName m)
-- See hack above
| isVanillaModule m && not inPrelude = preludePackageReference
| isVanillaModule m && not inPrelude = basePackageReference
| isVanillaModule m && inPrelude = moduleNameReference (moduleName m)
-- end hack
| otherwise = packageReference (modulePackage m)
preludePackageReference = packageReference preludePackage
inPrelude = preludePackage == opt_InPackage
basePackageReference = packageReference basePackage
inPrelude = basePackage == opt_InPackage
------------------------------------------------
-- This code is copied from absCSyn/CString.lhs,
......@@ -1693,13 +1693,13 @@ prelGHCReference :: IlxTyFrag
prelGHCReference env =
if ilxEnvModule env == mkHomeModule (mkModuleName "PrelGHC") then empty
else if inPrelude then moduleNameReference (mkModuleName "PrelGHC")
else preludePackageReference
else basePackageReference
prelBaseReference :: IlxTyFrag
prelBaseReference env =
if ilxEnvModule env == mkHomeModule (mkModuleName "PrelBase") then empty
else if inPrelude then moduleNameReference (mkModuleName "PrelBase")
else preludePackageReference
else basePackageReference
repThread = ilxType "class [mscorlib]System.Threading.Thread /* ThreadId# */ "
repByteArray = ilxType "unsigned int8[] /* ByteArr# */ "
......
......@@ -269,12 +269,13 @@ instance Binary ModIface where
put_ bh iface = do
build_tag <- readIORef v_Build_tag
put_ bh (show opt_HiVersion ++ build_tag)
p <- put_ bh (mi_module iface)
p <- put_ bh (moduleName (mi_module iface))
put_ bh (mi_package iface)
put_ bh (vers_module (mi_version iface))
put_ bh (mi_orphan iface)
-- no: mi_boot
lazyPut bh (map importVersionNameToOccName (mi_usages iface))
lazyPut bh (mi_deps iface)
lazyPut bh (map usageToOccName (mi_usages iface))
put_ bh (vers_exports (mi_version iface),
map exportItemToRdrExportItem (mi_exports iface))
put_ bh (declsToVersionedDecls (dcl_tycl (mi_decls iface))
......@@ -309,14 +310,9 @@ deprecsToIfaceDeprecs (DeprecSome env) = Just (Right (nameEnvElts env))
{-! for WhatsImported derive: Binary !-}
-- For binary interfaces we need to convert the ImportVersion Names to OccNames
importVersionNameToOccName :: ImportVersion Name -> ImportVersion OccName
importVersionNameToOccName (mod, orphans, boot, what)
= (mod, orphans, boot, fiddle_with what)
where fiddle_with NothingAtAll = NothingAtAll
fiddle_with (Everything v) = Everything v
fiddle_with (Specifically v ev ns rv) = Specifically v ev ns' rv
where ns' = [ (nameOccName n, v) | (n,v) <- ns ]
usageToOccName :: Usage Name -> Usage OccName
usageToOccName usg
= usg { usg_entities = [ (nameOccName n, v) | (n,v) <- usg_entities usg ] }
exportItemToRdrExportItem (mn, avails)
= (mn, map availInfoToRdrAvailInfo avails)
......@@ -370,6 +366,7 @@ instance Binary ParsedIface where
pkg_name <- get bh
module_ver <- get bh
orphan <- get bh
deps <- lazyGet bh
usages <- {-# SCC "bin_usages" #-} lazyGet bh
exports <- {-# SCC "bin_exports" #-} get bh
tycl_decls <- {-# SCC "bin_tycldecls" #-} get bh
......@@ -382,6 +379,7 @@ instance Binary ParsedIface where
pi_pkg = pkg_name,
pi_vers = module_ver,
pi_orphan = orphan,
pi_deps = deps,
pi_usages = usages,
pi_exports = exports,
pi_decls = tycl_decls,
......@@ -412,29 +410,23 @@ instance (Binary name) => Binary (GenAvailInfo name) where
ac <- get bh
return (AvailTC ab ac)
instance (Binary name) => Binary (WhatsImported name) where
put_ bh NothingAtAll = do
putByte bh 0
put_ bh (Everything aa) = do
putByte bh 1
put_ bh aa
put_ bh (Specifically ab ac ad ae) = do
putByte bh 2
put_ bh ab
put_ bh ac
put_ bh ad
put_ bh ae
instance (Binary name) => Binary (Usage name) where
put_ bh usg = do
put_ bh (usg_name usg)
put_ bh (usg_mod usg)
put_ bh (usg_exports usg)
put_ bh (usg_entities usg)
put_ bh (usg_rules usg)
get bh = do
h <- getByte bh
case h of
0 -> do return NothingAtAll
1 -> do aa <- get bh
return (Everything aa)
_ -> do ab <- get bh
ac <- get bh
ad <- get bh
ae <- get bh
return (Specifically ab ac ad ae)
nm <- get bh
mod <- get bh
exps <- get bh
ents <- get bh
rules <- get bh
return (Usage { usg_name = nm, usg_mod = mod,
usg_exports = exps, usg_entities = ents,
usg_rules = rules })
instance Binary Activation where
put_ bh NeverActive = do
......
......@@ -1176,7 +1176,7 @@ staticLink o_files = do
-- opts from -optl-<blah>
extra_ld_opts <- getStaticOpts v_Opt_l
[rts_pkg, std_pkg] <- getPackageDetails [rtsPackage, preludePackage]
[rts_pkg, std_pkg] <- getPackageDetails [rtsPackage, basePackage]
let extra_os = if static || no_hs_main
then []
......@@ -1252,7 +1252,7 @@ doMkDLL o_files = do
-- opts from -optdll-<blah>
extra_ld_opts <- getStaticOpts v_Opt_dll
[rts_pkg, std_pkg] <- getPackageDetails [rtsPackage, preludePackage]
[rts_pkg, std_pkg] <- getPackageDetails [rtsPackage, basePackage]
let extra_os = if static || no_hs_main
then []
......
-----------------------------------------------------------------------------
-- $Id: DriverState.hs,v 1.83 2002/10/17 14:26:18 simonmar Exp $
-- $Id: DriverState.hs,v 1.84 2002/10/24 14:17:49 simonpj Exp $
--
-- Settings for the driver
--
......@@ -18,7 +18,7 @@ import Packages ( PackageConfig(..), PackageConfigMap,
PackageName, mkPackageName, packageNameString,
packageDependents,
mungePackagePaths, emptyPkgMap, extendPkgMap, lookupPkg,
preludePackage, rtsPackage, haskell98Package )
basePackage, rtsPackage, haskell98Package )
import CmdLineOpts
import DriverPhases
import DriverUtil
......@@ -489,7 +489,7 @@ getPackages :: IO [PackageName]
getPackages = readIORef v_Packages
initPackageList = [haskell98Package,
preludePackage,
basePackage,
rtsPackage]
addPackage :: String -> IO ()
......
......@@ -40,6 +40,7 @@ import Parser
import Lex ( ParseResult(..), ExtFlags(..), mkPState )
import SrcLoc ( mkSrcLoc )
import TcRnDriver ( checkOldIface, tcRnModule, tcRnExtCore, tcRnIface )
import RnEnv ( extendOrigNameCache )
import Rules ( emptyRuleBase )
import PrelInfo ( wiredInThingEnv, wiredInThings, knownKeyNames )
import PrelRules ( builtinRules )
......@@ -57,7 +58,7 @@ import SimplStg ( stg2stg )
import CodeGen ( codeGen )
import CodeOutput ( codeOutput )
import Module ( ModuleName, moduleName )
import Module ( ModuleName, moduleName, emptyModuleEnv )
import CmdLineOpts
import DriverPhases ( isExtCore_file )
import ErrUtils ( dumpIfSet_dyn, showPass, printError )
......@@ -692,7 +693,6 @@ initExternalPackageState
eps_insts = (emptyBag, 0),
eps_inst_gates = emptyNameSet,
eps_rules = foldr add_rule (emptyBag, 0) builtinRules,
eps_imp_mods = emptyFM,
eps_PIT = emptyPackageIfaceTable,
eps_PTE = wiredInThingEnv,
......@@ -708,11 +708,11 @@ initExternalPackageState
rdr_name = nameRdrName name
gate_fn vis_fn = vis_fn name -- Load the rule whenever name is visible
initOrigNames :: FiniteMap (ModuleName,OccName) Name
initOrigNames :: OrigNameCache
initOrigNames
= grab knownKeyNames `plusFM` grab (map getName wiredInThings)
where
grab names = foldl add emptyFM names
add env name
= addToFM env (moduleName (nameModule name), nameOccName name) name
= insert knownKeyNames $
insert (map getName wiredInThings) $
emptyModuleEnv
where
insert names env = foldl extendOrigNameCache env names
\end{code}
......@@ -32,8 +32,7 @@ module HscTypes (
extendTypeEnvList, extendTypeEnvWithIds,
typeEnvElts, typeEnvClasses, typeEnvTyCons, typeEnvIds,
ImportedModuleInfo, WhetherHasOrphans, ImportVersion, WhatsImported(..),
IsBootInterface, DeclsMap,
WhetherHasOrphans, IsBootInterface, DeclsMap, Usage(..), Dependencies,
IfaceInsts, IfaceRules, GatedDecl, GatedDecls, GateFn,
NameCache(..), OrigNameCache, OrigIParamCache,
Avails, availsToNameSet, availName, availNames,
......@@ -83,14 +82,15 @@ import Class ( Class, classSelIds )
import TyCon ( TyCon, isNewTyCon, tyConGenIds, tyConSelIds, tyConDataCons_maybe )
import Type ( TyThing(..), isTyClThing )
import DataCon ( dataConWorkId, dataConWrapId )
import Packages ( PackageName, preludePackage )
import Packages ( PackageName, basePackage )
import CmdLineOpts ( DynFlags )
import BasicTypes ( Version, initialVersion, IPName,
Fixity, FixitySig(..), defaultFixity )
import HsSyn ( DeprecTxt, TyClDecl, InstDecl, RuleDecl,
tyClDeclName, ifaceRuleDeclName, tyClDeclNames )
import HsSyn ( DeprecTxt, TyClDecl, InstDecl, RuleDecl,
tyClDeclName, ifaceRuleDeclName, tyClDeclNames,
instDeclDFun )
import RnHsSyn ( RenamedTyClDecl, RenamedRuleDecl, RenamedInstDecl )
import CoreSyn ( IdCoreRule )
......@@ -193,15 +193,20 @@ data ModIface
= ModIface {
mi_module :: !Module,
mi_package :: !PackageName, -- Which package the module comes from
mi_version :: !VersionInfo, -- Module version number
mi_version :: !VersionInfo, -- Version info for everything in this module
mi_orphan :: !WhetherHasOrphans, -- Whether this module has orphans
mi_boot :: !IsBootInterface, -- Read from an hi-boot file?
mi_usages :: [ImportVersion Name],
mi_deps :: Dependencies,
-- This is consulted for directly-imported modules, but
-- not for anything else
mi_usages :: [Usage Name],
-- Usages; kept sorted so that it's easy to decide
-- whether to write a new iface file (changing usages
-- doesn't affect the version of this module)
-- NOT STRICT! we read this field lazily from the interface file
-- It is *only* consulted by the recompilation checker
mi_exports :: ![ExportItem],
-- What it exports Kept sorted by (mod,occ), to make
......@@ -229,8 +234,6 @@ data ModDetails
md_rules :: ![IdCoreRule] -- Domain may include Ids from other modules
}
-- A ModGuts is carried through the compiler, accumulating stuff as it goes
-- There is only one ModGuts at any time, the one for the module
-- being compiled right now. Once it is compiled, a ModIface and
......@@ -239,10 +242,11 @@ data ModDetails
data ModGuts
= ModGuts {
mg_module :: !Module,
mg_exports :: !Avails, -- What it exports
mg_usages :: ![ImportVersion Name], -- What it imports, directly or otherwise
-- ...exactly as in ModIface
mg_dir_imps :: ![Module], -- Directly imported modules
mg_exports :: !Avails, -- What it exports
mg_deps :: !Dependencies, -- What is below it, directly or otherwise
mg_dir_imps :: ![Module], -- Directly-imported modules; used to
-- generate initialisation code
mg_usages :: ![Usage Name], -- Version info for what it needed
mg_rdr_env :: !GlobalRdrEnv, -- Top-level lexical environment
mg_fix_env :: !FixityEnv, -- Fixity env, for things declared in this module
......@@ -306,22 +310,25 @@ data IfaceDecls = IfaceDecls { dcl_tycl :: [RenamedTyClDecl], -- Sorted
dcl_insts :: [RenamedInstDecl] } -- Unsorted
mkIfaceDecls :: [RenamedTyClDecl] -> [RenamedRuleDecl] -> [RenamedInstDecl] -> IfaceDecls
-- Sort to put them in canonical order for version comparison
mkIfaceDecls tycls rules insts
= IfaceDecls { dcl_tycl = sortLt lt_tycl tycls,
dcl_rules = sortLt lt_rule rules,
dcl_insts = insts }
dcl_insts = sortLt lt_inst insts }
where
d1 `lt_tycl` d2 = tyClDeclName d1 < tyClDeclName d2
r1 `lt_rule` r2 = ifaceRuleDeclName r1 < ifaceRuleDeclName r2
i1 `lt_inst` i2 = instDeclDFun i1 < instDeclDFun i2
\end{code}
\begin{code}
emptyModIface :: Module -> ModIface
emptyModIface mod
= ModIface { mi_module = mod,
mi_package = preludePackage, -- XXX fully bogus
mi_package = basePackage, -- XXX fully bogus
mi_version = initialVersionInfo,
mi_usages = [],
mi_deps = ([], []),
mi_orphan = False,
mi_boot = False,
mi_exports = [],
......@@ -353,7 +360,8 @@ data ParsedIface
pi_pkg :: PackageName,
pi_vers :: Version, -- Module version number
pi_orphan :: WhetherHasOrphans, -- Whether this module has orphans
pi_usages :: [ImportVersion OccName], -- Usages
pi_deps :: Dependencies, -- What it depends on
pi_usages :: [Usage OccName], -- Usages
pi_exports :: (Version, [RdrExportItem]), -- Exports
pi_decls :: [(Version, TyClDecl RdrName)], -- Local definitions
pi_fixity :: [FixitySig RdrName], -- Local fixity declarations,
......@@ -604,33 +612,30 @@ type WhetherHasOrphans = Bool
-- * a transformation rule in a module other than the one defining
-- the function in the head of the rule.
type IsBootInterface = Bool
type ImportVersion name = (ModuleName, WhetherHasOrphans, IsBootInterface, WhatsImported name)
data WhatsImported name = NothingAtAll -- The module is below us in the
-- hierarchy, but we import nothing
-- Used for orphan modules, so they appear
-- in the usage list
| Everything Version -- Used for modules from other packages;
-- we record only the module's version number
| Specifically
Version -- Module version
(Maybe Version) -- Export-list version, if we depend on it
[(name,Version)] -- List guaranteed non-empty
Version -- Rules version
type IsBootInterface = Bool
deriving( Eq )
-- 'Specifically' doesn't let you say "I imported f but none of the rules in
-- Dependency info about modules and packages below this one
-- in the import hierarchy. See TcRnTypes.ImportAvails for details.
--
-- Invariant: the dependencies of a module M never includes M
type Dependencies
= ([(ModuleName, WhetherHasOrphans, IsBootInterface)], [PackageName])
data Usage name
= Usage { usg_name :: ModuleName, -- Name of the module
usg_mod :: Version, -- Module version
usg_exports :: Maybe Version, -- Export-list version, if we depend on it
usg_entities :: [(name,Version)], -- Sorted by occurrence name
usg_rules :: Version -- Rules version
} deriving( Eq )
-- This type doesn't let you say "I imported f but none of the rules in
-- the module". If you use anything in the module you get its rule version
-- So if the rules change, you'll recompile, even if you don't use them.
-- This is easy to implement, and it's safer: you might not have used the rules last
-- time round, but if someone has added a new rule you might need it this time
-- The export list field is (Just v) if we depend on the export list:
-- we imported the module without saying exactly what we imported
-- i.e. we imported the module without saying exactly what we imported
-- We need to recompile if the module exports changes, because we might
-- now have a name clash in the importing module.
\end{code}
......@@ -674,11 +679,6 @@ data ExternalPackageState
-- * Fixities
-- * Deprecations
eps_imp_mods :: !ImportedModuleInfo,
-- Modules that we know something about, because they are mentioned
-- in interface files, BUT which we have not loaded yet.
-- No module is both in here and in the PIT
eps_PTE :: !PackageTypeEnv, -- Domain = external-package modules
eps_inst_env :: !PackageInstEnv, -- The total InstEnv accumulated from
......@@ -730,20 +730,14 @@ data NameCache
-- Ensures that one implicit parameter name gets one unique
}
type OrigNameCache = FiniteMap (ModuleName,OccName) Name
type OrigIParamCache = FiniteMap (IPName RdrName) (IPName Name)
\end{code}
type OrigNameCache = ModuleEnv (Module, OccNameCache)
-- Maps a module *name* to a Module,
-- plus the OccNameEnv fot that module
type OccNameCache = FiniteMap OccName Name
-- Maps the OccName to a Name
-- A FiniteMap because OccNames have a Namespace/Faststring pair
@ImportedModuleInfo@ contains info ONLY about modules that have not yet
been loaded into the iPIT. These modules are mentioned in interfaces we've
already read, so we know a tiny bit about them, but we havn't yet looked
at the interface file for the module itself. It needs to persist across
invocations of the renamer, at least from Rename.checkOldIface to Rename.renameSource.
And there's no harm in it persisting across multiple compilations.
\begin{code}
type ImportedModuleInfo
= FiniteMap ModuleName (WhetherHasOrphans, IsBootInterface)
type OrigIParamCache = FiniteMap (IPName RdrName) (IPName Name)
\end{code}
A DeclsMap contains a binding for each Name in the declaration
......
This diff is collapsed.
......@@ -12,7 +12,7 @@ module Packages (
PackageName, -- Instance of Outputable
mkPackageName, packageNameString,
preludePackage, rtsPackage, haskell98Package, -- :: PackageName
basePackage, rtsPackage, haskell98Package, thPackage, -- :: PackageName
PackageConfigMap, emptyPkgMap, extendPkgMap, lookupPkg
)
......@@ -60,10 +60,11 @@ mkPackageName = mkFastString
packageNameString :: PackageName -> String
packageNameString = unpackFS
rtsPackage, preludePackage, haskell98Package :: PackageName
preludePackage = FSLIT("base")
rtsPackage, basePackage, haskell98Package, thPackage :: PackageName
basePackage = FSLIT("base")
rtsPackage = FSLIT("rts")
haskell98Package = FSLIT("haskell98")
thPackage = FSLIT("haskell-src") -- Template Haskell libraries in here
packageDependents :: PackageConfig -> [PackageName]
-- Impedence matcher, because PackageConfig has Strings
......
......@@ -29,6 +29,7 @@ import BasicTypes ( isNeverActive )
import Name ( getOccName, nameOccName, mkInternalName, mkExternalName,
localiseName, isExternalName, nameSrcLoc
)
import RnEnv ( lookupOrigNameCache, newExternalName )
import NameEnv ( filterNameEnv )
import OccName ( TidyOccEnv, initTidyOccEnv, tidyOccName )
import Type ( tidyTopType )
......@@ -541,7 +542,7 @@ tidyTopName mod ns occ_env external name
-- Similarly, we must make sure it has a system-wide Unique, because
-- the byte-code generator builds a system-wide Name->BCO symbol table
| local && external = case lookupFM ns_names key of
| local && external = case lookupOrigNameCache ns_names mod occ' of
Just orig -> (ns, occ_env', orig)
Nothing -> (ns_w_global, occ_env', new_external_name)
-- If we want to externalise a currently-local name, check
......@@ -554,20 +555,17 @@ tidyTopName mod ns occ_env external name
global = isExternalName name
local = not global
internal = not external
loc = nameSrcLoc name
(occ_env', occ') = tidyOccName occ_env (nameOccName name)
key = (moduleName mod, occ')
ns_names = nsNames ns
ns_uniqs = nsUniqs ns
(us1, us2) = splitUniqSupply ns_uniqs
(us1, us2) = splitUniqSupply (nsUniqs ns)
uniq = uniqFromSupply us1
loc = nameSrcLoc name
new_local_name = mkInternalName uniq occ' loc
new_external_name = mkExternalName uniq mod occ' loc
new_local_name = mkInternalName uniq occ' loc
ns_w_local = ns { nsUniqs = us2 }
ns_w_global = ns { nsUniqs = us2, nsNames = addToFM ns_names key new_external_name }
(ns_w_global, new_external_name) = newExternalName ns mod occ' loc
------------ Worker --------------
......
{- -*-haskell-*-
-----------------------------------------------------------------------------
$Id: Parser.y,v 1.111 2002/10/23 14:30:01 simonpj Exp $
$Id: Parser.y,v 1.112 2002/10/24 14:17:50 simonpj Exp $
Haskell grammar.
......@@ -295,6 +295,7 @@ iface :: { ParsedIface }
pi_vers = 1, -- Module version
pi_orphan = False,
pi_exports = (1,[($2,mkIfaceExports $4)]),
pi_deps = ([],[]),
pi_usages = [],
pi_fixity = [],
pi_insts = [],
......
......@@ -4,8 +4,7 @@
\section[PrelNames]{Definitions of prelude modules and names}
The strings identify built-in prelude modules. They are
defined here so as to avod
Nota Bene: all Names defined in here should come from the base package
* ModuleNames for prelude modules,
e.g. pREL_BASE_Name :: ModuleName
......@@ -62,17 +61,10 @@ module PrelNames (
#include "HsVersions.h"
import Module ( ModuleName, mkPrelModule, mkHomeModule, mkModuleName,mkVanillaModule )
import OccName ( UserFS, dataName, tcName, clsName,
import Module ( ModuleName, mkBasePkgModule, mkHomeModule, mkModuleName )
import OccName ( UserFS, dataName, tcName, clsName, varName,
mkKindOccFS, mkOccFS
)
-- to avoid clashes with Meta.var we must make a local alias for OccName.varName
-- we do this by removing varName from the import of OccName above, making
-- a qualified instance of OccName and using OccNameAlias.varName where varName
-- ws previously used in this file.
import qualified OccName as OccNameAlias
import RdrName ( RdrName, nameRdrName, mkOrig, rdrNameOcc )
import Unique ( Unique, Uniquable(..), hasKey,
......@@ -100,7 +92,7 @@ import FastString
This *local* name is used by the interactive stuff
\begin{code}
itName uniq = mkInternalName uniq (mkOccFS OccNameAlias.varName FSLIT("it")) noSrcLoc
itName uniq = mkInternalName uniq (mkOccFS varName FSLIT("it")) noSrcLoc
\end{code}
\begin{code}
......@@ -285,18 +277,18 @@ aDDR_Name = mkModuleName "Addr"
gLA_EXTS_Name = mkModuleName "GHC.Exts"
gHC_PRIM = mkPrelModule gHC_PRIM_Name
pREL_BASE = mkPrelModule pREL_BASE_Name
pREL_ADDR = mkPrelModule pREL_ADDR_Name
pREL_PTR = mkPrelModule pREL_PTR_Name
pREL_STABLE = mkPrelModule pREL_STABLE_Name
pREL_IO_BASE = mkPrelModule pREL_IO_BASE_Name
pREL_PACK = mkPrelModule pREL_PACK_Name
pREL_ERR = mkPrelModule pREL_ERR_Name
pREL_NUM = mkPrelModule pREL_NUM_Name
pREL_REAL = mkPrelModule pREL_REAL_Name
pREL_FLOAT = mkPrelModule pREL_FLOAT_Name
pRELUDE = mkPrelModule pRELUDE_Name
gHC_PRIM = mkBasePkgModule gHC_PRIM_Name
pREL_BASE = mkBasePkgModule pREL_BASE_Name
pREL_ADDR = mkBasePkgModule pREL_ADDR_Name
pREL_PTR = mkBasePkgModule pREL_PTR_Name
pREL_STABLE = mkBasePkgModule pREL_STABLE_Name
pREL_IO_BASE = mkBasePkgModule pREL_IO_BASE_Name
pREL_PACK = mkBasePkgModule pREL_PACK_Name
pREL_ERR = mkBasePkgModule pREL_ERR_Name
pREL_NUM = mkBasePkgModule pREL_NUM_Name
pREL_REAL = mkBasePkgModule pREL_REAL_Name