Corrected the display of variables relating to REM

This commit is contained in:
Neil Brown 2008-01-16 11:34:56 +00:00
parent a14a866502
commit 183e68ee59

View File

@ -90,7 +90,9 @@ checkArrayUsage tree = (mapM_ checkPar $ listify (const True) tree) >> return tr
showFlattenedExp (Modulo top bottom)
= do top' <- showFlattenedExpSet top
bottom' <- showFlattenedExpSet bottom
return $ "(" ++ top' ++ " REM " ++ bottom' ++ ")"
case onlyConst (Set.toList bottom) of
Just _ -> return $ "(" ++ top' ++ " / " ++ bottom' ++ ")"
Nothing -> return $ "((" ++ top' ++ " REM " ++ bottom' ++ ") - " ++ top' ++ ")"
showFlattenedExp (Divide top bottom)
= do top' <- showFlattenedExpSet top
bottom' <- showFlattenedExpSet bottom
@ -127,6 +129,12 @@ 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 [] = Just 0
onlyConst ((Const n):es) = liftM2 (+) (return n) $ onlyConst es
onlyConst _ = Nothing
makeExpSet :: [FlattenedExp] -> Either String (Set.Set FlattenedExp)
makeExpSet = foldM makeExpSet' Set.empty
where
@ -389,11 +397,6 @@ makeEquations es high = makeEquations' >>* (\(s,v,lh) -> [(s,squareEquations eqI
makeEquation' m (Divide top bottom) = throwError "TODO Divide"
onlyConst :: [FlattenedExp] -> Maybe Integer
onlyConst [] = Just 0
onlyConst ((Const n):es) = liftM2 (+) (return n) $ onlyConst es
onlyConst _ = Nothing
empty :: [(Map.Map Int Integer,[Map.Map Int Integer], [Map.Map Int Integer])]
empty = [(Map.empty,[],[])]