diff --git a/checks/Check.hs b/checks/Check.hs index f85e881..055b946 100644 --- a/checks/Check.hs +++ b/checks/Check.hs @@ -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) diff --git a/checks/UsageCheckAlgorithms.hs b/checks/UsageCheckAlgorithms.hs index 2c3b402..5f22a44 100644 --- a/checks/UsageCheckAlgorithms.hs +++ b/checks/UsageCheckAlgorithms.hs @@ -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' diff --git a/flow/FlowAlgorithms.hs b/flow/FlowAlgorithms.hs index 296c5d4..c9e25fd 100644 --- a/flow/FlowAlgorithms.hs +++ b/flow/FlowAlgorithms.hs @@ -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