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

Annotation of /sml/trunk/src/cm/compile/bfc.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 459 - (view) (download)

1 : blume 403 (*
2 :     * Keeping binfiles for short periods of time.
3 :     * This is used in "stabilize" and in "make" where first there is a
4 :     * "compile" traversal that produces certain binfile contents, and
5 :     * then there is a "consumer" traversal that uses the binfile contents.
6 :     * No error checking is done -- the "get" operation assumes that the
7 :     * stuff is either in its cache or in the file system.
8 : blume 404 * Moreover, the static environment cannot be used (BF.senvOf will fail
9 :     * if the binfile had to be reloaded from disk).
10 : blume 403 *
11 :     * (C) 1999 Lucent Technologies, Bell Laboratories
12 :     *
13 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
14 :     *)
15 :     signature BFC = sig
16 :     type bfc
17 :     val new : unit -> { store: SmlInfo.info * bfc -> unit,
18 :     get: SmlInfo.info -> bfc }
19 :     end
20 :    
21 :     functor BfcFn (structure MachDepVC : MACHDEP_VC) :> BFC
22 :     where type bfc = MachDepVC.Binfile.bfContent =
23 :     struct
24 :    
25 :     structure BF = MachDepVC.Binfile
26 :     structure E = GenericVC.Environment
27 :     type bfc = BF.bfContent
28 :    
29 :     val estat = E.staticPart E.emptyEnv
30 :    
31 :     fun new () = let
32 :     val m = ref SmlInfoMap.empty
33 :    
34 :     fun store (i, bfc) = m := SmlInfoMap.insert (!m, i, bfc)
35 :    
36 :     fun get i =
37 :     case SmlInfoMap.find (!m, i) of
38 :     SOME bfc => bfc
39 :     | NONE => let
40 :     val binname = SmlInfo.binname i
41 :     fun reader s = let
42 :     val bfc = BF.read { stream = s, name = binname,
43 :     senv = estat }
44 :     in
45 :     store (i, bfc);
46 :     bfc
47 :     end
48 :     in
49 :     SafeIO.perform { openIt = fn () => BinIO.openIn binname,
50 :     closeIt = BinIO.closeIn,
51 :     work = reader,
52 : blume 459 cleanup = fn _ => () }
53 : blume 403 end
54 :     in
55 :     { store = store, get = get }
56 :     end
57 :     end

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