From 929745f05e7ff6db9924b9a1368f7ae36e714987 Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Wed, 22 Aug 2007 22:24:08 +0000 Subject: [PATCH] Tidy up how Main decides which passes to run. Since the set of passes that runs now depends on several variables, there's now an expression which builds a list of passes to run; this should be easier to extend in the future. --- CompState.hs | 8 ++++---- Main.hs | 16 ++++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/CompState.hs b/CompState.hs index 37b366e..e1081ec 100644 --- a/CompState.hs +++ b/CompState.hs @@ -31,15 +31,15 @@ import Metadata -- | Modes that Tock can run in. data CompMode = ModeParse | ModeCompile | ModePostC - deriving (Show, Data, Typeable) + deriving (Show, Data, Typeable, Eq) -- | Backends that Tock can use. data CompBackend = BackendC | BackendCPPCSP - deriving (Show, Data, Typeable) - + deriving (Show, Data, Typeable, Eq) + -- | Frontends that Tock can use. data CompFrontend = FrontendOccam | FrontendRain - deriving (Show, Data, Typeable) + deriving (Show, Data, Typeable, Eq) -- | State necessary for compilation. data CompState = CompState { diff --git a/Main.hs b/Main.hs index 25db549..270f223 100644 --- a/Main.hs +++ b/Main.hs @@ -43,8 +43,8 @@ import SimplifyProcs import SimplifyTypes import Unnest -passes :: [(String, Pass)] -passes = +commonPasses :: [(String, Pass)] +commonPasses = [ ("Simplify types", simplifyTypes) , ("Simplify expressions", simplifyExprs) , ("Simplify processes", simplifyProcs) @@ -157,10 +157,14 @@ compile fn ModeParse -> return $ show ast1 ModeCompile -> do progress "Passes:" - ast2 <- case csFrontend optsPS of - FrontendOccam -> (runPasses passes) ast1 - --Run the rain passes, then all the normal occam passes too: - FrontendRain -> ((runPasses rainPasses) ast1) >>= (runPasses passes) + + let passes + = concat [ commonPasses + , if csFrontend optsPS == FrontendRain + then rainPasses + else [] + ] + ast2 <- runPasses passes ast1 debug "{{{ Generate code" let generator