From c81fb0670b97a6719f24df9cc2df5d9d73dc5870 Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sun, 3 Feb 2008 12:42:16 +0000 Subject: [PATCH] Added a function to gather up a common pattern in ArrayUsageCheck --- checks/ArrayUsageCheck.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/checks/ArrayUsageCheck.hs b/checks/ArrayUsageCheck.hs index e50c6aa..fc7b120 100644 --- a/checks/ArrayUsageCheck.hs +++ b/checks/ArrayUsageCheck.hs @@ -260,6 +260,10 @@ makeEquations accesses bound | otherwise = (b,s) setIndexVar' _ _ b e = (b,e) + makeSingleEq :: A.Expression -> String -> StateT VarMap (Either String) EqualityConstraintEquation + makeSingleEq e desc = lift (flatten e) >>= makeEquation e (error $ "Type is irrelevant for " ++ desc) + >>= getSingleAccessItem ("Modulo or Divide not allowed in " ++ desc) + makeEquationWithPossibleRepBounds :: [(A.Variable, EqualityConstraintEquation, EqualityConstraintEquation)] -> ArrayAccess label -> StateT (VarMap) (Either String) (ArrayAccess label) makeEquationWithPossibleRepBounds [] item = return item @@ -305,10 +309,8 @@ makeEquations accesses bound makeRepVarEq :: (A.Replicator, Bool) -> StateT VarMap (Either String) (A.Variable, EqualityConstraintEquation, EqualityConstraintEquation) makeRepVarEq (A.For m varName from for, _) - = do from' <- lift (flatten from) >>= makeEquation from (error "Type is irrelevant for replication start") - >>= getSingleAccessItem "Modulo or Divide not allowed in replication start" - for' <- lift (flatten for) >>= makeEquation for (error "Type is irrelevant for replication count") - >>= getSingleAccessItem "Modulo or Divide not allowed in replication count" + = do from' <- makeSingleEq from "replication start" + for' <- makeSingleEq for "replication count" return (A.Variable m varName, from', for') mkEq' :: [(A.Variable, EqualityConstraintEquation, EqualityConstraintEquation)] -> (ArrayAccessType, A.Expression) -> StateT [(CoeffIndex,CoeffIndex)] (StateT VarMap (Either String)) [(A.Expression, ArrayAccessType, (EqualityConstraintEquation, EqualityProblem, InequalityProblem))]