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/compiler/Semant/statenv/statenv.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/Semant/statenv/statenv.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 651 - (view) (download)

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

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