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/branches/primop-branch/src/compiler/ElabData/statenv/statenv.sml
ViewVC logotype

Annotation of /sml/branches/primop-branch/src/compiler/ElabData/statenv/statenv.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1471 - (view) (download)

1 : blume 902 (* statenv.sml
2 :     *
3 :     * (C) 2001 Lucent Technologies, Bell Labs
4 :     *)
5 :     structure StaticEnv : STATICENV =
6 :     struct
7 :    
8 :     local structure B = Bindings
9 :     structure E = Env
10 :     structure M = Modules
11 :     in
12 :    
13 :     type binding = B.binding
14 :     type real_binding = binding * M.modtree option
15 :     type staticEnv = real_binding E.env
16 :    
17 :     exception Unbound = E.Unbound
18 :    
19 :     fun aug x = (x, NONE)
20 :     fun strip (rb: real_binding) = #1 rb
21 :    
22 :     val empty = E.empty
23 :     fun look (e, s) = strip (E.look (e, s))
24 :     val bind0 = E.bind
25 :     fun bind (s, b, e) = E.bind (s, aug b, e)
26 :     fun special (mkb, mks) = E.special (aug o mkb, mks)
27 :     val atop = E.atop
28 :     val consolidate = E.consolidate
29 :     val consolidateLazy = E.consolidateLazy
30 :     fun app f e = E.app (fn (s, b) => f (s, strip b)) e
31 :     fun map f e = E.map (aug o f o strip) e
32 :     fun fold f x0 e = E.fold (fn ((s, b), x) => f ((s, strip b), x)) x0 e
33 :     val realfold = E.fold
34 :     val symbols = E.symbols
35 :    
36 :     (*
37 :     * sort: sort the bindings in an environment.
38 :     *
39 :     * This is used for the assignment of dynamic access slots in structure
40 :     * elaborate, for printing, and for other purposes.
41 :     * The bindings are sorted in the following order:
42 :     *
43 :     * values
44 :     * constructors
45 :     * types
46 :     * signatures
47 :     * structures
48 :     * funsigs
49 :     * functors
50 :     * fixity declarations
51 :     *
52 :     * It is only correct to sort environments which have no duplicate bindings.
53 :     * All routines which build structure environments maintain this
54 :     * invariant, so it is ok to sort any structure environment using
55 :     * this function.
56 :     *)
57 :    
58 :     fun sort env = ListMergeSort.sort B.binderGt (fold (op ::) nil env)
59 :    
60 : blume 905 fun filter (e, l) =
61 :     let fun add (sy, e') = bind (sy, look (e, sy), e') handle Unbound => e'
62 :     in foldl add empty l
63 :     end
64 :    
65 : blume 902 end (* local *)
66 :     end (* structure StaticEnv *)

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