Commit 653d17bd authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

Rename Package into Unit (2)

* rename PackageState into UnitState
* rename findWiredInPackages into findWiredInUnits
* rename lookupModuleInAll[Packages,Units]
* etc.
parent 55b4263e
......@@ -144,7 +144,7 @@ When GHC reads the package data base, it (internally only) pretends it has UnitI
`integer-wired-in` instead of the actual UnitId (which includes the version
number); just like for `base` and other packages, as described in
Note [Wired-in units] in GHC.Unit.Module. This is done in
GHC.Unit.State.findWiredInPackages.
GHC.Unit.State.findWiredInUnits.
-}
{-# LANGUAGE CPP #-}
......
......@@ -561,14 +561,14 @@ type PackageNameMap a = Map PackageName a
-- For now, something really simple, since we're not actually going
-- to use this for anything
unitDefines :: PackageState -> LHsUnit PackageName -> (PackageName, HsComponentId)
unitDefines :: UnitState -> LHsUnit PackageName -> (PackageName, HsComponentId)
unitDefines pkgstate (L _ HsUnit{ hsunitName = L _ pn@(PackageName fs) })
= (pn, HsComponentId pn (mkIndefUnitId pkgstate fs))
bkpPackageNameMap :: PackageState -> [LHsUnit PackageName] -> PackageNameMap HsComponentId
bkpPackageNameMap :: UnitState -> [LHsUnit PackageName] -> PackageNameMap HsComponentId
bkpPackageNameMap pkgstate units = Map.fromList (map (unitDefines pkgstate) units)
renameHsUnits :: PackageState -> PackageNameMap HsComponentId -> [LHsUnit PackageName] -> [LHsUnit HsComponentId]
renameHsUnits :: UnitState -> PackageNameMap HsComponentId -> [LHsUnit PackageName] -> [LHsUnit HsComponentId]
renameHsUnits pkgstate m units = map (fmap renameHsUnit) units
where
......
......@@ -63,7 +63,7 @@ type BaseName = String -- Basename of file
-- source, interface, and object files for that module live.
-- It does *not* know which particular package a module lives in. Use
-- Packages.lookupModuleInAllPackages for that.
-- Packages.lookupModuleInAllUnits for that.
-- -----------------------------------------------------------------------------
-- The finder's cache
......@@ -758,7 +758,7 @@ cantFindErr cannot_find _ dflags mod_name find_result
pp_sugg (SuggestVisible m mod o) = ppr m <+> provenance o
where provenance ModHidden = Outputable.empty
provenance (ModUnusable _) = Outputable.empty
provenance (ModOrigin{ fromOrigPackage = e,
provenance (ModOrigin{ fromOrigUnit = e,
fromExposedReexport = res,
fromPackageFlag = f })
| Just True <- e
......@@ -775,7 +775,7 @@ cantFindErr cannot_find _ dflags mod_name find_result
pp_sugg (SuggestHidden m mod o) = ppr m <+> provenance o
where provenance ModHidden = Outputable.empty
provenance (ModUnusable _) = Outputable.empty
provenance (ModOrigin{ fromOrigPackage = e,
provenance (ModOrigin{ fromOrigUnit = e,
fromHiddenReexport = rhs })
| Just False <- e
= parens (text "needs flag -package-id"
......
......@@ -1527,7 +1527,7 @@ upsweep mHscMessage old_hpt stable_mods cleanup sccs = do
upsweep' old_hpt1 done' mods (mod_index+1) nmods uids_to_check' done_holes'
-- | Return a list of instantiated units to type check from the PackageState.
-- | Return a list of instantiated units to type check from the UnitState.
--
-- Use explicit (instantiated) units as roots and also return their
-- instantiations that are themselves instantiations and so on recursively.
......
......@@ -254,7 +254,7 @@ import GHC.Unit.Module
import {-# SOURCE #-} GHC.Driver.Plugins
import {-# SOURCE #-} GHC.Driver.Hooks
import GHC.Builtin.Names ( mAIN )
import {-# SOURCE #-} GHC.Unit.State (PackageState, emptyPackageState, UnitDatabase, updateIndefUnitId)
import {-# SOURCE #-} GHC.Unit.State (UnitState, emptyUnitState, UnitDatabase, updateIndefUnitId)
import GHC.Driver.Phases ( Phase(..), phaseInputExt )
import GHC.Driver.Flags
import GHC.Driver.Ways
......@@ -617,7 +617,7 @@ data DynFlags = DynFlags {
-- *reverse* order that they're specified on the command line.
-- This is intended to be applied with the list of "initial"
-- package databases derived from @GHC_PACKAGE_PATH@; see
-- 'getPackageDbRefs'.
-- 'getUnitDbRefs'.
ignorePackageFlags :: [IgnorePackageFlag],
-- ^ The @-ignore-package@ flags from the command line.
......@@ -643,7 +643,7 @@ data DynFlags = DynFlags {
-- `initUnits` is called again, it doesn't reload the databases from
-- disk.
unitState :: PackageState,
unitState :: UnitState,
-- ^ Consolidated unit database built by 'initUnits' from the unit
-- databases in 'unitDatabases' and flags ('-ignore-package', etc.).
--
......@@ -1377,7 +1377,7 @@ defaultDynFlags mySettings llvmConfig =
trustFlags = [],
packageEnv = Nothing,
unitDatabases = Nothing,
unitState = emptyPackageState,
unitState = emptyUnitState,
ways = defaultWays mySettings,
buildTag = waysTag (defaultWays mySettings),
splitInfo = Nothing,
......
......@@ -9,7 +9,7 @@ data DynFlags
targetPlatform :: DynFlags -> Platform
pprUserLength :: DynFlags -> Int
unitState :: DynFlags -> PackageState
unitState :: DynFlags -> UnitState
unsafeGlobalDynFlags :: DynFlags
hasPprDebug :: DynFlags -> Bool
hasNoDebugOutput :: DynFlags -> Bool
......
......@@ -2023,12 +2023,12 @@ mkQualModule dflags mod
= False
| otherwise = True
where lookup = lookupModuleInAllPackages (unitState dflags) (moduleName mod)
where lookup = lookupModuleInAllUnits (unitState dflags) (moduleName mod)
-- | Creates a function for formatting packages based on two heuristics:
-- (1) don't qualify if the package in question is "main", and (2) only qualify
-- with a unit id if the package ID would be ambiguous.
mkQualPackage :: PackageState -> QueryQualifyPackage
mkQualPackage :: UnitState -> QueryQualifyPackage
mkQualPackage pkgs uid
| uid == mainUnit || uid == interactiveUnit
-- Skip the lookup if it's main, since it won't be in the package
......@@ -2045,7 +2045,7 @@ mkQualPackage pkgs uid
-- | A function which only qualifies package names if necessary; but
-- qualifies all other identifiers.
pkgQual :: PackageState -> PrintUnqualified
pkgQual :: UnitState -> PrintUnqualified
pkgQual pkgs = alwaysQualify { queryQualifyPackage = mkQualPackage pkgs }
{-
......
......@@ -244,7 +244,7 @@ lessUnsafeCoerce dflags context what = do
lookupRdrNameInModuleForPlugins :: HscEnv -> ModuleName -> RdrName
-> IO (Maybe (Name, ModIface))
lookupRdrNameInModuleForPlugins hsc_env mod_name rdr_name = do
-- First find the package the module resides in by searching exposed packages and home modules
-- First find the unit the module resides in by searching exposed units and home modules
found_module <- findPluginModule hsc_env mod_name
case found_module of
Found _ mod -> do
......
......@@ -231,7 +231,7 @@ check_inst sig_inst = do
-- | Return this list of requirement interfaces that need to be merged
-- to form @mod_name@, or @[]@ if this is not a requirement.
requirementMerges :: PackageState -> ModuleName -> [InstantiatedModule]
requirementMerges :: UnitState -> ModuleName -> [InstantiatedModule]
requirementMerges pkgstate mod_name =
fmap fixupModule $ fromMaybe [] (Map.lookup mod_name (requirementContext pkgstate))
where
......
......@@ -17,7 +17,7 @@ import GHC.Utils.Outputable
-- Where a module lives on the file system: the actual locations
-- of the .hs, .hi and .o files, if we have them.
--
-- For a module in another package, the ml_hs_file and ml_obj_file components of
-- For a module in another unit, the ml_hs_file and ml_obj_file components of
-- ModLocation are undefined.
--
-- The locations specified by a ModLocation may or may not
......@@ -40,7 +40,7 @@ data ModLocation
-- ^ Where the .o file is, whether or not it exists yet.
-- (might not exist either because the module hasn't
-- been compiled yet, or because it is part of a
-- package with a .a file)
-- unit with a .a file)
ml_hie_file :: FilePath
-- ^ Where the .hie file is, whether or not it exists
......
This diff is collapsed.
......@@ -4,10 +4,10 @@ import GHC.Prelude
import GHC.Data.FastString
import {-# SOURCE #-} GHC.Unit.Types (IndefUnitId, UnitId)
data PackageState
data UnitState
data UnitDatabase unit
emptyPackageState :: PackageState
mkIndefUnitId :: PackageState -> FastString -> IndefUnitId
displayUnitId :: PackageState -> UnitId -> Maybe String
updateIndefUnitId :: PackageState -> IndefUnitId -> IndefUnitId
emptyUnitState :: UnitState
mkIndefUnitId :: UnitState -> FastString -> IndefUnitId
displayUnitId :: UnitState -> UnitId -> Maybe String
updateIndefUnitId :: UnitState -> IndefUnitId -> IndefUnitId
......@@ -601,7 +601,7 @@ had used @-ignore-package@).
The affected packages are compiled with, e.g., @-this-unit-id base@, so that
the symbols in the object files have the unversioned unit id in their name.
Make sure you change 'GHC.Unit.State.findWiredInPackages' if you add an entry here.
Make sure you change 'GHC.Unit.State.findWiredInUnits' if you add an entry here.
For `integer-gmp`/`integer-simple` we also change the base name to
`integer-wired-in`, but this is fundamentally no different.
......
......@@ -3074,7 +3074,7 @@ showCmd str = do
liftIO $ putLogMsg dflags NoReason SevDump noSrcSpan msg
, action "breaks" $ showBkptTable
, action "context" $ showContext
, action "packages" $ showPackages
, action "packages" $ showUnits
, action "paths" $ showPaths
, action "language" $ showLanguages
, hidden "languages" $ showLanguages -- backwards compat
......@@ -3212,8 +3212,8 @@ pprStopped res =
where
mb_mod_name = moduleName <$> GHC.breakInfo_module <$> GHC.resumeBreakInfo res
showPackages :: GHC.GhcMonad m => m ()
showPackages = do
showUnits :: GHC.GhcMonad m => m ()
showUnits = do
dflags <- getDynFlags
let pkg_flags = packageFlags dflags
liftIO $ putStrLn $ showSDoc dflags $
......
......@@ -49,7 +49,7 @@ import GHC.Platform.Host
import GHC.Settings.Config
import GHC.Settings.Constants
import GHC.Driver.Types
import GHC.Unit.State ( pprPackages, pprPackagesSimple )
import GHC.Unit.State ( pprUnits, pprUnitsSimple )
import GHC.Driver.Phases
import GHC.Types.Basic ( failed )
import GHC.Driver.Session hiding (WarnReason(..))
......@@ -251,8 +251,8 @@ main' postLoadMode dflags0 args flagWarnings = do
---------------- Display configuration -----------
case verbosity dflags6 of
v | v == 4 -> liftIO $ dumpPackagesSimple dflags6
| v >= 5 -> liftIO $ dumpPackages dflags6
v | v == 4 -> liftIO $ dumpUnitsSimple dflags6
| v >= 5 -> liftIO $ dumpUnits dflags6
| otherwise -> return ()
liftIO $ initUniqSupply (initialUnique dflags6) (uniqueIncrement dflags6)
......@@ -272,7 +272,7 @@ main' postLoadMode dflags0 args flagWarnings = do
DoEval exprs -> ghciUI hsc_env dflags6 srcs $ Just $
reverse exprs
DoAbiHash -> abiHash (map fst srcs)
ShowPackages -> liftIO $ showPackages dflags6
ShowPackages -> liftIO $ showUnits dflags6
DoFrontend f -> doFrontend f srcs
DoBackpack -> doBackpack (map fst srcs)
......@@ -493,12 +493,12 @@ data PostLoadMode
| DoFrontend ModuleName -- ghc --frontend Plugin.Module
doMkDependHSMode, doMakeMode, doInteractiveMode,
doAbiHashMode, showPackagesMode :: Mode
doAbiHashMode, showUnitsMode :: Mode
doMkDependHSMode = mkPostLoadMode DoMkDependHS
doMakeMode = mkPostLoadMode DoMake
doInteractiveMode = mkPostLoadMode DoInteractive
doAbiHashMode = mkPostLoadMode DoAbiHash
showPackagesMode = mkPostLoadMode ShowPackages
showUnitsMode = mkPostLoadMode ShowPackages
showInterfaceMode :: FilePath -> Mode
showInterfaceMode fp = mkPostLoadMode (ShowInterface fp)
......@@ -604,7 +604,7 @@ mode_flags =
, defFlag "-show-options" (PassFlag (setMode showOptionsMode))
, defFlag "-supported-languages" (PassFlag (setMode showSupportedExtensionsMode))
, defFlag "-supported-extensions" (PassFlag (setMode showSupportedExtensionsMode))
, defFlag "-show-packages" (PassFlag (setMode showPackagesMode))
, defFlag "-show-packages" (PassFlag (setMode showUnitsMode))
] ++
[ defFlag k' (PassFlag (setMode (printSetting k)))
| k <- ["Project version",
......@@ -864,10 +864,10 @@ dumpFastStringStats dflags = do
where
x `pcntOf` y = int ((x * 100) `quot` y) Outputable.<> char '%'
showPackages, dumpPackages, dumpPackagesSimple :: DynFlags -> IO ()
showPackages dflags = putStrLn (showSDoc dflags (pprPackages (unitState dflags)))
dumpPackages dflags = putMsg dflags (pprPackages (unitState dflags))
dumpPackagesSimple dflags = putMsg dflags (pprPackagesSimple (unitState dflags))
showUnits, dumpUnits, dumpUnitsSimple :: DynFlags -> IO ()
showUnits dflags = putStrLn (showSDoc dflags (pprUnits (unitState dflags)))
dumpUnits dflags = putMsg dflags (pprUnits (unitState dflags))
dumpUnitsSimple dflags = putMsg dflags (pprUnitsSimple (unitState dflags))
-- -----------------------------------------------------------------------------
-- Frontend plugin support
......
......@@ -502,7 +502,7 @@ runit verbosity cli nonopts = do
checkConsistency verbosity cli
["dump"] -> do
dumpPackages verbosity cli (fromMaybe False mexpand_pkgroot)
dumpUnits verbosity cli (fromMaybe False mexpand_pkgroot)
["recache"] -> do
recache verbosity cli
......@@ -1627,8 +1627,8 @@ describePackage verbosity my_flags pkgarg expand_pkgroot = do
doDump expand_pkgroot [ (pkg, locationAbsolute db)
| (db, pkgs) <- dbs, pkg <- pkgs ]
dumpPackages :: Verbosity -> [Flag] -> Bool -> IO ()
dumpPackages verbosity my_flags expand_pkgroot = do
dumpUnits :: Verbosity -> [Flag] -> Bool -> IO ()
dumpUnits verbosity my_flags expand_pkgroot = do
(_, GhcPkg.DbOpenReadOnly, flag_db_stack) <-
getPkgDatabases verbosity GhcPkg.DbOpenReadOnly
False{-use user-} True{-use cache-} expand_pkgroot my_flags
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment