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

SCM Repository

[smlnj] Annotation of /sml/trunk/src/cm/depend/indegree.sml
ViewVC logotype

Annotation of /sml/trunk/src/cm/depend/indegree.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 456 - (view) (download)

1 : blume 454 (*
2 :     * Calculate a map of in-degrees (= # of SNODEs that depend on it) for each
3 :     * SNODE.
4 :     * (The in-degree of a node can serve as a hint for prioritizing
5 :     * compilations during parallel make.)
6 :     *
7 :     * (C) 1999 Lucent Technologies, Bell Laboratories
8 :     *
9 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
10 :     *)
11 :     local
12 :     structure GG = GroupGraph
13 :     structure DG = DependencyGraph
14 :     structure M = SmlInfoMap
15 :     in
16 :     signature INDEGREE = sig
17 :     val indegrees : GG.group -> int M.map
18 :     end
19 :    
20 :     structure Indegree :> INDEGREE = struct
21 :    
22 :     fun indegrees (GG.GROUP { exports, ... }) = let
23 :     fun fsb sn ((_, DG.SB_SNODE n), m) = sn (n, m)
24 :     | fsb _ (_, m) = m
25 :    
26 :     fun inc_sn (DG.SNODE { smlinfo = i, ... }, m) =
27 :     M.insert (m, i, 1 + getOpt (M.find (m, i), 0))
28 :    
29 :     fun snode (DG.SNODE n, m) = let
30 :     val { smlinfo = i, localimports = li, globalimports = gi } = n
31 :     val m =
32 :     case M.find (m, i) of
33 :     SOME _ => m
34 :     | NONE => foldl snode
35 :     (foldl (fsb snode)
36 :     (M.insert (m, i, 0))
37 :     gi)
38 :     li
39 :     in
40 :     foldl inc_sn (foldl (fsb inc_sn) m gi) li
41 :     end
42 :    
43 :     fun impexp ((n, _), m) = fsb snode (n, m)
44 :     in
45 : blume 456 SymbolMap.foldl impexp M.empty exports
46 : blume 454 end
47 :     end
48 :     end

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