3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovCopyright : (c) Uni Bremen 2003-2007
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovLicense : GPLv2 or higher, see LICENSE.txt
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovMaintainer : raider@informatik.uni-bremen.de
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovStability : unstable
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovPortability : non-portable
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovThis Modul provides a function to display a Library Dependency Graph.
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov ( showLibGraph
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov , closeOpenWindows
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovimport Driver.Options (HetcatsOpts (outtypes, verbose))
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashovimport GUI.GraphLogic (translateGraph, showDGraph)
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashovimport qualified GUI.GraphAbstraction as GA
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovimport qualified Common.Lib.Rel as Rel
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovimport qualified Data.Map as Map
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovimport qualified Data.Set as Set
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashovtype NodeEdgeList = ([DaVinciNode LibName], [DaVinciArc (IO String)])
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov{- | Creates a new uDrawGraph Window and shows the Library Dependency Graph of
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov the given LibEnv. -}
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovshowLibGraph :: LibFunc
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovshowLibGraph gi = do
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov let lock = libGraphLock gi
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov isEmpty <- isEmptyMVar lock
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov when isEmpty $ do
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov putMVar lock ()
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov updateWindowCount gi succ
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov graph <- newIORef daVinciSort
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov nodesEdges <- newIORef (([], []) :: NodeEdgeList)
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov GlobalMenu (UDG.Menu Nothing
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov [ Button "Reload Library" $ reloadLibGraph gi graph nodesEdges
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov , Button "Experimental reload changed Library"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov $ changeLibGraph gi graph nodesEdges
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov , Button "Translate Library" $ translate gi
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov , Button "Show Logic Graph" showLG
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov graphParms = globalMenu $$
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov GraphTitle "Hets Library Graph" $$
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov OptimiseLayout True $$
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov AllowClose (closeGInfo gi) $$
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov FileMenuAct ExitMenuOption (Just (exitGInfo gi)) $$
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov emptyGraphParms
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov graph' <- newGraph daVinciSort graphParms
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov addNodesAndEdges gi graph graph' nodesEdges
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai KondrashovcloseGInfo :: GInfo -> IO Bool
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovcloseGInfo gi = do
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov updateWindowCount gi pred
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov takeMVar (libGraphLock gi)
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov-- | Reloads all Libraries and the Library Dependency Graph
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovreloadLibGraph :: GInfo -> IORef DaVinciGraphTypeSyn -> IORef NodeEdgeList
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovreloadLibGraph gi graph nodesEdges = do
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov b <- warningDialog "Reload library" warnTxt
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov when b $ reloadLibGraph' gi graph nodesEdges
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovwarnTxt :: String
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovwarnTxt = unlines
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov [ "Are you sure to recreate Library?"
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov , "All development graph windows will be closed and proofs will be lost."
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov , "", "This operation can not be undone." ]
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov-- | Reloads all Libraries and the Library Dependency Graph
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai KondrashovreloadLibGraph' :: GInfo -> IORef DaVinciGraphTypeSyn -> IORef NodeEdgeList
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai KondrashovreloadLibGraph' gi graph nodesEdges = do
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov graph' <- readIORef graph
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov (nodes, edges) <- readIORef nodesEdges
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov let ln = libName gi
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov libfile = libNameToFile ln
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov m <- anaLib (hetcatsOpts gi) { outtypes = [] } libfile
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov Nothing -> errorDialog "Error" $ "Error when reloading file '"
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov ++ libfile ++ "'"
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov Just (_, le) -> do
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov closeOpenWindows gi
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov mapM_ (deleteArc graph') edges
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov mapM_ (deleteNode graph') nodes
96544fca522e66b4f69b4252854a5f672c96f9c4Nikolai Kondrashov addNodesAndEdges gi graph graph' nodesEdges
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov writeIORef (intState gi) emptyIntState
96544fca522e66b4f69b4252854a5f672c96f9c4Nikolai Kondrashov { i_state = Just $ emptyIntIState le ln
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov , filename = libfile }
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov mShowGraph gi ln
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai KondrashovchangeLibGraph :: GInfo -> IORef DaVinciGraphTypeSyn -> IORef NodeEdgeList
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai KondrashovchangeLibGraph gi graph nodesEdges = do
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov let ln = libName gi
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov opts = hetcatsOpts gi
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov ost <- readIORef $ intState gi
5f4f0428c182a9e77d29b39f3749fce03643ac8dNikolai Kondrashov graph' <- readIORef graph
3ce85a5f5264e7118beb6524e120fd8b53a13da4Nikolai Kondrashov (nodes, edges) <- readIORef nodesEdges
c2 = ToXml.dGraph opts le ln dgold
c3 = ToXml.dGraph opts nle ln ndg
writeIORef iorOpenGraphs Map.empty
lookup' x y = Map.findWithDefault
keySet = Map.keysSet le
keys = Set.toList keySet
subNodeMenu = LocalMenu (UDG.Menu Nothing [
Button "Show spec/View Names" $ showSpec le])
nodes' = Map.fromList $ zip keys subNodeList
subArcMenu = LocalMenu (UDG.Menu Nothing [])
getLibDeps :: Set.Set LibName -> LibEnv -> [(LibName, LibName)]
$ unlines . map show . Map.keys . globalEnv