Commit 266bc3d9 authored by Sylvain Henry's avatar Sylvain Henry Committed by Marge Bot

DynFlags: refactor unwireUnit

parent 9400aa93
......@@ -195,7 +195,7 @@ withBkpSession cid insts deps session_type do_this = do
-- Synthesized the flags
packageFlags = packageFlags dflags ++ map (\(uid0, rn) ->
let state = unitState dflags
uid = unwireUnit dflags (improveUnit state $ renameHoleUnit state (listToUFM insts) uid0)
uid = unwireUnit state (improveUnit state $ renameHoleUnit state (listToUFM insts) uid0)
in ExposePackage
(showSDoc dflags
(text "-unit-id" <+> ppr uid <+> ppr rn))
......@@ -306,6 +306,7 @@ buildUnit session cid insts lunit = do
$ home_mod_infos
getOfiles (LM _ _ us) = map nameOfObject (filter isObject us)
obj_files = concatMap getOfiles linkables
state = unitState (hsc_dflags hsc_env)
let compat_fs = unitIdFS (indefUnit cid)
compat_pn = PackageName compat_fs
......@@ -330,7 +331,7 @@ buildUnit session cid insts lunit = do
-- really used for anything, so we leave it
-- blank for now.
TcSession -> []
_ -> map (toUnitId . unwireUnit dflags)
_ -> map (toUnitId . unwireUnit state)
$ deps ++ [ moduleUnit mod
| (_, mod) <- insts
, not (isHoleModule mod) ],
......
......@@ -320,7 +320,7 @@ warnUnusedPackages = do
requestedArgs = mapMaybe packageArg (packageFlags dflags)
unusedArgs
= filter (\arg -> not $ any (matching dflags arg) loadedPackages)
= filter (\arg -> not $ any (matching state arg) loadedPackages)
requestedArgs
let warn = makeIntoWarning
......@@ -348,15 +348,15 @@ warnUnusedPackages = do
= str == unitPackageIdString p
|| str == unitPackageNameString p
matching :: DynFlags -> PackageArg -> UnitInfo -> Bool
matching :: UnitState -> PackageArg -> UnitInfo -> Bool
matching _ (PackageArg str) p = matchingStr str p
matching dflags (UnitIdArg uid) p = uid == realUnit dflags p
matching state (UnitIdArg uid) p = uid == realUnit state p
-- For wired-in packages, we have to unwire their id,
-- otherwise they won't match package flags
realUnit :: DynFlags -> UnitInfo -> Unit
realUnit dflags
= unwireUnit dflags
realUnit :: UnitState -> UnitInfo -> Unit
realUnit state
= unwireUnit state
. RealUnit
. Definite
. unitId
......
......@@ -1616,9 +1616,9 @@ mkUnitState dflags dbs = do
-- | Given a wired-in 'Unit', "unwire" it into the 'Unit'
-- that it was recorded as in the package database.
unwireUnit :: DynFlags -> Unit-> Unit
unwireUnit dflags uid@(RealUnit (Definite def_uid)) =
maybe uid (RealUnit . Definite) (Map.lookup def_uid (unwireMap (unitState dflags)))
unwireUnit :: UnitState -> Unit-> Unit
unwireUnit state uid@(RealUnit (Definite def_uid)) =
maybe uid (RealUnit . Definite) (Map.lookup def_uid (unwireMap state))
unwireUnit _ uid = uid
-- -----------------------------------------------------------------------------
......
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