Commit fd893156 authored by Edward Z. Yang's avatar Edward Z. Yang
Browse files

Rename IndefUnitId constructor to DefiniteUnitId


Signed-off-by: default avatarEdward Z. Yang <ezyang@cs.stanford.edu>
parent 1be2b213
......@@ -85,7 +85,7 @@ data IndefUnitId
-- been compiled and abbreviated as a hash. The embedded 'UnitId'
-- MUST NOT be for an indefinite component; an 'IndefUnitId'
-- is guaranteed not to have any holes.
| IndefUnitId UnitId
| DefiniteUnitId UnitId
deriving (Generic, Read, Show, Eq, Ord, Typeable, Data)
-- TODO: cache holes?
......@@ -93,7 +93,7 @@ instance Binary IndefUnitId
instance NFData IndefUnitId where
rnf (IndefFullUnitId cid subst) = rnf cid `seq` rnf subst
rnf (IndefUnitId uid) = rnf uid
rnf (DefiniteUnitId uid) = rnf uid
instance Text IndefUnitId where
disp (IndefFullUnitId cid insts)
......@@ -101,8 +101,8 @@ instance Text IndefUnitId where
-- better
| Map.null insts = disp cid
| otherwise = disp cid <<>> Disp.brackets (dispIndefModuleSubst insts)
disp (IndefUnitId uid) = disp uid
parse = parseIndefUnitId <++ fmap IndefUnitId parse
disp (DefiniteUnitId uid) = disp uid
parse = parseIndefUnitId <++ fmap DefiniteUnitId parse
where
parseIndefUnitId = do
cid <- parse
......@@ -113,7 +113,7 @@ instance Text IndefUnitId where
-- | Get the 'ComponentId' of an 'IndefUnitId'.
indefUnitIdComponentId :: IndefUnitId -> ComponentId
indefUnitIdComponentId (IndefFullUnitId cid _) = cid
indefUnitIdComponentId (IndefUnitId uid) = unitIdComponentId uid
indefUnitIdComponentId (DefiniteUnitId uid) = unitIdComponentId uid
-- | Get the set of holes ('ModuleVar') embedded in a 'UnitId'.
indefUnitIdFreeHoles :: IndefUnitId -> Set ModuleName
......@@ -208,7 +208,7 @@ indefModuleSubstFreeHoles insts = Set.unions (map indefModuleFreeHoles (Map.elem
-- 'IndefFullUnitId' be compiled; instead, we just depend on the
-- installed indefinite unit installed at the 'ComponentId'.
abstractUnitId :: IndefUnitId -> UnitId
abstractUnitId (IndefUnitId uid) = uid
abstractUnitId (DefiniteUnitId uid) = uid
abstractUnitId (IndefFullUnitId cid _) = newSimpleUnitId cid
-- | Take a module substitution and hash it into a string suitable for
......
......@@ -248,7 +248,7 @@ mkLinkedComponentsLocalBuildInfo comp rcs = map go rcs
= Installed.ExposedModule modname' Nothing
| otherwise
= Installed.ExposedModule modname'
(Just (IndefModule (IndefUnitId uid) modname))
(Just (IndefModule (DefiniteUnitId uid) modname))
convIndefModuleExport (modname', modu@(IndefModule uid modname))
-- TODO: This isn't a good enough test if we have mutual
-- recursion (but maybe we'll get saved by the module name
......@@ -270,7 +270,7 @@ mkLinkedComponentsLocalBuildInfo comp rcs = map go rcs
insts =
case rc_i rc of
Left indefc -> [ (m, IndefModuleVar m) | m <- indefc_requires indefc ]
Right instc -> [ (m, IndefModule (IndefUnitId uid') m')
Right instc -> [ (m, IndefModule (DefiniteUnitId uid') m')
| (m, Module uid' m') <- instc_insts instc ]
in LibComponentLocalBuildInfo {
componentPackageDeps = cpds,
......@@ -327,7 +327,7 @@ mkLinkedComponentsLocalBuildInfo comp rcs = map go rcs
Left indefc ->
indefc_includes indefc
Right instc ->
map (\(x,y) -> (IndefUnitId x,y)) (instc_includes instc)
map (\(x,y) -> (DefiniteUnitId x,y)) (instc_includes instc)
internal_deps =
filter isInternal (nodeNeighbors rc)
++ rc_internal_build_tools rc
......
......@@ -19,7 +19,7 @@ type FullDb = UnitId -> FullUnitId
expandIndefUnitId :: FullDb -> IndefUnitId -> FullUnitId
expandIndefUnitId _db (IndefFullUnitId cid subst)
= FullUnitId cid subst
expandIndefUnitId db (IndefUnitId uid)
expandIndefUnitId db (DefiniteUnitId uid)
= expandUnitId db uid
expandUnitId :: FullDb -> UnitId -> FullUnitId
......
......@@ -74,10 +74,14 @@ emptyModuleShape = ModuleShape Map.empty Set.empty
shapeInstalledPackage :: IPI.InstalledPackageInfo -> ModuleShape
shapeInstalledPackage ipi = ModuleShape (Map.fromList provs) reqs
where
uid = IPI.installedUnitId ipi
insts = Map.fromList (IPI.instantiatedWith ipi)
uid =
if Set.null (indefModuleSubstFreeHoles insts)
then DefiniteUnitId (IPI.installedUnitId ipi)
else IndefFullUnitId (IPI.installedComponentId ipi) insts
provs = map shapeExposedModule (IPI.exposedModules ipi)
reqs = indefModuleSubstFreeHoles (Map.fromList (IPI.instantiatedWith ipi))
shapeExposedModule (IPI.ExposedModule mod_name Nothing)
= (mod_name, IndefModule (IndefUnitId uid) mod_name)
= (mod_name, IndefModule uid mod_name)
shapeExposedModule (IPI.ExposedModule mod_name (Just mod))
= (mod_name, mod)
......@@ -222,7 +222,7 @@ toReadyComponents pid_map subst0 comps
| otherwise = return Nothing
substUnitId :: Map ModuleName Module -> IndefUnitId -> InstM UnitId
substUnitId _ (IndefUnitId uid) =
substUnitId _ (DefiniteUnitId uid) =
return uid
substUnitId subst (IndefFullUnitId cid insts) = do
insts' <- substSubst subst insts
......
......@@ -237,7 +237,7 @@ convertUnitId' :: MuEnv s
-> UnifyM s (UnitIdU s)
-- TODO: this could be more lazy if we know there are no internal
-- references
convertUnitId' _ (IndefUnitId uid) =
convertUnitId' _ (DefiniteUnitId uid) =
liftST $ UnionFind.fresh (UnitIdThunkU uid)
convertUnitId' stk (IndefFullUnitId cid insts) = do
fs <- fmap unify_uniq getUnifEnv
......@@ -314,7 +314,7 @@ convertUnitIdU' :: MooEnv -> UnitIdU s -> UnifyM s IndefUnitId
convertUnitIdU' stk uid_u = do
x <- liftST $ UnionFind.find uid_u
case x of
UnitIdThunkU uid -> return (IndefUnitId uid)
UnitIdThunkU uid -> return (DefiniteUnitId uid)
UnitIdU u cid insts_u ->
case lookupMooEnv stk u of
Just _i -> error "convertUnitIdU': mutual recursion" -- return (UnitIdVar i)
......
......@@ -474,7 +474,7 @@ testSuiteLibV09AsLibAndExe pkg_descr
componentExeDeps = [],
componentLocalName = CExeName (stubName test),
componentPackageDeps = deps,
componentIncludes = zip (map (IndefUnitId . fst) deps) (repeat defaultRenaming)
componentIncludes = zip (map (DefiniteUnitId . fst) deps) (repeat defaultRenaming)
}
testSuiteLibV09AsLibAndExe _ TestSuite{} _ _ _ _ = error "testSuiteLibV09AsLibAndExe: wrong kind"
......
......@@ -1732,7 +1732,7 @@ instantiateInstallPlan plan =
| otherwise = error ("instantiateComponent: " ++ display cid)
substUnitId :: Map ModuleName Module -> IndefUnitId -> InstM UnitId
substUnitId _ (IndefUnitId uid) =
substUnitId _ (DefiniteUnitId uid) =
return uid
substUnitId subst (IndefFullUnitId cid insts) = do
insts' <- substSubst subst insts
......
......@@ -819,7 +819,7 @@ getExternalSetupMethod verbosity options pkg bt = do
then []
else cabalDep
addRenaming (ipid, _) =
(Backpack.IndefUnitId (newSimpleUnitId ipid), defaultRenaming)
(Backpack.DefiniteUnitId (newSimpleUnitId ipid), defaultRenaming)
cppMacrosFile = setupDir </> "setup_macros.h"
ghcOptions = mempty {
-- Respect -v0, but don't crank up verbosity on GHC if
......
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