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

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