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 879 - (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 : blume 879 val cvt : Environment.staticEnv -> DAEnv.env * (unit -> SymbolSet.set)
10 : blume 310
11 :     (* The thunk passed to cvtMemo will not be called until the first
12 :     * attempt to query the resulting DAEnv.env.
13 :     * If the symbols for which queries succeed are known, then one
14 :     * should further guard the resulting env with an appropriate filter
15 :     * to avoid queries that are known in advance to be unsuccessful
16 :     * because they would needlessly cause the thunk to be called. *)
17 : blume 879 val cvtMemo : (unit -> Environment.staticEnv) -> DAEnv.env
18 : blume 309 end
19 :    
20 :     structure Statenv2DAEnv :> STATENV2DAENV = struct
21 :    
22 : blume 879 structure E = Environment
23 : blume 309
24 : blume 310 fun cvt_fctenv look = DAEnv.FCTENV (cvt_result o look)
25 :    
26 : blume 587 and cvt_result (E.CM_ENV { look, ... }) = SOME (cvt_fctenv look)
27 :     | cvt_result E.CM_NONE = NONE
28 : blume 310
29 : blume 355 fun cvt sb = let
30 : blume 309 fun l2s l = let
31 :     fun addModule (sy, set) =
32 :     case Symbol.nameSpace sy of
33 :     (Symbol.STRspace | Symbol.SIGspace |
34 :     Symbol.FCTspace | Symbol.FSIGspace) =>
35 :     SymbolSet.add (set, sy)
36 :     | _ => set
37 :     in
38 :     foldl addModule SymbolSet.empty l
39 :     end
40 : blume 587 val dae = cvt_fctenv (E.cmEnvOfModule sb)
41 :     fun mkDomain () = l2s (E.catalogEnv sb)
42 : blume 309 in
43 :     (dae, mkDomain)
44 :     end
45 : blume 310
46 : blume 355 fun cvtMemo getSB = let
47 : blume 310 val l = ref (fn s => raise Fail "se2dae: uninitialized")
48 :     fun looker s = let
49 : blume 587 fun getCME () = E.cmEnvOfModule (getSB ())
50 : blume 310 val lk = cvt_result o (getCME ())
51 :     in
52 :     l := lk;
53 :     lk s
54 :     end
55 :     in
56 :     l := looker;
57 :     DAEnv.FCTENV (fn s => !l s)
58 :     end
59 : blume 309 end

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