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 902 - (view) (download)
Original Path: sml/trunk/src/compiler/ElabData/statenv/statenv.sml

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 :     exception SpecialEnv = E.SpecialEnv
19 :    
20 :     fun aug x = (x, NONE)
21 :     fun strip (rb: real_binding) = #1 rb
22 :    
23 :     val empty = E.empty
24 :     fun look (e, s) = strip (E.look (e, s))
25 :     val bind0 = E.bind
26 :     fun bind (s, b, e) = E.bind (s, aug b, e)
27 :     fun special (mkb, mks) = E.special (aug o mkb, mks)
28 :     val atop = E.atop
29 :     val consolidate = E.consolidate
30 :     val consolidateLazy = E.consolidateLazy
31 :     fun app f e = E.app (fn (s, b) => f (s, strip b)) e
32 :     fun map f e = E.map (aug o f o strip) e
33 :     fun fold f x0 e = E.fold (fn ((s, b), x) => f ((s, strip b), x)) x0 e
34 :     val realfold = E.fold
35 :     val symbols = E.symbols
36 :    
37 :     (*
38 :     * sort: sort the bindings in an environment.
39 :     *
40 :     * This is used for the assignment of dynamic access slots in structure
41 :     * elaborate, for printing, and for other purposes.
42 :     * The bindings are sorted in the following order:
43 :     *
44 :     * values
45 :     * constructors
46 :     * types
47 :     * signatures
48 :     * structures
49 :     * funsigs
50 :     * functors
51 :     * fixity declarations
52 :     *
53 :     * It is only correct to sort environments which have no duplicate bindings.
54 :     * All routines which build structure environments maintain this
55 :     * invariant, so it is ok to sort any structure environment using
56 :     * this function.
57 :     *)
58 :    
59 :     fun sort env = ListMergeSort.sort B.binderGt (fold (op ::) nil env)
60 :    
61 :     end (* local *)
62 :     end (* structure StaticEnv *)

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