From 2e46e22eb0971c345e592314bd33729902e94d21 Mon Sep 17 00:00:00 2001 From: Matthijs Kooijman Date: Tue, 30 Mar 2010 14:56:43 +0200 Subject: [PATCH] Add AppFirst and AddSecond to CoreContext. Also let subeverywhere set those contexts when appropriate. --- "c\316\273ash/CLasH/Normalize/NormalizeTools.hs" | 4 ++-- "c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" | 8 +++++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git "a/c\316\273ash/CLasH/Normalize/NormalizeTools.hs" "b/c\316\273ash/CLasH/Normalize/NormalizeTools.hs" index b1ca369..c774a33 100644 --- "a/c\316\273ash/CLasH/Normalize/NormalizeTools.hs" +++ "b/c\316\273ash/CLasH/Normalize/NormalizeTools.hs" @@ -57,8 +57,8 @@ applyboth first (name, second) context expr = do -- expression itself. subeverywhere :: Transform -> Transform subeverywhere trans c (App a b) = do - a' <- trans (Other:c) a - b' <- trans (Other:c) b + a' <- trans (AppFirst:c) a + b' <- trans (AppSecond:c) b return $ App a' b' subeverywhere trans c (Let (NonRec b bexpr) expr) = do diff --git "a/c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" "b/c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" index a7de6dc..9059252 100644 --- "a/c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" +++ "b/c\316\273ash/CLasH/Normalize/NormalizeTypes.hs" @@ -15,7 +15,13 @@ import CLasH.Translator.TranslatorTypes type TransformMonad = Writer.WriterT Monoid.Any TranslatorSession -- | In what context does a core expression occur? -data CoreContext = Other -- ^ Another context +data CoreContext = AppFirst -- ^ The expression is the first + -- argument of an application (i.e., + -- it is applied) + | AppSecond -- ^ The expression is the second + -- argument of an application + -- (i.e., something is applied to it) + | Other -- ^ Another context -- | Transforms a CoreExpr and keeps track if it has changed. type Transform = [CoreContext] -> CoreSyn.CoreExpr -> TransformMonad CoreSyn.CoreExpr -- 2.30.2