aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Waern <david.waern@gmail.com>2008-07-12 16:48:28 +0000
committerDavid Waern <david.waern@gmail.com>2008-07-12 16:48:28 +0000
commit32868490786d0328c59097915d5c56d3220d2a86 (patch)
treefa30f28e9f8bd9632a496b2917168f0d4f7a6c70
parentb32cad20b4e8c6c187ed2244d4fd79d0a6b6511b (diff)
Stop using the map from exported names to declarations
During creation of the interface, we were using two maps: one from exported names to declarations, and one from all defined names in the module to declarations. The first contained subordinate names while the second one didn't. The first map was never used to look up names not defined in the associated module, so if we add subordinate names to the second map, we could use it everywhere. That's that this patch does. This simplifies code because we don't have to pass around two maps everywhere. We now store the map from locally defined things in the interface structure instead of the one from exported names.
-rw-r--r--src/Haddock/Interface/Create.hs21
-rw-r--r--src/Haddock/Types.hs2
2 files changed, 11 insertions, 12 deletions
diff --git a/src/Haddock/Interface/Create.hs b/src/Haddock/Interface/Create.hs
index 1b6721e0..60d657c0 100644
--- a/src/Haddock/Interface/Create.hs
+++ b/src/Haddock/Interface/Create.hs
@@ -60,8 +60,8 @@ createInterface ghcMod flags modMap = do
subNames = allSubNames group
localNames = entityNames_ ++ subNames
subMap = mkSubMap group
- expDeclMap = mkDeclMap (ghcExportedNames ghcMod) group
- localDeclMap = mkDeclMap entityNames_ group
+-- declMap = mkDeclMap entityNames_ group
+ declMap = mkDeclMap localNames group
docMap = mkDocMap group
ignoreExps = Flag_IgnoreAllExports `elem` flags
exportedNames = ghcExportedNames ghcMod
@@ -69,10 +69,10 @@ createInterface ghcMod flags modMap = do
visibleNames <- mkVisibleNames mod modMap localNames
(ghcNamesInScope ghcMod)
- subMap exports opts localDeclMap
+ subMap exports opts declMap
exportItems <- mkExportItems modMap mod (ghcExportedNames ghcMod)
- expDeclMap localDeclMap subMap entities
+ declMap subMap entities
opts exports ignoreExps docMap
-- prune the export list to just those declarations that have
@@ -98,7 +98,7 @@ createInterface ghcMod flags modMap = do
ifaceEnv = origEnv,
ifaceExports = exportedNames,
ifaceVisibleExports = visibleNames,
- ifaceExportedDeclMap = expDeclMap,
+ ifaceDeclMap = declMap,
ifaceInstances = ghcInstances ghcMod
}
@@ -344,7 +344,6 @@ mkExportItems
:: ModuleMap
-> Module -- this module
-> [Name] -- exported names (orig)
- -> Map Name (LHsDecl Name) -- maps exported names to declarations
-> Map Name (LHsDecl Name) -- maps local names to declarations
-> Map Name [Name] -- sub-map for this module
-> [Entity] -- entities in the current module
@@ -354,7 +353,7 @@ mkExportItems
-> Map Name (HsDoc Name)
-> ErrMsgM [ExportItem Name]
-mkExportItems modMap this_mod exported_names exportedDeclMap localDeclMap sub_map entities
+mkExportItems modMap this_mod exported_names declMap sub_map entities
opts maybe_exps ignore_all_exports docMap
| isNothing maybe_exps || ignore_all_exports || OptIgnoreExports `elem` opts
= everything_local_exported
@@ -363,7 +362,7 @@ mkExportItems modMap this_mod exported_names exportedDeclMap localDeclMap sub_ma
return (concat exps)
where
everything_local_exported = -- everything exported
- return (fullContentsOfThisModule this_mod entities localDeclMap docMap)
+ return (fullContentsOfThisModule this_mod entities declMap docMap)
packageId = modulePackageId this_mod
@@ -393,7 +392,7 @@ mkExportItems modMap this_mod exported_names exportedDeclMap localDeclMap sub_ma
| otherwise = allSubsOfName modMap t
fullContentsOf m
- | m == this_mod = return (fullContentsOfThisModule this_mod entities localDeclMap docMap)
+ | m == this_mod = return (fullContentsOfThisModule this_mod entities declMap docMap)
| otherwise =
case Map.lookup m modMap of
Just iface
@@ -405,10 +404,10 @@ mkExportItems modMap this_mod exported_names exportedDeclMap localDeclMap sub_ma
findDecl :: Name -> (Maybe (LHsDecl Name), Maybe (HsDoc Name))
findDecl n | not (isExternalName n) = error "This shouldn't happen"
findDecl n
- | m == this_mod = (Map.lookup n exportedDeclMap, Map.lookup n docMap)
+ | m == this_mod = (Map.lookup n declMap, Map.lookup n docMap)
| otherwise =
case Map.lookup m modMap of
- Just iface -> (Map.lookup n (ifaceExportedDeclMap iface),
+ Just iface -> (Map.lookup n (ifaceDeclMap iface),
Map.lookup n (ifaceDocMap iface))
Nothing -> (Nothing, Nothing)
where
diff --git a/src/Haddock/Types.hs b/src/Haddock/Types.hs
index 1d63928e..f120bc85 100644
--- a/src/Haddock/Types.hs
+++ b/src/Haddock/Types.hs
@@ -129,7 +129,7 @@ data Interface = Interface {
-- | The Haddock options for this module (prune, ignore-exports, etc)
ifaceOptions :: [DocOption],
- ifaceExportedDeclMap :: Map Name (LHsDecl Name),
+ ifaceDeclMap :: Map Name (LHsDecl Name),
ifaceDocMap :: Map Name (HsDoc Name),
ifaceRnDocMap :: Map Name (HsDoc DocName),