diff --git a/checks/ArrayUsageCheck.hs b/checks/ArrayUsageCheck.hs index e8a9528..08f2ec5 100644 --- a/checks/ArrayUsageCheck.hs +++ b/checks/ArrayUsageCheck.hs @@ -16,7 +16,7 @@ You should have received a copy of the GNU General Public License along with this program. If not, see . -} -module ArrayUsageCheck (checkArrayUsage, FlattenedExp(..), makeEquations, usageCheckPass, VarMap) where +module ArrayUsageCheck (checkArrayUsage, FlattenedExp(..), makeEquations, VarMap) where import Control.Monad.Error import Control.Monad.State @@ -29,24 +29,13 @@ import qualified Data.Set as Set import qualified AST as A import CompState import Errors -import FlowGraph import Metadata import Omega -import Pass import ShowCode import Types -import UsageCheckAlgorithms import UsageCheckUtils import Utils -usageCheckPass :: Pass -usageCheckPass t = do g' <- buildFlowGraph labelFunctions t - g <- case g' of - Left err -> die err - Right g -> return g - sequence_ $ checkPar checkArrayUsage g - return t - checkArrayUsage :: forall m. (Die m, CSM m) => (Meta, ParItems (Maybe Decl, Vars)) -> m () checkArrayUsage (m,p) = mapM_ (checkIndexes m) $ Map.toList $ groupArrayIndexes $ transformParItems snd p diff --git a/checks/Check.hs b/checks/Check.hs index 991c613..5008bc7 100644 --- a/checks/Check.hs +++ b/checks/Check.hs @@ -20,7 +20,7 @@ with this program. If not, see . -- the control-flow graph stuff, hence the use of functions that match the dictionary -- of functions in FlowGraph. This is also why we don't drill down into processes; -- the control-flow graph means that we only need to concentrate on each node that isn't nested. -module Check (checkInitVar) where +module Check (checkInitVar, usageCheckPass) where import Control.Monad.Identity import Data.Graph.Inductive @@ -29,13 +29,25 @@ import qualified Data.Map as Map import Data.Maybe import qualified Data.Set as Set +import ArrayUsageCheck import CompState import Errors import FlowAlgorithms import FlowGraph import Metadata +import Pass import ShowCode +import UsageCheckAlgorithms import UsageCheckUtils + +usageCheckPass :: Pass +usageCheckPass t = do g' <- buildFlowGraph labelFunctions t + g <- case g' of + Left err -> die err + Right g -> return g + sequence_ $ checkPar checkArrayUsage g + return t + {- Near the beginning, this piece of code was too clever for itself and applied processVarW using "everything". diff --git a/common/PassList.hs b/common/PassList.hs index 6d06a81..57e2a9a 100644 --- a/common/PassList.hs +++ b/common/PassList.hs @@ -19,7 +19,7 @@ with this program. If not, see . -- | Lists of passes module PassList (getPassList) where -import ArrayUsageCheck +import Check import CompState import GenerateC import GenerateCPPCSP