X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=compiler%2FcoreSyn%2FCoreTidy.lhs;h=586f032b32e42fd23faf1df58ad2c0b5b2ea19e8;hb=410fc617555117dd0ebbb3854f2d335628d60ea9;hp=95c3ac45d30be2d00dfc863b8b9ae5f1a79e614d;hpb=940524aec90652b5ef81789c9a453c57c0e42cc9;p=ghc-hetmet.git diff --git a/compiler/coreSyn/CoreTidy.lhs b/compiler/coreSyn/CoreTidy.lhs index 95c3ac4..586f032 100644 --- a/compiler/coreSyn/CoreTidy.lhs +++ b/compiler/coreSyn/CoreTidy.lhs @@ -25,7 +25,8 @@ import Name hiding (tidyNameOcc) import OccName import SrcLoc import Maybes -import Util + +import Data.List \end{code} @@ -54,7 +55,7 @@ tidyBind env (Rec prs) tidyExpr :: TidyEnv -> CoreExpr -> CoreExpr tidyExpr env (Var v) = Var (tidyVarOcc env v) tidyExpr env (Type ty) = Type (tidyType env ty) -tidyExpr env (Lit lit) = Lit lit +tidyExpr _ (Lit lit) = Lit lit tidyExpr env (App f a) = App (tidyExpr env f) (tidyExpr env a) tidyExpr env (Note n e) = Note (tidyNote env n) (tidyExpr env e) tidyExpr env (Cast e co) = Cast (tidyExpr env e) (tidyType env co) @@ -73,23 +74,25 @@ tidyExpr env (Lam b e) Lam b (tidyExpr env' e) ------------ Case alternatives -------------- -tidyAlt case_bndr env (con, vs, rhs) +tidyAlt :: CoreBndr -> TidyEnv -> CoreAlt -> CoreAlt +tidyAlt _case_bndr env (con, vs, rhs) = tidyBndrs env vs =: \ (env', vs) -> (con, vs, tidyExpr env' rhs) ------------ Notes -------------- -tidyNote env note = note +tidyNote :: TidyEnv -> Note -> Note +tidyNote _ note = note ------------ Rules -------------- tidyRules :: TidyEnv -> [CoreRule] -> [CoreRule] -tidyRules env [] = [] +tidyRules _ [] = [] tidyRules env (rule : rules) = tidyRule env rule =: \ rule -> tidyRules env rules =: \ rules -> (rule : rules) tidyRule :: TidyEnv -> CoreRule -> CoreRule -tidyRule env rule@(BuiltinRule {}) = rule +tidyRule _ rule@(BuiltinRule {}) = rule tidyRule env rule@(Rule { ru_bndrs = bndrs, ru_args = args, ru_rhs = rhs, ru_fn = fn, ru_rough = mb_ns }) = tidyBndrs env bndrs =: \ (env', bndrs) -> @@ -173,17 +176,24 @@ tidyIdBndr env@(tidy_env, var_env) id -- though we could extract it from the Id -- -- All nested Ids now have the same IdInfo, namely vanillaIdInfo, - -- which should save some space. + -- which should save some space; except that we hang onto dead-ness + -- (at the moment, solely to make printing tidy core nicer) -- But note that tidyLetBndr puts some of it back. - ty' = tidyType env (idType id) - id' = mkUserLocal occ' (idUnique id) ty' noSrcSpan - `setIdInfo` vanillaIdInfo - var_env' = extendVarEnv var_env id id' + ty' = tidyType env (idType id) + name' = mkInternalName (idUnique id) occ' noSrcSpan + id' = mkLocalIdWithInfo name' ty' new_info + var_env' = extendVarEnv var_env id id' + new_info | isDeadOcc (idOccInfo id) = deadIdInfo + | otherwise = vanillaIdInfo in ((tidy_env', var_env'), id') } + +deadIdInfo :: IdInfo +deadIdInfo = vanillaIdInfo `setOccInfo` IAmDead \end{code} \begin{code} +(=:) :: a -> (a -> b) -> b m =: k = m `seq` k m \end{code}