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 275 - (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 267 type collection
18 :    
19 : blume 274 val empty : collection
20 :    
21 : blume 270 val expandOne : (AbsPath.t -> DependencyGraph.farnode SymbolMap.map)
22 : blume 275 -> { sourcepath: AbsPath.t, group: AbsPath.t, class: string option,
23 :     error : string -> unit }
24 : blume 270 -> collection
25 : blume 275 val sequential : collection * collection * (string -> unit) -> collection
26 : blume 267
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 275 structure Symbol = GenericVC.Symbol
36 : blume 267
37 : blume 270 type smlinfo = SmlInfo.info
38 : blume 275 type symbol = Symbol.symbol
39 : blume 267
40 : blume 269 datatype collection =
41 :     COLLECTION of { subexports: DG.farnode SymbolMap.map,
42 :     smlfiles: smlinfo list,
43 :     localdefs: smlinfo SymbolMap.map }
44 :    
45 : blume 274 val empty =
46 :     COLLECTION { subexports = SymbolMap.empty,
47 :     smlfiles = [],
48 :     localdefs = SymbolMap.empty }
49 :    
50 : blume 275 fun sequential (COLLECTION c1, COLLECTION c2, error) = let
51 :     fun describeSymbol (s, r) = let
52 :     val ns = Symbol.nameSpace s
53 :     in
54 :     Symbol.nameSpaceToString ns :: " " :: Symbol.name s :: r
55 :     end
56 :     fun se_error (s, x as (_, n1), (_, n2)) =
57 :     (error (concat (describeSymbol
58 :     (s, [" imported from ", DG.describeNode n1,
59 :     " and also from ", DG.describeNode n2])));
60 :     x)
61 : blume 269 val se_union = SymbolMap.unionWithi se_error
62 : blume 270 fun ld_error (s, f1, f2) =
63 : blume 275 (error (concat (describeSymbol
64 :     (s, [" defined in ", SmlInfo.describe f1,
65 :     " and also in ", SmlInfo.describe f2])));
66 :     f1)
67 : blume 269 val ld_union = SymbolMap.unionWithi ld_error
68 :     in
69 :     COLLECTION { subexports = se_union (#subexports c1, #subexports c2),
70 :     smlfiles = #smlfiles c1 @ #smlfiles c2,
71 :     localdefs = ld_union (#localdefs c1, #localdefs c2) }
72 :     end
73 :    
74 : blume 275 fun expandOne gexports { sourcepath, group, class, error } = let
75 : blume 274 fun noPrimitive () = let
76 : blume 275 val expansions = PrivateTools.expand error (sourcepath, class)
77 : blume 274 fun exp2coll (PrivateTools.GROUP p) =
78 :     COLLECTION { subexports = gexports p,
79 :     smlfiles = [],
80 :     localdefs = SymbolMap.empty }
81 :     | exp2coll (PrivateTools.SMLSOURCE src) = let
82 :     val { sourcepath = p, history = h, share = s } = src
83 :     val i = SmlInfo.new
84 :     Policy.default
85 : blume 275 { sourcepath = p, group = group,
86 :     error = error, history = h,
87 : blume 274 share = s, stableinfo = NONE }
88 :     val exports = SmlInfo.exports i
89 :     fun addLD (s, m) = SymbolMap.insert (m, s, i)
90 :     val ld = SymbolSet.foldl addLD SymbolMap.empty exports
91 :     in
92 :     COLLECTION { subexports = SymbolMap.empty,
93 :     smlfiles = [i],
94 :     localdefs = ld }
95 :     end
96 :     val collections = map exp2coll expansions
97 : blume 275 fun combine (c1, c2) = sequential (c2, c1, error)
98 : blume 274 in
99 :     foldl combine empty collections
100 :     end
101 :     in
102 :     if isSome class then noPrimitive ()
103 :     else case Primitive.fromString (AbsPath.spec sourcepath) of
104 :     SOME p => let
105 : blume 270 val exports = Primitive.exports p
106 :     fun addFN (s, m) =
107 :     SymbolMap.insert (m, s, (NONE, DG.PNODE p))
108 :     val se = SymbolSet.foldl addFN SymbolMap.empty exports
109 :     in
110 :     COLLECTION { subexports = se,
111 :     smlfiles = [],
112 :     localdefs = SymbolMap.empty }
113 :     end
114 : blume 274 | NONE => noPrimitive ()
115 : blume 270 end
116 :    
117 : blume 268 fun num_look (c: collection) (s: string) = 0
118 : blume 269
119 : blume 268 fun cm_look (c: collection) (s: string) = false
120 : blume 269
121 :     fun ml_look (COLLECTION { subexports, localdefs, ... }) s =
122 :     isSome (SymbolMap.find (subexports, s)) orelse
123 :     isSome (SymbolMap.find (localdefs, s))
124 : blume 267 end

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