Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
GHC
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
4,274
Issues
4,274
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
412
Merge Requests
412
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Glasgow Haskell Compiler
GHC
Commits
3d171cd6
Commit
3d171cd6
authored
May 12, 2020
by
Sylvain Henry
Committed by
Marge Bot
Jun 13, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Document and refactor `mkUnit` and `mkUnitInfoMap`
parent
d345edfe
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
15 deletions
+31
-15
compiler/GHC/Unit/Info.hs
compiler/GHC/Unit/Info.hs
+12
-4
compiler/GHC/Unit/State.hs
compiler/GHC/Unit/State.hs
+19
-11
No files found.
compiler/GHC/Unit/Info.hs
View file @
3d171cd6
...
...
@@ -153,11 +153,19 @@ pprUnitInfo GenericUnitInfo {..} =
where
field
name
body
=
text
name
<>
colon
<+>
nest
4
body
-- | Make a `Unit` from a `UnitInfo`
--
-- If the unit is definite, make a `RealUnit` from `unitId` field.
--
-- If the unit is indefinite, make a `VirtUnit` from `unitInstanceOf` and
-- `unitInstantiations` fields. Note that in this case we don't keep track of
-- `unitId`. It can be retrieved later with "improvement", i.e. matching on
-- `unitInstanceOf/unitInstantiations` fields (see Note [About units] in
-- GHC.Unit).
mkUnit
::
UnitInfo
->
Unit
mkUnit
p
=
if
unitIsIndefinite
p
then
mkVirtUnit
(
unitInstanceOf
p
)
(
unitInstantiations
p
)
else
RealUnit
(
Definite
(
unitId
p
))
mkUnit
p
|
unitIsIndefinite
p
=
mkVirtUnit
(
unitInstanceOf
p
)
(
unitInstantiations
p
)
|
otherwise
=
RealUnit
(
Definite
(
unitId
p
))
-- | Create a UnitPprInfo from a UnitInfo
mkUnitPprInfo
::
GenUnitInfo
u
->
UnitPprInfo
...
...
compiler/GHC/Unit/State.hs
View file @
3d171cd6
...
...
@@ -442,17 +442,25 @@ searchPackageId :: PackageState -> PackageId -> [UnitInfo]
searchPackageId
pkgstate
pid
=
filter
((
pid
==
)
.
unitPackageId
)
(
listUnitInfoMap
pkgstate
)
-- | Extends the package configuration map with a list of package configs.
extendUnitInfoMap
::
UnitInfoMap
->
[
UnitInfo
]
->
UnitInfoMap
extendUnitInfoMap
(
UnitInfoMap
pkg_map
closure
)
new_pkgs
=
UnitInfoMap
(
foldl'
add
pkg_map
new_pkgs
)
closure
-- We also add the expanded version of the mkUnit, so that
-- 'improveUnit' can find it.
-- | Create a Map UnitId UnitInfo
--
-- For each instantiated unit, we add two map keys:
-- * the real unit id
-- * the virtual unit id made from its instantiation
--
-- We do the same thing for fully indefinite units (which are "instantiated"
-- with module holes).
--
mkUnitInfoMap
::
[
UnitInfo
]
->
UnitInfoMap
mkUnitInfoMap
infos
=
UnitInfoMap
(
foldl'
add
emptyUDFM
infos
)
emptyUniqSet
where
mkVirt
p
=
mkVirtUnit
(
unitInstanceOf
p
)
(
unitInstantiations
p
)
add
pkg_map
p
=
addToUDFM
(
addToUDFM
pkg_map
(
mkVirt
p
)
p
)
(
unitId
p
)
p
add
pkg_map
p
|
not
(
null
(
unitInstantiations
p
))
=
addToUDFM
(
addToUDFM
pkg_map
(
mkVirt
p
)
p
)
(
unitId
p
)
p
|
otherwise
=
addToUDFM
pkg_map
(
unitId
p
)
p
-- | Get a list of entries from the package database. NB: be careful with
-- this function, although all packages in this map are "visible", this
...
...
@@ -1410,7 +1418,7 @@ mkPackageState dflags dbs preload0 = do
-- or not packages are visible or not)
pkgs1
<-
foldM
(
applyTrustFlag
dflags
prec_map
unusable
)
(
Map
.
elems
pkg_map2
)
(
reverse
(
trustFlags
dflags
))
let
prelim_pkg_db
=
extendUnitInfoMap
empty
UnitInfoMap
pkgs1
let
prelim_pkg_db
=
mk
UnitInfoMap
pkgs1
--
-- Calculate the initial set of units from package databases, prior to any package flags.
...
...
@@ -1476,7 +1484,7 @@ mkPackageState dflags dbs preload0 = do
-- package arguments we need to key against the old versions.
--
(
pkgs2
,
wired_map
)
<-
findWiredInPackages
dflags
prec_map
pkgs1
vis_map2
let
pkg_db
=
extendUnitInfoMap
empty
UnitInfoMap
pkgs2
let
pkg_db
=
mk
UnitInfoMap
pkgs2
-- Update the visibility map, so we treat wired packages as visible.
let
vis_map
=
updateVisibilityMap
wired_map
vis_map2
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment