From 5bc88ec1fc749b92c8e68df4636305404843aa29 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 4 Jun 2008 18:43:50 +0000 Subject: [PATCH] Fixed another test that was broken during the change to Rep --- transformations/PassTest.hs | 3 ++- transformations/SimplifyExprs.hs | 7 +++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/transformations/PassTest.hs b/transformations/PassTest.hs index 6da5ea9..d6e4d06 100644 --- a/transformations/PassTest.hs +++ b/transformations/PassTest.hs @@ -597,7 +597,8 @@ testPullRepCounts = TestList pullRepCounts (A.Seq emptyMeta $ A.Spec emptyMeta (A.Specification emptyMeta (simpleName "i") $ A.Rep emptyMeta (A.For emptyMeta (intLiteral 0) (intLiteral 6))) $ - A.Spec emptyMeta (A.Specification emptyMeta (simpleName "j") $ A.Rep emptyMeta (A.For emptyMeta (intLiteral 0) (intLiteral 8))) $ A.Several emptyMeta []) + A.Spec emptyMeta (A.Specification emptyMeta (simpleName "j") $ + A.Rep emptyMeta (A.For emptyMeta (intLiteral 0) (intLiteral 8))) $ A.Several emptyMeta []) (return ()) ] where diff --git a/transformations/SimplifyExprs.hs b/transformations/SimplifyExprs.hs index 50e92c7..3194d55 100644 --- a/transformations/SimplifyExprs.hs +++ b/transformations/SimplifyExprs.hs @@ -164,16 +164,19 @@ pullRepCounts = pass "Pull up replicator counts for SEQs" doProcess :: A.Process -> PassM A.Process doProcess (A.Seq m s) = pullRepCountSeq s >>* A.Seq m doProcess p = return p - + + -- Don't want to apply this using applyDepthM, because then nested PARs + -- inside the SEQ would also be processed, which is unnecessary pullRepCountSeq :: A.Structured A.Process -> PassM (A.Structured A.Process) pullRepCountSeq s@(A.Only _ _) = return s pullRepCountSeq (A.Spec m (A.Specification mspec n (A.Rep mrep (A.For mfor from for))) scope) = do t <- astTypeOf for spec@(A.Specification _ nonceName _) <- makeNonceIsExpr "rep_for" mspec t for + scope' <- pullRepCountSeq scope return $ A.Spec mspec spec $ A.Spec m (A.Specification mspec n (A.Rep mrep - (A.For mfor from (A.ExprVariable mspec $ A.Variable mspec nonceName)))) scope + (A.For mfor from (A.ExprVariable mspec $ A.Variable mspec nonceName)))) scope' pullRepCountSeq (A.Spec m sp str) = do str' <- pullRepCountSeq str return $ A.Spec m sp str'