From 7d30bf612da9ec6a1f7461b89cb7b2da8770328d Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sun, 3 Feb 2008 12:43:36 +0000 Subject: [PATCH] Moved flattenParItems up to the higher where clause in checkArrayUsage --- checks/ArrayUsageCheck.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/checks/ArrayUsageCheck.hs b/checks/ArrayUsageCheck.hs index fc7b120..0f529f6 100644 --- a/checks/ArrayUsageCheck.hs +++ b/checks/ArrayUsageCheck.hs @@ -40,6 +40,11 @@ checkArrayUsage :: forall m. (Die m, CSM m) => (Meta, ParItems UsageLabel) -> m checkArrayUsage (m,p) = mapM_ (checkIndexes m) $ Map.toList $ groupArrayIndexes $ transformParItems nodeVars p where + flattenParItems :: ParItems a -> [a] + flattenParItems (SeqItems xs) = xs + flattenParItems (ParItems ps) = concatMap flattenParItems ps + flattenParItems (RepParItem _ p) = flattenParItems p + -- Returns (array name, list of written-to indexes, list of read-from indexes) groupArrayIndexes :: ParItems Vars -> Map.Map String (ParItems ([A.Expression], [A.Expression])) groupArrayIndexes vs = filterByKey $ transformParItems (uncurry (zipMap join) . (transformPair (makeList . writtenVars) (makeList . readVars)) . mkPair) vs @@ -47,10 +52,7 @@ checkArrayUsage (m,p) = mapM_ (checkIndexes m) $ Map.toList $ join :: Maybe [a] -> Maybe [a] -> Maybe ([a],[a]) join x y = Just (fromMaybe [] x, fromMaybe [] y) - flattenParItems :: ParItems a -> [a] - flattenParItems (SeqItems xs) = xs - flattenParItems (ParItems ps) = concatMap flattenParItems ps - flattenParItems (RepParItem _ p) = flattenParItems p + makeList :: Set.Set Var -> Map.Map String [A.Expression]