X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FbasicTypes%2FVarSet.lhs;h=6f03aad1bf05c1ce4c051fee1688969a98d166e5;hb=59300a7161f44b3a2afe381a6ccd914043a32c4f;hp=55e82a8515ae17871946e676343a1ed94dbeb249;hpb=0065d5ab628975892cea1ec7303f968c3338cbe1;p=ghc-hetmet.git diff --git a/compiler/basicTypes/VarSet.lhs b/compiler/basicTypes/VarSet.lhs index 55e82a8..6f03aad 100644 --- a/compiler/basicTypes/VarSet.lhs +++ b/compiler/basicTypes/VarSet.lhs @@ -1,28 +1,30 @@ % +% (c) The University of Glasgow 2006 % (c) The GRASP/AQUA Project, Glasgow University, 1992-1998 % -\section{@VarSet@: Variable sets} \begin{code} module VarSet ( + -- * Var, Id and TyVar set types VarSet, IdSet, TyVarSet, + + -- ** Manipulating these sets emptyVarSet, unitVarSet, mkVarSet, extendVarSet, extendVarSetList, extendVarSet_C, elemVarSet, varSetElems, subVarSet, unionVarSet, unionVarSets, - intersectVarSet, intersectsVarSet, + intersectVarSet, intersectsVarSet, disjointVarSet, isEmptyVarSet, delVarSet, delVarSetList, delVarSetByKey, - minusVarSet, foldVarSet, filterVarSet, + minusVarSet, foldVarSet, filterVarSet, fixVarSet, lookupVarSet, mapVarSet, sizeVarSet, seqVarSet, elemVarSetByKey ) where #include "HsVersions.h" -import Var ( Var, Id, TyVar ) -import Unique ( Unique ) +import Var ( Var, TyVar, Id ) +import Unique import UniqSet -import UniqFM ( delFromUFM_Directly, addToUFM_C ) \end{code} %************************************************************************ @@ -61,6 +63,7 @@ extendVarSet_C :: (Var->Var->Var) -> VarSet -> Var -> VarSet delVarSetByKey :: VarSet -> Unique -> VarSet elemVarSetByKey :: Unique -> VarSet -> Bool +fixVarSet :: (VarSet -> VarSet) -> VarSet -> VarSet emptyVarSet = emptyUniqSet unitVarSet = unitUniqSet @@ -69,9 +72,10 @@ extendVarSetList= addListToUniqSet intersectVarSet = intersectUniqSets intersectsVarSet:: VarSet -> VarSet -> Bool -- True if non-empty intersection - -- (s1 `intersectsVarSet` s2) doesn't compute s2 if s1 is empty +disjointVarSet :: VarSet -> VarSet -> Bool -- True if empty intersection subVarSet :: VarSet -> VarSet -> Bool -- True if first arg is subset of second - -- (s1 `subVarSet` s2) doesn't compute s2 if s1 is empty + -- (s1 `intersectsVarSet` s2) doesn't compute s2 if s1 is empty; + -- ditto disjointVarSet, subVarSet unionVarSet = unionUniqSets unionVarSets = unionManyUniqSets @@ -87,15 +91,22 @@ lookupVarSet = lookupUniqSet mapVarSet = mapUniqSet sizeVarSet = sizeUniqSet filterVarSet = filterUniqSet -extendVarSet_C combine s x = addToUFM_C combine s x x -delVarSetByKey = delFromUFM_Directly -- Can't be bothered to add this to UniqSet +extendVarSet_C = addOneToUniqSet_C +delVarSetByKey = delOneFromUniqSet_Directly elemVarSetByKey = elemUniqSet_Directly \end{code} \begin{code} -- See comments with type signatures -intersectsVarSet s1 s2 = not (isEmptyVarSet (s1 `intersectVarSet` s2)) -a `subVarSet` b = isEmptyVarSet (a `minusVarSet` b) +intersectsVarSet s1 s2 = not (s1 `disjointVarSet` s2) +disjointVarSet s1 s2 = isEmptyVarSet (s1 `intersectVarSet` s2) +subVarSet s1 s2 = isEmptyVarSet (s1 `minusVarSet` s2) + +-- Iterate f to a fixpoint +fixVarSet f s | new_s `subVarSet` s = s + | otherwise = fixVarSet f new_s + where + new_s = f s \end{code} \begin{code}