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 588 - (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 : blume 537 val getStable : { stable: string, offset: int, descr: string } -> bfc
20 : blume 403 end
21 :    
22 :     functor BfcFn (structure MachDepVC : MACHDEP_VC) :> BFC
23 :     where type bfc = MachDepVC.Binfile.bfContent =
24 :     struct
25 :    
26 :     structure BF = MachDepVC.Binfile
27 :     structure E = GenericVC.Environment
28 :     type bfc = BF.bfContent
29 :    
30 : blume 588 val emap = GenericVC.ModuleId.emptyTmap
31 : blume 403
32 :     fun new () = let
33 :     val m = ref SmlInfoMap.empty
34 :    
35 :     fun store (i, bfc) = m := SmlInfoMap.insert (!m, i, bfc)
36 :    
37 :     fun get i =
38 :     case SmlInfoMap.find (!m, i) of
39 :     SOME bfc => bfc
40 :     | NONE => let
41 :     val binname = SmlInfo.binname i
42 :     fun reader s = let
43 :     val bfc = BF.read { stream = s, name = binname,
44 : blume 588 modmap = emap }
45 : blume 403 in
46 :     store (i, bfc);
47 :     bfc
48 :     end
49 :     in
50 :     SafeIO.perform { openIt = fn () => BinIO.openIn binname,
51 :     closeIt = BinIO.closeIn,
52 :     work = reader,
53 : blume 459 cleanup = fn _ => () }
54 : blume 403 end
55 :     in
56 :     { store = store, get = get }
57 :     end
58 : blume 537
59 :     fun getStable { stable, offset, descr } = let
60 :     fun work s =
61 :     (Seek.seek (s, offset);
62 :     (* We can use an empty static env because no
63 :     * unpickling will be done. *)
64 : blume 588 BF.read { stream = s, name = descr, modmap = emap })
65 : blume 537 in
66 :     SafeIO.perform { openIt = fn () => BinIO.openIn stable,
67 :     closeIt = BinIO.closeIn,
68 :     work = work,
69 :     cleanup = fn _ => () }
70 :     end
71 : blume 403 end

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