Added more helper functions to the Pass module for constructing passes
This commit is contained in:
parent
59e0922263
commit
6f6538ed57
31
pass/Pass.hs
31
pass/Pass.hs
|
@ -125,15 +125,40 @@ passOnlyOnAST name func x
|
|||
Nothing -> dieP emptyMeta $ name ++ " crazy cast error at top-level"
|
||||
Just y' -> return y'
|
||||
|
||||
rainOnlyPass :: String -> [Property] -> [Property] -> (forall t. Data t => t -> PassM t) -> Pass
|
||||
rainOnlyPass name pre post code
|
||||
type PassMaker = String -> [Property] -> [Property] -> (forall t. Data t => t -> PassM t) -> Pass
|
||||
|
||||
passMakerHelper :: (CompState -> Bool) -> PassMaker
|
||||
passMakerHelper f name pre post code
|
||||
= Pass {passCode = code
|
||||
,passName = name
|
||||
,passPre = Set.fromList pre
|
||||
,passPost = Set.fromList post
|
||||
,passEnabled = (== FrontendRain) . csFrontend
|
||||
,passEnabled = f
|
||||
}
|
||||
|
||||
rainOnlyPass :: PassMaker
|
||||
rainOnlyPass = passMakerHelper $ (== FrontendRain) . csFrontend
|
||||
|
||||
occamOnlyPass :: PassMaker
|
||||
occamOnlyPass = passMakerHelper $ (== FrontendOccam) . csFrontend
|
||||
|
||||
cOnlyPass :: PassMaker
|
||||
cOnlyPass = passMakerHelper $ (== BackendC) . csBackend
|
||||
|
||||
cppOnlyPass :: PassMaker
|
||||
cppOnlyPass = passMakerHelper $ (== BackendCPPCSP) . csBackend
|
||||
|
||||
|
||||
pass :: String -> [Property] -> [Property] -> (forall t. Data t => t -> PassM t) -> Pass
|
||||
pass name pre post code
|
||||
= Pass {passCode = code
|
||||
,passName = name
|
||||
,passPre = Set.fromList pre
|
||||
,passPost = Set.fromList post
|
||||
,passEnabled = const True
|
||||
}
|
||||
|
||||
|
||||
-- | Compose a list of passes into a single pass by running them in the order given.
|
||||
runPasses :: [Pass] -> (A.AST -> PassM A.AST)
|
||||
runPasses [] ast = return ast
|
||||
|
|
|
@ -19,7 +19,6 @@ with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
-- | Lists of passes
|
||||
module PassList (calculatePassList, getPassList) where
|
||||
|
||||
import Control.Monad.Error
|
||||
import Control.Monad.State
|
||||
import Data.List
|
||||
import qualified Data.Map as Map
|
||||
|
|
Loading…
Reference in New Issue
Block a user