Skip to content

Commit e702c3f

Browse files
committed
MNT: complete implementation of M_visit.deep_map
Signed-off-by: Ioannis Filippidis <[email protected]>
1 parent 3b69928 commit e702c3f

File tree

1 file changed

+15
-25
lines changed

1 file changed

+15
-25
lines changed

src/module/m_visit.ml

Lines changed: 15 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,6 @@ let update_cx (cx: ctx) mu =
2121
Dq.append_list cx hyps
2222

2323

24-
(* TODO: make this method deep,
25-
for uniformity of the API with
26-
`Expr.Visit.map`,
27-
and create a class
28-
`Module.Visit.shallow_map`,
29-
and call that one from where
30-
currently the class `map` is
31-
being used.
32-
*)
3324
class map =
3425
(* Shallow mapping of modules.
3526
@@ -174,30 +165,19 @@ class map =
174165
method mutate cx change usable =
175166
let mu = Mutate (
176167
change, usable) in
177-
(* TODO: change the visibility of
178-
facts in `cx` based on the
179-
`Mutate` statement.
180-
*)
181168
(cx, mu)
182169

183170
method submod cx tla_module =
184171
let mu = Submod tla_module in
185172
(cx, mu)
186173

187174
method anoninst cx inst local =
188-
(* TODO: expand statements
189-
from `INSTANCE` *)
190175
let mu = Anoninst (inst, local) in
191176
(cx, mu)
192177

193178
end
194179

195180

196-
(* TODO: handle `INSTANCE`
197-
statements when expanding
198-
tuply declarations, or
199-
expand them beforehand.
200-
*)
201181
class deep_map =
202182
(* Deep mapping of modules.
203183
@@ -243,14 +223,24 @@ class deep_map =
243223
let cx = update_cx cx mu in
244224
(cx, mu)
245225

246-
(* TODO: expression references and instantiation
247226
method mutate cx change usable =
248-
failwith "not implemented"
227+
let scx = ((), cx) in
228+
let usable = self#usable scx usable in
229+
let mu = Mutate (change, usable) in
230+
let cx = update_cx cx mu in
231+
(cx, mu)
249232

250233
method submod cx tla_module =
251-
failwith "not implemented"
234+
let cx, tla_module = self#tla_module
235+
cx tla_module in
236+
let mu = Submod tla_module in
237+
(cx, mu)
252238

253239
method anoninst cx inst local =
254-
failwith "not implemented"
255-
*)
240+
let scx = ((), cx) in
241+
let inst = self#instance scx inst in
242+
let mu = Anoninst (inst, local) in
243+
(* NOTE: `inst_sub` expressions mapped,
244+
not full instantiation, so `cx` unchanged. *)
245+
(cx, mu)
256246
end

0 commit comments

Comments
 (0)