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

SCM Repository

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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (download) (annotate)
Thu Jun 1 18:34:03 2000 UTC (19 years, 3 months ago) by monnier
File size: 1273 byte(s)
bring revisions from the vendor branch to the trunk
(*
 * Calculate a map of in-degrees (= # of SNODEs that depend on it) for each
 * SNODE.
 * (The in-degree of a node can serve as a hint for prioritizing
 *  compilations during parallel make.)
 *
 * (C) 1999 Lucent Technologies, Bell Laboratories
 *
 * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
 *)
local
    structure GG = GroupGraph
    structure DG = DependencyGraph
    structure M = SmlInfoMap
in
    signature INDEGREE = sig
	val indegrees : GG.group -> int M.map
    end

    structure Indegree :> INDEGREE = struct
	
	fun indegrees GG.ERRORGROUP = M.empty
	  | indegrees (GG.GROUP { exports, ... }) = let
	    fun fsb sn ((_, DG.SB_SNODE n), m) = sn (n, m)
	      | fsb _ (_, m) = m

	    fun inc_sn (DG.SNODE { smlinfo = i, ... }, m) =
		M.insert (m, i, 1 + getOpt (M.find (m, i), 0))

	    fun snode (DG.SNODE n, m) = let
		val { smlinfo = i, localimports = li, globalimports = gi } = n
		val m =
		    case M.find (m, i) of
			SOME _ => m
		      | NONE => foldl snode
			              (foldl (fsb snode)
				             (M.insert (m, i, 0))
					     gi)
			              li
	    in
		foldl inc_sn (foldl (fsb inc_sn) m gi) li
	    end

	    fun impexp ((n, _), m) = fsb snode (n, m)
	in
	    SymbolMap.foldl impexp M.empty exports
	end
    end
end

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