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/se2dae.sml
ViewVC logotype

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

Parent Directory Parent Directory | Revision Log Revision Log

Revision 310 - (download) (annotate)
Wed Jun 2 07:28:27 1999 UTC (22 years ago) by blume
File size: 1801 byte(s)
stabilization code working but only flimsily hooked up
 * Convert a given static env to a "dependency-analysis env".
 * (C) 1999 Lucent Technologies, Bell Laboratories
 * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
signature STATENV2DAENV = sig
    val cvt :
	GenericVC.Environment.staticEnv -> DAEnv.env * (unit -> SymbolSet.set)

    (* The thunk passed to cvtMemo will not be called until the first
     * attempt to query the resulting DAEnv.env.
     * If the symbols for which queries succeed are known, then one
     * should further guard the resulting env with an appropriate filter
     * to avoid queries that are known in advance to be unsuccessful
     * because they would needlessly cause the thunk to be called. *)
    val cvtMemo :
	(unit -> GenericVC.Environment.staticEnv) ->

structure Statenv2DAEnv :> STATENV2DAENV = struct

    structure BE = GenericVC.BareEnvironment

    fun cvt_fctenv look = DAEnv.FCTENV (cvt_result o look)

    and cvt_result (BE.CM_ENV { look, ... }) = SOME (cvt_fctenv look)
      | cvt_result BE.CM_NONE = NONE

    fun cvt se = let
	fun l2s l = let
	    fun addModule (sy, set) =
		case Symbol.nameSpace sy of
		    (Symbol.STRspace | Symbol.SIGspace |
		     Symbol.FCTspace | Symbol.FSIGspace) =>
		    SymbolSet.add (set, sy)
		   | _ => set
	    foldl addModule SymbolSet.empty l
	val sb = GenericVC.CoerceEnv.es2bs se
	val dae = cvt_fctenv (BE.cmEnvOfModule sb)
	fun mkDomain () = l2s (BE.catalogEnv sb)
	(dae, mkDomain)

    fun cvtMemo getSE = let
	val l = ref (fn s => raise Fail "se2dae: uninitialized")
	fun looker s = let
	    fun getCME () =
		BE.cmEnvOfModule (GenericVC.CoerceEnv.es2bs (getSE ()))
	    val lk = cvt_result o (getCME ())
	    l := lk;
	    lk s
	l := looker;
	DAEnv.FCTENV (fn s => !l s)

ViewVC Help
Powered by ViewVC 1.0.0