Add a CaseAlt constructor to CoreContext.
authorMatthijs Kooijman <matthijs@stdin.nl>
Wed, 16 Jun 2010 13:37:19 +0000 (15:37 +0200)
committerMatthijs Kooijman <matthijs@stdin.nl>
Wed, 16 Jun 2010 13:37:19 +0000 (15:37 +0200)
Since a case expression can introduce a binder (for its scrutinee), we
should be able to denote that in the CoreContext.

clash/CLasH/Normalize/NormalizeTools.hs
clash/CLasH/Normalize/NormalizeTypes.hs

index 307795634463313631079e0ed058669a9745f227..0652081760d8f646a19823343a95e84c10bf665e 100644 (file)
@@ -113,7 +113,7 @@ subeverywhere trans c (Case scrut b t alts) = do
   where
     transalt :: CoreAlt -> TransformMonad CoreAlt
     transalt (con, binders, expr) = do
-      expr' <- trans (Other:c) expr
+      expr' <- trans ((CaseAlt b):c) expr
       return (con, binders, expr')
 
 subeverywhere trans c (Var x) = return $ Var x
index 506633de65e569548787d8c8deca83d3cc814755..f4e5e9b523eb9f3c0ace82aa90c06f6d23205ebf 100644 (file)
@@ -31,6 +31,9 @@ data CoreContext = AppFirst        -- ^ The expression is the first
                  | LambdaBody CoreSyn.CoreBndr
                                    -- ^ The expression is the body of a
                                    --   lambda abstraction
+                 | CaseAlt CoreSyn.CoreBndr
+                                   -- ^ The expression is the body of a
+                                   --   case alternative.
                  | Other           -- ^ Another context
   deriving (Eq, Show)
 -- | Transforms a CoreExpr and keeps track if it has changed.