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 309 - (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 278 type symbol = Symbol.symbol
15 : blume 270 type smlinfo = SmlInfo.info
16 : blume 283 type impexp = DependencyGraph.impexp
17 : blume 297 type region = GenericVC.SourceMap.region
18 : blume 269
19 : blume 267 type collection
20 :    
21 : blume 274 val empty : collection
22 :    
23 : blume 299 val expandOne : GeneralParams.info * (AbsPath.t -> GroupGraph.group)
24 : blume 297 -> { sourcepath: AbsPath.t, group: AbsPath.t * region,
25 :     class: string option }
26 : blume 270 -> collection
27 : blume 275 val sequential : collection * collection * (string -> unit) -> collection
28 : blume 267
29 : blume 297 val build :
30 :     collection * SymbolSet.set option * (string -> unit) *
31 : blume 299 GeneralParams.info
32 : blume 301 -> impexp SymbolMap.map * GroupGraph.privileges
33 : blume 280
34 : blume 294 val subgroups : collection -> GroupGraph.group list
35 :    
36 : blume 268 val num_look : collection -> string -> int
37 : blume 278 val ml_look : collection -> symbol -> bool
38 : blume 268 val cm_look : collection -> string -> bool
39 : blume 267 end
40 :    
41 :     structure MemberCollection :> MEMBERCOLLECTION = struct
42 :    
43 : blume 269 structure DG = DependencyGraph
44 : blume 277 structure EM = GenericVC.ErrorMsg
45 : blume 278 structure CBE = GenericVC.BareEnvironment
46 : blume 286 structure SS = SymbolSet
47 : blume 294 structure GG = GroupGraph
48 : blume 267
49 : blume 270 type smlinfo = SmlInfo.info
50 : blume 275 type symbol = Symbol.symbol
51 : blume 283 type impexp = DG.impexp
52 : blume 297 type region = GenericVC.SourceMap.region
53 : blume 267
54 : blume 269 datatype collection =
55 : blume 283 COLLECTION of { imports: impexp SymbolMap.map,
56 :     gimports: impexp SymbolMap.map,
57 : blume 269 smlfiles: smlinfo list,
58 : blume 294 localdefs: smlinfo SymbolMap.map,
59 : blume 301 subgroups: GG.group list,
60 :     reqpriv: GG.privileges }
61 : blume 269
62 : blume 274 val empty =
63 : blume 283 COLLECTION { imports = SymbolMap.empty,
64 :     gimports = SymbolMap.empty,
65 : blume 274 smlfiles = [],
66 : blume 294 localdefs = SymbolMap.empty,
67 : blume 301 subgroups = [],
68 :     reqpriv = StringSet.empty }
69 : blume 274
70 : blume 275 fun sequential (COLLECTION c1, COLLECTION c2, error) = let
71 :     fun describeSymbol (s, r) = let
72 :     val ns = Symbol.nameSpace s
73 :     in
74 :     Symbol.nameSpaceToString ns :: " " :: Symbol.name s :: r
75 :     end
76 : blume 283 fun i_error (s, x as (fn1, _), (fn2, _)) =
77 : blume 275 (error (concat (describeSymbol
78 : blume 282 (s, [" imported from ", DG.describeFarSBN fn1,
79 :     " and also from ", DG.describeFarSBN fn2])));
80 : blume 275 x)
81 : blume 283 val i_union = SymbolMap.unionWithi i_error
82 :     val gi_union = SymbolMap.unionWith #1
83 : blume 270 fun ld_error (s, f1, f2) =
84 : blume 275 (error (concat (describeSymbol
85 : blume 280 (s, [" defined in ", SmlInfo.spec f1,
86 :     " and also in ", SmlInfo.spec f2])));
87 : blume 275 f1)
88 : blume 269 val ld_union = SymbolMap.unionWithi ld_error
89 :     in
90 : blume 283 COLLECTION { imports = i_union (#imports c1, #imports c2),
91 :     gimports = gi_union (#gimports c1, #gimports c2),
92 : blume 269 smlfiles = #smlfiles c1 @ #smlfiles c2,
93 : blume 294 localdefs = ld_union (#localdefs c1, #localdefs c2),
94 : blume 301 subgroups = #subgroups c1 @ #subgroups c2,
95 :     reqpriv = StringSet.union (#reqpriv c1, #reqpriv c2) }
96 : blume 269 end
97 :    
98 : blume 299 fun expandOne (gp, rparse) arg = let
99 :     val primconf = #primconf (#param gp)
100 : blume 297 val { sourcepath, group, class } = arg
101 : blume 299 val error = GroupReg.error (#groupreg gp) group
102 : blume 274 fun noPrimitive () = let
103 : blume 294 fun e0 s = error EM.COMPLAIN s EM.nullErrorBody
104 :     fun w0 s = error EM.WARN s EM.nullErrorBody
105 : blume 277 val expansions = PrivateTools.expand e0 (sourcepath, class)
106 : blume 283 fun exp2coll (PrivateTools.GROUP p) = let
107 : blume 305 val g as GG.GROUP { exports = i, islib, required, ... } =
108 : blume 301 rparse p
109 : blume 294 val gi = if islib then SymbolMap.empty else i
110 : blume 283 in
111 :     COLLECTION { imports = i, gimports = gi, smlfiles = [],
112 : blume 294 localdefs = SymbolMap.empty,
113 : blume 301 subgroups = [g],
114 : blume 305 reqpriv = required }
115 : blume 283 end
116 : blume 274 | exp2coll (PrivateTools.SMLSOURCE src) = let
117 :     val { sourcepath = p, history = h, share = s } = src
118 : blume 301 val i = SmlInfo.info gp
119 : blume 297 { sourcepath = p,
120 :     group = group,
121 : blume 277 share = s }
122 : blume 301 val exports =
123 :     case SmlInfo.exports gp i of
124 :     NONE => SS.empty
125 :     | SOME ex => (if SS.isEmpty ex then
126 :     w0 ("no module exports from " ^
127 :     AbsPath.name p)
128 :     else ();
129 :     ex)
130 : blume 274 fun addLD (s, m) = SymbolMap.insert (m, s, i)
131 : blume 286 val ld = SS.foldl addLD SymbolMap.empty exports
132 : blume 274 in
133 : blume 283 COLLECTION { imports = SymbolMap.empty,
134 :     gimports = SymbolMap.empty,
135 : blume 274 smlfiles = [i],
136 : blume 294 localdefs = ld,
137 : blume 301 subgroups = [],
138 :     reqpriv = StringSet.empty }
139 : blume 274 end
140 :     val collections = map exp2coll expansions
141 : blume 277 fun combine (c1, c2) = sequential (c2, c1, e0)
142 : blume 274 in
143 :     foldl combine empty collections
144 :     end
145 :     in
146 :     if isSome class then noPrimitive ()
147 :     else case Primitive.fromString (AbsPath.spec sourcepath) of
148 :     SOME p => let
149 : blume 286 val exports = Primitive.exports primconf p
150 : blume 309 val env = Primitive.da_env primconf p
151 : blume 278 fun addFN (s, m) = let
152 : blume 282 val fsbn = (NONE, DG.SB_BNODE (DG.PNODE p))
153 : blume 278 in
154 : blume 282 SymbolMap.insert (m, s, (fsbn, env))
155 : blume 278 end
156 : blume 286 val imp = SS.foldl addFN SymbolMap.empty exports
157 : blume 270 in
158 : blume 283 COLLECTION { imports = imp,
159 :     gimports = SymbolMap.empty,
160 : blume 270 smlfiles = [],
161 : blume 294 localdefs = SymbolMap.empty,
162 : blume 301 subgroups = [],
163 :     reqpriv = Primitive.reqpriv p }
164 : blume 270 end
165 : blume 274 | NONE => noPrimitive ()
166 : blume 270 end
167 :    
168 : blume 297 fun build (COLLECTION c, fopt, error, gp) =
169 :     BuildDepend.build (c, fopt, error, gp)
170 : blume 280
171 : blume 294 fun subgroups (COLLECTION { subgroups = sg, ... }) = sg
172 :    
173 : blume 268 fun num_look (c: collection) (s: string) = 0
174 : blume 269
175 : blume 268 fun cm_look (c: collection) (s: string) = false
176 : blume 269
177 : blume 283 fun ml_look (COLLECTION { imports, localdefs, ... }) s =
178 :     isSome (SymbolMap.find (imports, s)) orelse
179 : blume 269 isSome (SymbolMap.find (localdefs, s))
180 : blume 267 end

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