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 587 - (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 587 val cvt : GenericVC.Environment.staticEnv ->
10 : blume 355 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 : blume 587 (unit -> GenericVC.Environment.staticEnv) ->
20 : blume 310 DAEnv.env
21 : blume 309 end
22 :    
23 :     structure Statenv2DAEnv :> STATENV2DAENV = struct
24 :    
25 : blume 587 structure E = GenericVC.Environment
26 : blume 309
27 : blume 310 fun cvt_fctenv look = DAEnv.FCTENV (cvt_result o look)
28 :    
29 : blume 587 and cvt_result (E.CM_ENV { look, ... }) = SOME (cvt_fctenv look)
30 :     | cvt_result E.CM_NONE = NONE
31 : blume 310
32 : blume 355 fun cvt sb = let
33 : blume 309 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 : blume 587 val dae = cvt_fctenv (E.cmEnvOfModule sb)
44 :     fun mkDomain () = l2s (E.catalogEnv sb)
45 : blume 309 in
46 :     (dae, mkDomain)
47 :     end
48 : blume 310
49 : blume 355 fun cvtMemo getSB = let
50 : blume 310 val l = ref (fn s => raise Fail "se2dae: uninitialized")
51 :     fun looker s = let
52 : blume 587 fun getCME () = E.cmEnvOfModule (getSB ())
53 : blume 310 val lk = cvt_result o (getCME ())
54 :     in
55 :     l := lk;
56 :     lk s
57 :     end
58 :     in
59 :     l := looker;
60 :     DAEnv.FCTENV (fn s => !l s)
61 :     end
62 : blume 309 end

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