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 272 - (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 270 val expandOne : (AbsPath.t -> DependencyGraph.farnode SymbolMap.map)
23 :     -> { sourcepath: AbsPath.t, group: AbsPath.t, class: string option }
24 :     -> collection
25 : blume 267 val sequential : collection * collection -> collection
26 :    
27 : blume 268 val num_look : collection -> string -> int
28 :     val ml_look : collection -> GenericVC.Symbol.symbol -> bool
29 :     val cm_look : collection -> string -> bool
30 : blume 267 end
31 :    
32 :     structure MemberCollection :> MEMBERCOLLECTION = struct
33 :    
34 : blume 269 structure DG = DependencyGraph
35 : blume 267
36 : blume 270 type smlinfo = SmlInfo.info
37 : blume 269 type symbol = GenericVC.Symbol.symbol
38 : blume 267
39 : blume 270 exception DuplicateImport of symbol * string * string
40 :     exception DuplicateDefinition of symbol * string * string
41 : blume 269
42 :     datatype collection =
43 :     COLLECTION of { subexports: DG.farnode SymbolMap.map,
44 :     smlfiles: smlinfo list,
45 :     localdefs: smlinfo SymbolMap.map }
46 :    
47 :     fun sequential (COLLECTION c1, COLLECTION c2) = let
48 : blume 270 fun se_error (s, (_, n1), (_, n2)) =
49 :     raise DuplicateImport (s, DG.describeNode n1, DG.describeNode n2)
50 : blume 269 val se_union = SymbolMap.unionWithi se_error
51 : blume 270 fun ld_error (s, f1, f2) =
52 :     raise DuplicateDefinition (s, SmlInfo.describe f1,
53 :     SmlInfo.describe f2)
54 : blume 269 val ld_union = SymbolMap.unionWithi ld_error
55 : blume 270
56 : blume 269 in
57 :     COLLECTION { subexports = se_union (#subexports c1, #subexports c2),
58 :     smlfiles = #smlfiles c1 @ #smlfiles c2,
59 :     localdefs = ld_union (#localdefs c1, #localdefs c2) }
60 :     end
61 :    
62 : blume 270 fun expandOne gexports { sourcepath, group, class } = let
63 : blume 272 val expansions = PrivateTools.expand (sourcepath, class)
64 :     fun exp2coll (PrivateTools.GROUP p) =
65 : blume 270 COLLECTION { subexports = gexports p,
66 :     smlfiles = [],
67 :     localdefs = SymbolMap.empty }
68 : blume 272 | exp2coll (PrivateTools.PRIMITIVE p) = let
69 : blume 270 val exports = Primitive.exports p
70 :     fun addFN (s, m) =
71 :     SymbolMap.insert (m, s, (NONE, DG.PNODE p))
72 :     val se = SymbolSet.foldl addFN SymbolMap.empty exports
73 :     in
74 :     COLLECTION { subexports = se,
75 :     smlfiles = [],
76 :     localdefs = SymbolMap.empty }
77 :     end
78 : blume 272 | exp2coll (PrivateTools.SMLSOURCE src) = let
79 : blume 270 val { sourcepath = p, history = h, share = s } = src
80 :     val i = SmlInfo.new { sourcepath = p, group = group,
81 : blume 272 history = h, share = s,
82 : blume 270 stableinfo = NONE }
83 :     val exports = SmlInfo.exports i
84 :     fun addLD (s, m) = SymbolMap.insert (m, s, i)
85 :     val ld = SymbolSet.foldl addLD SymbolMap.empty exports
86 :     in
87 :     COLLECTION { subexports = SymbolMap.empty,
88 :     smlfiles = [i],
89 :     localdefs = ld }
90 :     end
91 :    
92 :     val collections = map exp2coll expansions
93 :     val empty = COLLECTION { subexports = SymbolMap.empty,
94 :     smlfiles = [],
95 :     localdefs = SymbolMap.empty }
96 :     fun combine (c1, c2) = sequential (c2, c1)
97 :     in
98 :     foldl combine empty collections
99 :     end
100 :    
101 : blume 268 fun num_look (c: collection) (s: string) = 0
102 : blume 269
103 : blume 268 fun cm_look (c: collection) (s: string) = false
104 : blume 269
105 :     fun ml_look (COLLECTION { subexports, localdefs, ... }) s =
106 :     isSome (SymbolMap.find (subexports, s)) orelse
107 :     isSome (SymbolMap.find (localdefs, s))
108 : blume 267 end

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