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 299 - (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 283 -> impexp SymbolMap.map
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 :     subgroups: GG.group list }
60 : blume 269
61 : blume 274 val empty =
62 : blume 283 COLLECTION { imports = SymbolMap.empty,
63 :     gimports = SymbolMap.empty,
64 : blume 274 smlfiles = [],
65 : blume 294 localdefs = SymbolMap.empty,
66 :     subgroups = [] }
67 : blume 274
68 : blume 275 fun sequential (COLLECTION c1, COLLECTION c2, error) = let
69 :     fun describeSymbol (s, r) = let
70 :     val ns = Symbol.nameSpace s
71 :     in
72 :     Symbol.nameSpaceToString ns :: " " :: Symbol.name s :: r
73 :     end
74 : blume 283 fun i_error (s, x as (fn1, _), (fn2, _)) =
75 : blume 275 (error (concat (describeSymbol
76 : blume 282 (s, [" imported from ", DG.describeFarSBN fn1,
77 :     " and also from ", DG.describeFarSBN fn2])));
78 : blume 275 x)
79 : blume 283 val i_union = SymbolMap.unionWithi i_error
80 :     val gi_union = SymbolMap.unionWith #1
81 : blume 270 fun ld_error (s, f1, f2) =
82 : blume 275 (error (concat (describeSymbol
83 : blume 280 (s, [" defined in ", SmlInfo.spec f1,
84 :     " and also in ", SmlInfo.spec f2])));
85 : blume 275 f1)
86 : blume 269 val ld_union = SymbolMap.unionWithi ld_error
87 :     in
88 : blume 283 COLLECTION { imports = i_union (#imports c1, #imports c2),
89 :     gimports = gi_union (#gimports c1, #gimports c2),
90 : blume 269 smlfiles = #smlfiles c1 @ #smlfiles c2,
91 : blume 294 localdefs = ld_union (#localdefs c1, #localdefs c2),
92 :     subgroups = #subgroups c1 @ #subgroups c2 }
93 : blume 269 end
94 :    
95 : blume 299 fun expandOne (gp, rparse) arg = let
96 :     val primconf = #primconf (#param gp)
97 : blume 297 val { sourcepath, group, class } = arg
98 : blume 299 val error = GroupReg.error (#groupreg gp) group
99 : blume 274 fun noPrimitive () = let
100 : blume 294 fun e0 s = error EM.COMPLAIN s EM.nullErrorBody
101 :     fun w0 s = error EM.WARN s EM.nullErrorBody
102 : blume 277 val expansions = PrivateTools.expand e0 (sourcepath, class)
103 : blume 283 fun exp2coll (PrivateTools.GROUP p) = let
104 : blume 294 val g as GG.GROUP { exports = i, islib, ... } = rparse p
105 :     val gi = if islib then SymbolMap.empty else i
106 : blume 283 in
107 :     COLLECTION { imports = i, gimports = gi, smlfiles = [],
108 : blume 294 localdefs = SymbolMap.empty,
109 :     subgroups = [g] }
110 : blume 283 end
111 : blume 274 | exp2coll (PrivateTools.SMLSOURCE src) = let
112 :     val { sourcepath = p, history = h, share = s } = src
113 : blume 299 val i = SmlInfo.info gp
114 : blume 297 { sourcepath = p,
115 :     group = group,
116 : blume 277 share = s }
117 : blume 299 val exports = SmlInfo.exports gp i
118 : blume 294 val _ = if SS.isEmpty exports then w0 "no module exports"
119 : blume 286 else ()
120 : blume 274 fun addLD (s, m) = SymbolMap.insert (m, s, i)
121 : blume 286 val ld = SS.foldl addLD SymbolMap.empty exports
122 : blume 274 in
123 : blume 283 COLLECTION { imports = SymbolMap.empty,
124 :     gimports = SymbolMap.empty,
125 : blume 274 smlfiles = [i],
126 : blume 294 localdefs = ld,
127 :     subgroups = [] }
128 : blume 274 end
129 :     val collections = map exp2coll expansions
130 : blume 277 fun combine (c1, c2) = sequential (c2, c1, e0)
131 : blume 274 in
132 :     foldl combine empty collections
133 :     end
134 :     in
135 :     if isSome class then noPrimitive ()
136 :     else case Primitive.fromString (AbsPath.spec sourcepath) of
137 :     SOME p => let
138 : blume 286 val exports = Primitive.exports primconf p
139 :     val plook = Primitive.lookup primconf p
140 : blume 278 fun addFN (s, m) = let
141 : blume 286 val env = plook s
142 : blume 282 val fsbn = (NONE, DG.SB_BNODE (DG.PNODE p))
143 : blume 278 in
144 : blume 282 SymbolMap.insert (m, s, (fsbn, env))
145 : blume 278 end
146 : blume 286 val imp = SS.foldl addFN SymbolMap.empty exports
147 : blume 270 in
148 : blume 283 COLLECTION { imports = imp,
149 :     gimports = SymbolMap.empty,
150 : blume 270 smlfiles = [],
151 : blume 294 localdefs = SymbolMap.empty,
152 :     subgroups = [] }
153 : blume 270 end
154 : blume 274 | NONE => noPrimitive ()
155 : blume 270 end
156 :    
157 : blume 297 fun build (COLLECTION c, fopt, error, gp) =
158 :     BuildDepend.build (c, fopt, error, gp)
159 : blume 280
160 : blume 294 fun subgroups (COLLECTION { subgroups = sg, ... }) = sg
161 :    
162 : blume 268 fun num_look (c: collection) (s: string) = 0
163 : blume 269
164 : blume 268 fun cm_look (c: collection) (s: string) = false
165 : blume 269
166 : blume 283 fun ml_look (COLLECTION { imports, localdefs, ... }) s =
167 :     isSome (SymbolMap.find (imports, s)) orelse
168 : blume 269 isSome (SymbolMap.find (localdefs, s))
169 : blume 267 end

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