Removed obsolete conditions from the valid set as we search for constraints
Previously, conditions from IF branches were being retained even after the end of the whole IF. Now I use the just-added information from the flow graph as to when those conditions are no longer applicable.
This commit is contained in:
parent
c315352647
commit
4b44da8008
|
@ -185,9 +185,9 @@ findConstraints :: Monad m => FlowGraph m UsageLabel -> Node -> Either String
|
||||||
(Map.Map Node [A.Expression])
|
(Map.Map Node [A.Expression])
|
||||||
findConstraints graph startNode
|
findConstraints graph startNode
|
||||||
= flowAlgorithm graphFuncs (dfs [startNode] graph) (startNode, [])
|
= flowAlgorithm graphFuncs (dfs [startNode] graph) (startNode, [])
|
||||||
>>* Map.filter (not . null)
|
>>* Map.map (map snd) >>* Map.filter (not . null)
|
||||||
where
|
where
|
||||||
graphFuncs :: GraphFuncs Node EdgeLabel [A.Expression]
|
graphFuncs :: GraphFuncs Node EdgeLabel [(Integer, A.Expression)]
|
||||||
graphFuncs = GF
|
graphFuncs = GF
|
||||||
{
|
{
|
||||||
nodeFunc = processNode
|
nodeFunc = processNode
|
||||||
|
@ -197,15 +197,20 @@ findConstraints graph startNode
|
||||||
, userErrLabel = (++ " in graph: " ++ makeFlowGraphInstr graph) . ("for node at: " ++) . show . fmap getNodeMeta . lab graph
|
, userErrLabel = (++ " in graph: " ++ makeFlowGraphInstr graph) . ("for node at: " ++) . show . fmap getNodeMeta . lab graph
|
||||||
}
|
}
|
||||||
|
|
||||||
processNode :: (Node, EdgeLabel) -> [A.Expression] -> Maybe [A.Expression]
|
processNode :: (Node, EdgeLabel) -> [(Integer, A.Expression)]
|
||||||
-> [A.Expression]
|
-> Maybe [(Integer, A.Expression)] -> [(Integer, A.Expression)]
|
||||||
processNode (n, e) nodeVal curAgg = case fmap getNodeData $ lab graph n of
|
processNode (n, e) nodeVal curAgg = case fmap getNodeData $ lab graph n of
|
||||||
Just u ->
|
Just u ->
|
||||||
let valFilt = filter (\e -> null $ intersect (listify (const
|
let overlapsWithWritten e = not $ null $ intersect
|
||||||
True) e) [v | Var v <- Map.keys $ writtenVars $ nodeVars u]) $
|
(listify (const True) e)
|
||||||
|
[v | Var v <- Map.keys $ writtenVars $ nodeVars u]
|
||||||
|
valFilt = filter (not . overlapsWithWritten) $
|
||||||
nub $ nodeVal ++ (case e of
|
nub $ nodeVal ++ (case e of
|
||||||
ESeq (Just (_, Just True)) -> maybeToList (nodeCond u)
|
ESeq (Just (n, Just True)) -> maybeToList (fmap ((,) n) $ nodeCond u)
|
||||||
_ -> []) in
|
_ -> [])
|
||||||
nub $ valFilt ++ fromMaybe [] curAgg
|
removeOld = case e of
|
||||||
|
ESeq (Just (n, Nothing)) -> filter ((/= n) . fst)
|
||||||
|
_ -> id
|
||||||
|
in removeOld $ nub $ valFilt ++ fromMaybe [] curAgg
|
||||||
Nothing -> []
|
Nothing -> []
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user