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:
Neil Brown 2008-06-05 20:35:43 +00:00
parent 7e0bc775bf
commit cf35eb97d3
3 changed files with 7 additions and 2 deletions

View File

@ -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
mapM_ (checkInitVar' vwb) (map readNode labelledConnectedNodes)
where
connectedNodes = dfs [startNode] graph
connectedNodes = udfs [startNode] graph
-- Gets all variables read-from in a particular node, and the node identifier
readNode :: (Node, FNode m UsageLabel) -> (Node, ExSet Var)

View File

@ -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
A.Expression))))
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:
let r' = Map.mapWithKey (\n -> Map.filterWithKey (readInNode' n)) r
return $ Map.filter (not . Map.null) r'

View File

@ -53,6 +53,11 @@ data GraphFuncs n e result = GF {
-- (i.e. where nodesToProcess returns the empty list) in the list except the
-- 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
-- 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