X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Fcompiler%2FbasicTypes%2FVarSet.lhs;h=5971964f41f6004caace61d0d09e55046a861e64;hb=ca0b7c66f2e8e50f15a03c406408d9e86455f8eb;hp=cf4f5df60e3ce93cdd6d5dc3737257ee204f92ab;hpb=9d787ef5a8072b6c1f576f2de1b66edfa59813ed;p=ghc-hetmet.git diff --git a/ghc/compiler/basicTypes/VarSet.lhs b/ghc/compiler/basicTypes/VarSet.lhs index cf4f5df..5971964 100644 --- a/ghc/compiler/basicTypes/VarSet.lhs +++ b/ghc/compiler/basicTypes/VarSet.lhs @@ -5,27 +5,23 @@ \begin{code} module VarSet ( - VarSet, IdSet, TyVarSet, IdOrTyVarSet, UVarSet, + VarSet, IdSet, TyVarSet, emptyVarSet, unitVarSet, mkVarSet, - extendVarSet, + extendVarSet, extendVarSetList, extendVarSet_C, elemVarSet, varSetElems, subVarSet, unionVarSet, unionVarSets, intersectVarSet, intersectsVarSet, - isEmptyVarSet, delVarSet, delVarSetByKey, + isEmptyVarSet, delVarSet, delVarSetList, delVarSetByKey, minusVarSet, foldVarSet, filterVarSet, - lookupVarSet, mapVarSet, sizeVarSet, seqVarSet, - - uniqAway + lookupVarSet, mapVarSet, sizeVarSet, seqVarSet ) where #include "HsVersions.h" -import CmdLineOpts ( opt_PprStyle_Debug ) -import Var ( Var, Id, TyVar, UVar, IdOrTyVar, setVarUnique ) -import Unique ( Unique, Uniquable(..), incrUnique, deriveUnique ) +import Var ( Var, Id, TyVar ) +import Unique ( Unique ) import UniqSet -import UniqFM ( delFromUFM_Directly ) -import Outputable +import UniqFM ( delFromUFM_Directly, addToUFM_C ) \end{code} %************************************************************************ @@ -38,19 +34,18 @@ import Outputable type VarSet = UniqSet Var type IdSet = UniqSet Id type TyVarSet = UniqSet TyVar -type IdOrTyVarSet = UniqSet IdOrTyVar -type UVarSet = UniqSet UVar emptyVarSet :: VarSet intersectVarSet :: VarSet -> VarSet -> VarSet -intersectsVarSet:: VarSet -> VarSet -> Bool -- True if non-empty intersection unionVarSet :: VarSet -> VarSet -> VarSet unionVarSets :: [VarSet] -> VarSet varSetElems :: VarSet -> [Var] unitVarSet :: Var -> VarSet extendVarSet :: VarSet -> Var -> VarSet +extendVarSetList:: VarSet -> [Var] -> VarSet elemVarSet :: Var -> VarSet -> Bool delVarSet :: VarSet -> Var -> VarSet +delVarSetList :: VarSet -> [Var] -> VarSet minusVarSet :: VarSet -> VarSet -> VarSet isEmptyVarSet :: VarSet -> Bool mkVarSet :: [Var] -> VarSet @@ -61,21 +56,28 @@ lookupVarSet :: VarSet -> Var -> Maybe Var mapVarSet :: (Var -> Var) -> VarSet -> VarSet sizeVarSet :: VarSet -> Int filterVarSet :: (Var -> Bool) -> VarSet -> VarSet -subVarSet :: VarSet -> VarSet -> Bool +extendVarSet_C :: (Var->Var->Var) -> VarSet -> Var -> VarSet delVarSetByKey :: VarSet -> Unique -> VarSet emptyVarSet = emptyUniqSet unitVarSet = unitUniqSet extendVarSet = addOneToUniqSet +extendVarSetList= addListToUniqSet intersectVarSet = intersectUniqSets -intersectsVarSet s1 s2 = not (isEmptyVarSet (s1 `intersectVarSet` s2)) + +intersectsVarSet:: VarSet -> VarSet -> Bool -- True if non-empty intersection + -- (s1 `intersectsVarSet` s2) doesn't compute s2 if s1 is empty +subVarSet :: VarSet -> VarSet -> Bool -- True if first arg is subset of second + -- (s1 `subVarSet` s2) doesn't compute s2 if s1 is empty + unionVarSet = unionUniqSets unionVarSets = unionManyUniqSets varSetElems = uniqSetToList elemVarSet = elementOfUniqSet minusVarSet = minusUniqSet delVarSet = delOneFromUniqSet +delVarSetList = delListFromUniqSet isEmptyVarSet = isEmptyUniqSet mkVarSet = mkUniqSet foldVarSet = foldUniqSet @@ -83,29 +85,18 @@ lookupVarSet = lookupUniqSet mapVarSet = mapUniqSet sizeVarSet = sizeUniqSet filterVarSet = filterUniqSet -a `subVarSet` b = isEmptyVarSet (a `minusVarSet` b) +extendVarSet_C combine s x = addToUFM_C combine s x x delVarSetByKey = delFromUFM_Directly -- Can't be bothered to add this to UniqSet \end{code} \begin{code} -seqVarSet :: VarSet -> () -seqVarSet s = sizeVarSet s `seq` () +-- See comments with type signatures +intersectsVarSet s1 s2 = not (isEmptyVarSet (s1 `intersectVarSet` s2)) +a `subVarSet` b = isEmptyVarSet (a `minusVarSet` b) \end{code} \begin{code} -uniqAway :: VarSet -> Var -> Var --- Give the Var a new unique, different to any in the VarSet -uniqAway set var - | not (var `elemVarSet` set) = var -- Nothing to do - - | otherwise - = try 1 (deriveUnique (getUnique var) (hashUniqSet set)) - where - try n uniq | uniq `elemUniqSet_Directly` set = try ((n+1)::Int) (incrUnique uniq) -#ifdef DEBUG - | opt_PprStyle_Debug && n > 3 - = pprTrace "uniqAway:" (ppr n <+> text "tries" <+> ppr var) - setVarUnique var uniq -#endif - | otherwise = setVarUnique var uniq +seqVarSet :: VarSet -> () +seqVarSet s = sizeVarSet s `seq` () \end{code} +