Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /sml/trunk/src/cm/depend/reachable.sml
ViewVC logotype

Diff of /sml/trunk/src/cm/depend/reachable.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 568, Tue Mar 7 03:59:09 2000 UTC revision 569, Tue Mar 7 04:01:07 2000 UTC
# Line 7  Line 7 
7   *)   *)
8  signature REACHABLE = sig  signature REACHABLE = sig
9      (* These two functions simply give you the set of (non-stable)      (* These two functions simply give you the set of (non-stable)
10       * modules reachable from some root. *)       * modules reachable from some root and the fringe of stable
11      val reachable' : DependencyGraph.impexp SymbolMap.map -> SmlInfoSet.set       * modules that surrounds the non-stable portion. *)
12      val reachable : GroupGraph.group -> SmlInfoSet.set      val reachable' :
13            DependencyGraph.sbnode list -> SmlInfoSet.set * StableSet.set
14        val reachable : GroupGraph.group -> SmlInfoSet.set * StableSet.set
15    
16      (* "snodeMap" gives us handles at arbitrary points within the (non-stable)      (* "snodeMap" gives us handles at arbitrary points within the (non-stable)
17       * portion of a dependency graph.       * portion of a dependency graph.
# Line 28  Line 30 
30      (* Given a "closed" subset of (non-stable) nodes in a dependency graph,      (* Given a "closed" subset of (non-stable) nodes in a dependency graph,
31       * "frontier" gives you the set of frontier nodes of that set.  The       * "frontier" gives you the set of frontier nodes of that set.  The
32       * closed set is given by its indicator function (first argument).       * closed set is given by its indicator function (first argument).
33       * ("closed" means that any node that if a node's ancestors are all in       * ("closed" means that if a node's ancestors are all in
34       * the set, then so is the node itself.  A frontier node is a node that       * the set, then so is the node itself.  A frontier node is a node that
35       * is in the set but either not all of its ancestors are or the node       * is in the set but either not all of its ancestors are or the node
36       * is an export node.) *)       * is an export node.) *)
# Line 40  Line 42 
42      structure GG = GroupGraph      structure GG = GroupGraph
43    
44      local      local
45          fun reach ops (exports: DG.impexp SymbolMap.map) = let          fun reach ops (export_nodes: DG.sbnode list) = let
46              val { add, member, empty } = ops              val { add, member, empty } = ops
47              fun snode (x as DG.SNODE n, known) = let              fun snode (x as DG.SNODE n, (known, stabfringe)) = let
48                  val { smlinfo = i, localimports = l, globalimports = g } = n                  val { smlinfo = i, localimports = l, globalimports = g } = n
49              in              in
50                  if member (known, i) then known                  if member (known, i) then (known, stabfringe)
51                  else foldl farsbnode (foldl snode (add (known, i, x)) l) g                  else foldl farsbnode
52                               (foldl snode (add (known, i, x), stabfringe) l)
53                               g
54              end              end
55    
56              and farsbnode ((_, n), known) = sbnode (n, known)              and farsbnode ((_, n), ksf) = sbnode (n, ksf)
57    
58              and sbnode (DG.SB_BNODE _, known) = known              and sbnode (DG.SB_BNODE (DG.BNODE n, _), (known, stabfringe)) =
59                | sbnode (DG.SB_SNODE n, known) = snode (n, known)                  (known, StableSet.add (stabfringe, #bininfo n))
60                  | sbnode (DG.SB_SNODE n, ksf) = snode (n, ksf)
             fun impexp ((n, _), known) = farsbnode (n, known)  
61          in          in
62              SymbolMap.foldl impexp empty exports              foldl sbnode (empty, StableSet.empty) export_nodes
63          end          end
64    
65          fun snodeMap' (exports, acc) = let          fun snodeMap' (exports: DG.impexp SymbolMap.map, acc) = let
66              fun add (m, i, x) = SrcPathMap.insert (m, SmlInfo.sourcepath i, x)              fun add (m, i, x) = SrcPathMap.insert (m, SmlInfo.sourcepath i, x)
67              fun member (m, i) = SrcPathMap.inDomain (m, SmlInfo.sourcepath i)              fun member (m, i) = SrcPathMap.inDomain (m, SmlInfo.sourcepath i)
68          in          in
69              reach { add = add, member = member, empty = acc } exports              #1 (reach { add = add, member = member, empty = acc }
70                          (map (#2 o #1) (SymbolMap.listItems exports)))
71          end          end
72      in      in
73          val reachable' =          val reachable' =
# Line 71  Line 75 
75                      member = SmlInfoSet.member,                      member = SmlInfoSet.member,
76                      empty = SmlInfoSet.empty }                      empty = SmlInfoSet.empty }
77    
78          fun reachable (GG.GROUP { exports, ... }) = reachable' exports          fun reachable (GG.GROUP { exports, ... }) =
79                          reachable' (map (#2 o #1) (SymbolMap.listItems exports))
80    
81          fun snodeMap g = let          fun snodeMap g = let
82              fun snm (g, (a, seen)) = let              fun snm (g, (a, seen)) = let

Legend:
Removed from v.568  
changed lines
  Added in v.569

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0