From 9b1fbc3f8f7eba432dc20f52f7ba8948a1510a2e Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Wed, 12 Sep 2007 08:45:23 +0000 Subject: [PATCH] Added a helper function for creating passes that check the validity of the AST --- common/Pass.hs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/common/Pass.hs b/common/Pass.hs index 64aa5f2..43d7331 100644 --- a/common/Pass.hs +++ b/common/Pass.hs @@ -30,6 +30,7 @@ import CompState import Errors import Metadata import PrettyShow +import TreeUtil -- | The monad in which AST-mangling passes operate. type PassM = ErrorT String (StateT CompState IO) @@ -105,3 +106,8 @@ makeGeneric top `extM` (return :: String -> PassM String) `extM` (return :: Meta -> PassM Meta) +excludeConstr :: Data a => [Constr] -> a -> PassM a +excludeConstr cons x + = if null items then return x else dieInternal $ "Excluded item still remains in source tree: " ++ (show $ head items) ++ " tree is: " ++ pshow x + where + items = checkTreeForConstr cons x