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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 310 - (view) (download)

1 : blume 309 (*
2 :     * Convert a given static env to a "dependency-analysis env".
3 :     *
4 :     * (C) 1999 Lucent Technologies, Bell Laboratories
5 :     *
6 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
7 :     *)
8 :     signature STATENV2DAENV = sig
9 :     val cvt :
10 :     GenericVC.Environment.staticEnv -> DAEnv.env * (unit -> SymbolSet.set)
11 : blume 310
12 :     (* The thunk passed to cvtMemo will not be called until the first
13 :     * attempt to query the resulting DAEnv.env.
14 :     * If the symbols for which queries succeed are known, then one
15 :     * should further guard the resulting env with an appropriate filter
16 :     * to avoid queries that are known in advance to be unsuccessful
17 :     * because they would needlessly cause the thunk to be called. *)
18 :     val cvtMemo :
19 :     (unit -> GenericVC.Environment.staticEnv) ->
20 :     DAEnv.env
21 : blume 309 end
22 :    
23 :     structure Statenv2DAEnv :> STATENV2DAENV = struct
24 :    
25 :     structure BE = GenericVC.BareEnvironment
26 :    
27 : blume 310 fun cvt_fctenv look = DAEnv.FCTENV (cvt_result o look)
28 :    
29 :     and cvt_result (BE.CM_ENV { look, ... }) = SOME (cvt_fctenv look)
30 :     | cvt_result BE.CM_NONE = NONE
31 :    
32 : blume 309 fun cvt se = let
33 :     fun l2s l = let
34 :     fun addModule (sy, set) =
35 :     case Symbol.nameSpace sy of
36 :     (Symbol.STRspace | Symbol.SIGspace |
37 :     Symbol.FCTspace | Symbol.FSIGspace) =>
38 :     SymbolSet.add (set, sy)
39 :     | _ => set
40 :     in
41 :     foldl addModule SymbolSet.empty l
42 :     end
43 :     val sb = GenericVC.CoerceEnv.es2bs se
44 :     val dae = cvt_fctenv (BE.cmEnvOfModule sb)
45 :     fun mkDomain () = l2s (BE.catalogEnv sb)
46 :     in
47 :     (dae, mkDomain)
48 :     end
49 : blume 310
50 :     fun cvtMemo getSE = let
51 :     val l = ref (fn s => raise Fail "se2dae: uninitialized")
52 :     fun looker s = let
53 :     fun getCME () =
54 :     BE.cmEnvOfModule (GenericVC.CoerceEnv.es2bs (getSE ()))
55 :     val lk = cvt_result o (getCME ())
56 :     in
57 :     l := lk;
58 :     lk s
59 :     end
60 :     in
61 :     l := looker;
62 :     DAEnv.FCTENV (fn s => !l s)
63 :     end
64 : blume 309 end

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