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 652 - (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 : blume 587 fun indegrees GG.ERRORGROUP = M.empty
23 :     | indegrees (GG.GROUP { exports, ... }) = let
24 : blume 454 fun fsb sn ((_, DG.SB_SNODE n), m) = sn (n, m)
25 :     | fsb _ (_, m) = m
26 :    
27 :     fun inc_sn (DG.SNODE { smlinfo = i, ... }, m) =
28 :     M.insert (m, i, 1 + getOpt (M.find (m, i), 0))
29 :    
30 :     fun snode (DG.SNODE n, m) = let
31 :     val { smlinfo = i, localimports = li, globalimports = gi } = n
32 :     val m =
33 :     case M.find (m, i) of
34 :     SOME _ => m
35 :     | NONE => foldl snode
36 :     (foldl (fsb snode)
37 :     (M.insert (m, i, 0))
38 :     gi)
39 :     li
40 :     in
41 :     foldl inc_sn (foldl (fsb inc_sn) m gi) li
42 :     end
43 :    
44 : blume 652 fun impexp ((nth, _, _), m) = fsb snode (nth (), m)
45 : blume 454 in
46 : blume 456 SymbolMap.foldl impexp M.empty exports
47 : blume 454 end
48 :     end
49 :     end

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