X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FsimplCore%2FSimplEnv.lhs;h=c9fb4fbb8ba23d5d9471a535c0498c71fe0609e1;hb=59264221c24a17e7c8ecde3e289882b9620bd5a8;hp=f9e048430b81c598661ea8c093fbfecc423f3e2c;hpb=7a327c1297615a9498e7117a0017b09ff2458d53;p=ghc-hetmet.git diff --git a/compiler/simplCore/SimplEnv.lhs b/compiler/simplCore/SimplEnv.lhs index f9e0484..c9fb4fb 100644 --- a/compiler/simplCore/SimplEnv.lhs +++ b/compiler/simplCore/SimplEnv.lhs @@ -21,7 +21,7 @@ module SimplEnv ( setEnclosingCC, getEnclosingCC, -- Environments - SimplEnv(..), -- Temp not abstract + SimplEnv(..), pprSimplEnv, -- Temp not abstract mkSimplEnv, extendIdSubst, SimplEnv.extendTvSubst, zapSubstEnv, setSubstEnv, getInScope, setInScope, setInScopeSet, modifyInScope, addNewInScopeIds, @@ -129,7 +129,14 @@ data SimplEnv } +pprSimplEnv :: SimplEnv -> SDoc +-- Used for debugging; selective +pprSimplEnv env + = vcat [ptext SLIT("TvSubst:") <+> ppr (seTvSubst env), + ptext SLIT("IdSubst:") <+> ppr (seIdSubst env) ] + type SimplIdSubst = IdEnv SimplSR -- IdId |--> OutExpr + -- See Note [Extending the Subst] in CoreSubst data SimplSR = DoneEx OutExpr -- Completed term @@ -137,15 +144,16 @@ data SimplSR | ContEx TvSubstEnv -- A suspended substitution SimplIdSubst InExpr + instance Outputable SimplSR where ppr (DoneEx e) = ptext SLIT("DoneEx") <+> ppr e ppr (DoneId v) = ptext SLIT("DoneId") <+> ppr v ppr (ContEx tv id e) = vcat [ptext SLIT("ContEx") <+> ppr e {-, ppr (filter_env tv), ppr (filter_env id) -}] - where - fvs = exprFreeVars e - filter_env env = filterVarEnv_Directly keep env - keep uniq _ = uniq `elemUFM_Directly` fvs + -- where + -- fvs = exprFreeVars e + -- filter_env env = filterVarEnv_Directly keep env + -- keep uniq _ = uniq `elemUFM_Directly` fvs \end{code} @@ -531,6 +539,8 @@ substIdBndr :: SimplEnv -> Id -- Substitition and Id to transform -- * The substitution extended with a DoneId if unique changed -- In this case, the var in the DoneId is the same as the -- var returned +-- +-- Exactly like CoreSubst.substIdBndr, except that the type of id_subst differs substIdBndr env@(SimplEnv { seInScope = in_scope, seIdSubst = id_subst}) old_id @@ -549,6 +559,7 @@ substIdBndr env@(SimplEnv { seInScope = in_scope, seIdSubst = id_subst}) -- Extend the substitution if the unique has changed -- See the notes with substTyVarBndr for the delSubstEnv + -- Also see Note [Extending the Subst] in CoreSubst new_subst | new_id /= old_id = extendVarEnv id_subst old_id (DoneId new_id) | otherwise