Corrected a couple of uses of flowAlgorithm to use the connected nodes, not all the remaining nodes in the graph
This commit is contained in:
parent
7e0bc775bf
commit
cf35eb97d3
|
@ -159,7 +159,7 @@ checkInitVar m graph startNode
|
||||||
-- Now we check that for every variable read in each node, it has already been written to by then
|
-- Now we check that for every variable read in each node, it has already been written to by then
|
||||||
mapM_ (checkInitVar' vwb) (map readNode labelledConnectedNodes)
|
mapM_ (checkInitVar' vwb) (map readNode labelledConnectedNodes)
|
||||||
where
|
where
|
||||||
connectedNodes = dfs [startNode] graph
|
connectedNodes = udfs [startNode] graph
|
||||||
|
|
||||||
-- Gets all variables read-from in a particular node, and the node identifier
|
-- Gets all variables read-from in a particular node, and the node identifier
|
||||||
readNode :: (Node, FNode m UsageLabel) -> (Node, ExSet Var)
|
readNode :: (Node, FNode m UsageLabel) -> (Node, ExSet Var)
|
||||||
|
|
|
@ -132,7 +132,7 @@ checkPar getRep f g = mapM f =<< allParItems
|
||||||
findReachDef :: forall m. Monad m => FlowGraph m UsageLabel -> Node -> Either String (Map.Map Node (Map.Map Var (Set.Set (Maybe
|
findReachDef :: forall m. Monad m => FlowGraph m UsageLabel -> Node -> Either String (Map.Map Node (Map.Map Var (Set.Set (Maybe
|
||||||
A.Expression))))
|
A.Expression))))
|
||||||
findReachDef graph startNode
|
findReachDef graph startNode
|
||||||
= do r <- flowAlgorithm graphFuncs (nodes graph) (startNode, Map.empty)
|
= do r <- flowAlgorithm graphFuncs (udfs [startNode] graph) (startNode, Map.empty)
|
||||||
-- These lines remove the maps where the variable is not read in that particular node:
|
-- These lines remove the maps where the variable is not read in that particular node:
|
||||||
let r' = Map.mapWithKey (\n -> Map.filterWithKey (readInNode' n)) r
|
let r' = Map.mapWithKey (\n -> Map.filterWithKey (readInNode' n)) r
|
||||||
return $ Map.filter (not . Map.null) r'
|
return $ Map.filter (not . Map.null) r'
|
||||||
|
|
|
@ -53,6 +53,11 @@ data GraphFuncs n e result = GF {
|
||||||
-- (i.e. where nodesToProcess returns the empty list) in the list except the
|
-- (i.e. where nodesToProcess returns the empty list) in the list except the
|
||||||
-- starting node.
|
-- starting node.
|
||||||
--
|
--
|
||||||
|
-- The implication of the above is that you should /not/ pass as the second
|
||||||
|
-- parameter all the nodes in the graph (unless you /know/ that it is fully
|
||||||
|
-- connected). Instead you should pass the connected nodes, using @(udfs [startNode]
|
||||||
|
-- graph)@.
|
||||||
|
--
|
||||||
-- The general idea of iterative data-flow is that all nodes start out with
|
-- The general idea of iterative data-flow is that all nodes start out with
|
||||||
-- a default "guessed" value. Then each node is processed in turn by using
|
-- a default "guessed" value. Then each node is processed in turn by using
|
||||||
-- the previous value (to start with, the default value), and the values of
|
-- the previous value (to start with, the default value), and the values of
|
||||||
|
|
Loading…
Reference in New Issue
Block a user