X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcoreSyn%2FCoreFVs.lhs;h=e2eb3a2e82b2d4de9540870b0743d30a4418ffb0;hb=0c5a05841df790c3d6b8537debc3b18aa8da98c5;hp=a15362a5853b0e7cb587a90545efc47721475b09;hpb=d95ce839533391e7118257537044f01cbb1d6694;p=ghc-hetmet.git diff --git a/compiler/coreSyn/CoreFVs.lhs b/compiler/coreSyn/CoreFVs.lhs index a15362a..e2eb3a2 100644 --- a/compiler/coreSyn/CoreFVs.lhs +++ b/compiler/coreSyn/CoreFVs.lhs @@ -16,7 +16,6 @@ Taken quite directly from the Peyton Jones/Lester paper. module CoreFVs ( -- * Free variables of expressions and binding groups exprFreeVars, -- CoreExpr -> VarSet -- Find all locally-defined free Ids or tyvars - exprFreeIds, -- CoreExpr -> IdSet -- Find all locally-defined free Ids exprsFreeVars, -- [CoreExpr] -> VarSet bindFreeVars, -- CoreBind -> VarSet @@ -26,8 +25,7 @@ module CoreFVs ( exprFreeNames, exprsFreeNames, -- * Free variables of Rules, Vars and Ids - idRuleVars, idRuleRhsVars, idFreeVars, idInlineFreeVars, - varTypeTyVars, + idRuleVars, idFreeVars, varTypeTyVars, varTypeTcTyVars, ruleRhsFreeVars, rulesFreeVars, ruleLhsFreeNames, ruleLhsFreeIds, @@ -73,10 +71,6 @@ but not those that are free in the type of variable occurrence. exprFreeVars :: CoreExpr -> VarSet exprFreeVars = exprSomeFreeVars isLocalVar --- | Find all locally-defined free Ids in an expression -exprFreeIds :: CoreExpr -> IdSet -- Find all locally-defined free Ids -exprFreeIds = exprSomeFreeVars isLocalId - -- | Find all locally-defined free Ids or type variables in several expressions exprsFreeVars :: [CoreExpr] -> VarSet exprsFreeVars = foldr (unionVarSet . exprFreeVars) emptyVarSet @@ -376,6 +370,13 @@ varTypeTyVars var | isLocalId var || isCoVar var = tyVarsOfType (idType var) | otherwise = emptyVarSet -- Global Ids and non-coercion TyVars +varTypeTcTyVars :: Var -> TyVarSet +-- Find the type variables free in the type of the variable +-- Remember, coercion variables can mention type variables... +varTypeTcTyVars var + | isLocalId var || isCoVar var = tcTyVarsOfType (idType var) + | otherwise = emptyVarSet -- Global Ids and non-coercion TyVars + idFreeVars :: Id -> VarSet idFreeVars id = ASSERT( isId id) idRuleVars id `unionVarSet` varTypeTyVars id @@ -384,24 +385,7 @@ bndrRuleVars v | isTyVar v = emptyVarSet | otherwise = idRuleVars v idRuleVars ::Id -> VarSet -idRuleVars id = ASSERT( isId id) - specInfoFreeVars (idSpecialisation id) `unionVarSet` - idInlineFreeVars id -- And the variables in an INLINE rule - -idRuleRhsVars :: Id -> VarSet --- Just the variables free on the *rhs* of a rule --- See Note [Choosing loop breakers] in Simplify.lhs -idRuleRhsVars id = foldr (unionVarSet . ruleRhsFreeVars) - (idInlineFreeVars id) - (idCoreRules id) - -idInlineFreeVars :: Id -> VarSet --- Produce free vars for an InlineRule, BUT NOT for an ordinary unfolding --- An InlineRule behaves *very like* a RULE, and that is what we are after here -idInlineFreeVars id - = case idUnfolding id of - InlineRule { uf_tmpl = tmpl } -> exprFreeVars tmpl - _ -> emptyVarSet +idRuleVars id = ASSERT( isId id) specInfoFreeVars (idSpecialisation id) \end{code}