From 713011534f54f0ee2af38d4e1236fa07e43b7aff Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 13 Nov 2008 13:02:46 +0000 Subject: [PATCH] Corrected the nodes searched during the flow analysis I was searching starting at the current node, but I actually should have started at the terminal node connected to the current node as I need to process all the nodes ahead of me -- but in a backwards flow --- checks/CheckFramework.hs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/checks/CheckFramework.hs b/checks/CheckFramework.hs index d9a560a..8f39fc7 100644 --- a/checks/CheckFramework.hs +++ b/checks/CheckFramework.hs @@ -262,12 +262,20 @@ getVarsTouchedAfter = do Just vs -> return vs -} +-- | Searches forward in the graph from the given node to find all the reachable +-- nodes that have no successors, i.e. the terminal nodes +findTerminals :: Node -> Gr a b -> [Node] +findTerminals n g = nub [x | x <- dfs [n] g, null (suc g x)] + varsTouchedAfter :: FlowGraphAnalysis (Set.Set Var) varsTouchedAfter = FlowGraphAnalysis nextVarsTouched (\x d -> d {nextVarsTouched = Just x}) $ \(g, startNode) -> - case flowAlgorithm (funcs g) (rdfs [startNode] g) (startNode, Set.empty) of + let [termNode] = findTerminals startNode g + connNodes = rdfs [termNode] g in + case flowAlgorithm (funcs g) connNodes (termNode, Set.empty) of Left err -> dieP emptyMeta err - Right nodesToVars -> (liftIO $ putStrLn $ show g) >> return nodesToVars + Right nodesToVars -> (liftIO $ putStrLn $ "Graph:\n" ++ show g ++ "\n\nNodes:\n" + ++ show (termNode, connNodes)) >> return nodesToVars where funcs :: FlowGraph CheckOptM UsageLabel -> GraphFuncs Node EdgeLabel (Set.Set Var) funcs g = GF @@ -319,6 +327,7 @@ getCachedAnalysis' f an = do case find (\(_,l) -> f (getNodeData l) && (getNodeRouteId l == r)) (labNodes g) of Nothing -> dieP emptyMeta $ "Node not found in flow graph: " ++ show g Just (n, _) -> do + liftIO $ putStrLn $ "\nUsing node: " ++ show n ++ "\n" m <- case getFlowGraphAnalysis an d of Just y -> return y Nothing -> liftCheckOptM $