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/semant/members.sml
ViewVC logotype

Annotation of /sml/trunk/src/cm/semant/members.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 274 - (view) (download)

1 : blume 267 (*
2 :     * Collections of members in CM descriptions.
3 :     * Involves:
4 :     * - running tools
5 :     * - fully analyzing sub-groups and sub-libraries
6 :     * - parsing ML files and getting their export lists
7 :     *
8 :     * (C) 1999 Lucent Technologies, Bell Laboratories
9 :     *
10 :     * Author: Matthias Blume (blume@kurims.kyoto-u.ac.jp)
11 :     *)
12 :     signature MEMBERCOLLECTION = sig
13 :    
14 : blume 269 type symbol = GenericVC.Symbol.symbol
15 : blume 270 type smlinfo = SmlInfo.info
16 : blume 269
17 : blume 270 exception DuplicateImport of symbol * string * string
18 :     exception DuplicateDefinition of symbol * string * string
19 : blume 269
20 : blume 267 type collection
21 :    
22 : blume 274 val empty : collection
23 :    
24 : blume 270 val expandOne : (AbsPath.t -> DependencyGraph.farnode SymbolMap.map)
25 :     -> { sourcepath: AbsPath.t, group: AbsPath.t, class: string option }
26 :     -> collection
27 : blume 267 val sequential : collection * collection -> collection
28 :    
29 : blume 268 val num_look : collection -> string -> int
30 :     val ml_look : collection -> GenericVC.Symbol.symbol -> bool
31 :     val cm_look : collection -> string -> bool
32 : blume 267 end
33 :    
34 :     structure MemberCollection :> MEMBERCOLLECTION = struct
35 :    
36 : blume 269 structure DG = DependencyGraph
37 : blume 267
38 : blume 270 type smlinfo = SmlInfo.info
39 : blume 269 type symbol = GenericVC.Symbol.symbol
40 : blume 267
41 : blume 270 exception DuplicateImport of symbol * string * string
42 :     exception DuplicateDefinition of symbol * string * string
43 : blume 269
44 :     datatype collection =
45 :     COLLECTION of { subexports: DG.farnode SymbolMap.map,
46 :     smlfiles: smlinfo list,
47 :     localdefs: smlinfo SymbolMap.map }
48 :    
49 : blume 274 val empty =
50 :     COLLECTION { subexports = SymbolMap.empty,
51 :     smlfiles = [],
52 :     localdefs = SymbolMap.empty }
53 :    
54 : blume 269 fun sequential (COLLECTION c1, COLLECTION c2) = let
55 : blume 270 fun se_error (s, (_, n1), (_, n2)) =
56 :     raise DuplicateImport (s, DG.describeNode n1, DG.describeNode n2)
57 : blume 269 val se_union = SymbolMap.unionWithi se_error
58 : blume 270 fun ld_error (s, f1, f2) =
59 :     raise DuplicateDefinition (s, SmlInfo.describe f1,
60 :     SmlInfo.describe f2)
61 : blume 269 val ld_union = SymbolMap.unionWithi ld_error
62 : blume 270
63 : blume 269 in
64 :     COLLECTION { subexports = se_union (#subexports c1, #subexports c2),
65 :     smlfiles = #smlfiles c1 @ #smlfiles c2,
66 :     localdefs = ld_union (#localdefs c1, #localdefs c2) }
67 :     end
68 :    
69 : blume 270 fun expandOne gexports { sourcepath, group, class } = let
70 : blume 274 fun noPrimitive () = let
71 :     val expansions = PrivateTools.expand (sourcepath, class)
72 :     fun exp2coll (PrivateTools.GROUP p) =
73 :     COLLECTION { subexports = gexports p,
74 :     smlfiles = [],
75 :     localdefs = SymbolMap.empty }
76 :     | exp2coll (PrivateTools.SMLSOURCE src) = let
77 :     val { sourcepath = p, history = h, share = s } = src
78 :     val i = SmlInfo.new
79 :     Policy.default
80 :     { sourcepath = p, group = group, history = h,
81 :     share = s, stableinfo = NONE }
82 :     val exports = SmlInfo.exports i
83 :     fun addLD (s, m) = SymbolMap.insert (m, s, i)
84 :     val ld = SymbolSet.foldl addLD SymbolMap.empty exports
85 :     in
86 :     COLLECTION { subexports = SymbolMap.empty,
87 :     smlfiles = [i],
88 :     localdefs = ld }
89 :     end
90 :     val collections = map exp2coll expansions
91 :     fun combine (c1, c2) = sequential (c2, c1)
92 :     in
93 :     foldl combine empty collections
94 :     end
95 :     in
96 :     if isSome class then noPrimitive ()
97 :     else case Primitive.fromString (AbsPath.spec sourcepath) of
98 :     SOME p => let
99 : blume 270 val exports = Primitive.exports p
100 :     fun addFN (s, m) =
101 :     SymbolMap.insert (m, s, (NONE, DG.PNODE p))
102 :     val se = SymbolSet.foldl addFN SymbolMap.empty exports
103 :     in
104 :     COLLECTION { subexports = se,
105 :     smlfiles = [],
106 :     localdefs = SymbolMap.empty }
107 :     end
108 : blume 274 | NONE => noPrimitive ()
109 : blume 270 end
110 :    
111 : blume 268 fun num_look (c: collection) (s: string) = 0
112 : blume 269
113 : blume 268 fun cm_look (c: collection) (s: string) = false
114 : blume 269
115 :     fun ml_look (COLLECTION { subexports, localdefs, ... }) s =
116 :     isSome (SymbolMap.find (subexports, s)) orelse
117 :     isSome (SymbolMap.find (localdefs, s))
118 : blume 267 end

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