Added some Or and And wrappers to the Check module, ready to help clear up the code
This commit is contained in:
parent
0e95d5d15e
commit
717a4dc0df
|
@ -30,6 +30,7 @@ import Data.Graph.Inductive
|
||||||
import Data.List hiding (union)
|
import Data.List hiding (union)
|
||||||
import qualified Data.Map as Map
|
import qualified Data.Map as Map
|
||||||
import Data.Maybe
|
import Data.Maybe
|
||||||
|
import Data.Monoid
|
||||||
import qualified Data.Set as Set
|
import qualified Data.Set as Set
|
||||||
|
|
||||||
import ArrayUsageCheck
|
import ArrayUsageCheck
|
||||||
|
@ -99,6 +100,35 @@ followBK = map followBK'
|
||||||
next = Set.fromList $ map Var $ listify (const True :: A.Variable -> Bool) bk
|
next = Set.fromList $ map Var $ listify (const True :: A.Variable -> Bool) bk
|
||||||
|
|
||||||
|
|
||||||
|
data And a = And [a]
|
||||||
|
data Or a = Or [a]
|
||||||
|
|
||||||
|
instance Monoid (And a) where
|
||||||
|
mempty = And []
|
||||||
|
mappend (And a) (And b) = And (a ++ b)
|
||||||
|
instance Monoid (Or a) where
|
||||||
|
mempty = Or []
|
||||||
|
mappend (Or a) (Or b) = Or (a ++ b)
|
||||||
|
|
||||||
|
instance Functor And where
|
||||||
|
fmap f (And xs) = And $ map f xs
|
||||||
|
|
||||||
|
instance Functor Or where
|
||||||
|
fmap f (Or xs) = Or $ map f xs
|
||||||
|
|
||||||
|
deAnd :: And a -> [a]
|
||||||
|
deAnd (And xs) = xs
|
||||||
|
|
||||||
|
deOr :: Or a -> [a]
|
||||||
|
deOr (Or xs) = xs
|
||||||
|
|
||||||
|
noOr :: a -> Or a
|
||||||
|
noOr = Or . singleton
|
||||||
|
|
||||||
|
noAnd :: a -> And a
|
||||||
|
noAnd = And . singleton
|
||||||
|
|
||||||
|
|
||||||
addBK :: Map.Map Node (Map.Map Var (Set.Set (Maybe A.Expression))) ->
|
addBK :: Map.Map Node (Map.Map Var (Set.Set (Maybe A.Expression))) ->
|
||||||
Map.Map Node [A.Expression] -> FlowGraph PassM UsageLabel ->
|
Map.Map Node [A.Expression] -> FlowGraph PassM UsageLabel ->
|
||||||
Node -> FNode PassM UsageLabel -> FNode PassM (BK, UsageLabel)
|
Node -> FNode PassM UsageLabel -> FNode PassM (BK, UsageLabel)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user