Moved customVarCompare from ArrayUsageCheck to UsageCheck and used it to derive Ord for the Var type
This commit is contained in:
parent
c2c761ab7d
commit
64a9292b75
|
@ -142,6 +142,8 @@ data FlattenedExp
|
||||||
| Modulo (Set.Set FlattenedExp) (Set.Set FlattenedExp)
|
| Modulo (Set.Set FlattenedExp) (Set.Set FlattenedExp)
|
||||||
| Divide (Set.Set FlattenedExp) (Set.Set FlattenedExp)
|
| Divide (Set.Set FlattenedExp) (Set.Set FlattenedExp)
|
||||||
|
|
||||||
|
--TODO change the A.Variable to Var, and automatically derive Eq and Ord
|
||||||
|
|
||||||
instance Eq FlattenedExp where
|
instance Eq FlattenedExp where
|
||||||
a == b = EQ == compare a b
|
a == b = EQ == compare a b
|
||||||
|
|
||||||
|
@ -159,10 +161,6 @@ instance Ord FlattenedExp where
|
||||||
compare (Divide ltop lbottom) (Divide rtop rbottom)
|
compare (Divide ltop lbottom) (Divide rtop rbottom)
|
||||||
= combineCompare [compare ltop rtop, compare lbottom rbottom]
|
= combineCompare [compare ltop rtop, compare lbottom rbottom]
|
||||||
|
|
||||||
customVarCompare :: A.Variable -> A.Variable -> Ordering
|
|
||||||
customVarCompare (A.Variable _ (A.Name _ _ lname)) (A.Variable _ (A.Name _ _ rname)) = compare lname rname
|
|
||||||
-- TODO the rest
|
|
||||||
|
|
||||||
onlyConst :: [FlattenedExp] -> Maybe Integer
|
onlyConst :: [FlattenedExp] -> Maybe Integer
|
||||||
onlyConst [] = Just 0
|
onlyConst [] = Just 0
|
||||||
onlyConst ((Const n):es) = liftM2 (+) (return n) $ onlyConst es
|
onlyConst ((Const n):es) = liftM2 (+) (return n) $ onlyConst es
|
||||||
|
|
|
@ -29,6 +29,16 @@ import Metadata
|
||||||
|
|
||||||
newtype Var = Var A.Variable
|
newtype Var = Var A.Variable
|
||||||
|
|
||||||
|
customVarCompare :: A.Variable -> A.Variable -> Ordering
|
||||||
|
customVarCompare (A.Variable _ (A.Name _ _ lname)) (A.Variable _ (A.Name _ _ rname)) = compare lname rname
|
||||||
|
-- TODO the rest
|
||||||
|
|
||||||
|
instance Eq Var where
|
||||||
|
a == b = EQ == compare a b
|
||||||
|
|
||||||
|
instance Ord Var where
|
||||||
|
compare (Var a) (Var b) = customVarCompare a b
|
||||||
|
|
||||||
data Vars = Vars {
|
data Vars = Vars {
|
||||||
readVars :: Set.Set Var
|
readVars :: Set.Set Var
|
||||||
,writtenVars :: Set.Set Var
|
,writtenVars :: Set.Set Var
|
||||||
|
|
Loading…
Reference in New Issue
Block a user