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

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