Commit d5300557 authored by POTTIER Francois's avatar POTTIER Francois

VISIT macro.

parent 01945269
(* The conventional name of the visitor method. *)
#define VISIT(term) \
CONCAT(visit_, term)
(* -------------------------------------------------------------------------- *)
(* [ba_term] computes the set of bound atoms of a term and (at the same time)
......@@ -15,8 +20,6 @@
(* [wf_terms] is a variant of [ba_term] that returns no result, but can still
raise [IllFormed]. *)
#define __BA \
exception IllFormed = KitBa.IllFormed \
class ['self] __ba = object (_ : 'self) \
......@@ -26,7 +29,7 @@
#define BA(term) \
let CONCAT(ba_, term) t = \
new __ba # CONCAT(visit_, term) () t \
new __ba # VISIT(term) () t \
let CONCAT(ba_, CONCAT(term, s)) ts = \
List.fold_left \
(fun accu t -> Atom.Set.disjoint_union accu (CONCAT(ba_, term) t)) \
......@@ -45,7 +48,7 @@
#define COPY(term) \
let CONCAT(copy_, term) t = \
new __copy # CONCAT(visit_, term) KitCopy.empty t
new __copy # VISIT(term) KitCopy.empty t
(* -------------------------------------------------------------------------- *)
......@@ -61,7 +64,7 @@
#define SHOW(term) \
let CONCAT(show_, term) t = \
new __show # CONCAT(visit_, term) () t
new __show # VISIT(term) () t
(* -------------------------------------------------------------------------- *)
......@@ -82,7 +85,7 @@
#define IMPORT(term) \
let CONCAT(import_, term) env t = \
new __import # CONCAT(visit_, term) env t
new __import # VISIT(term) env t
(* -------------------------------------------------------------------------- *)
......@@ -98,7 +101,7 @@
#define EXPORT(term) \
let CONCAT(export_, term) env t = \
new __export # CONCAT(visit_, term) env t
new __export # VISIT(term) env t
(* -------------------------------------------------------------------------- *)
......@@ -112,13 +115,13 @@
inherit [_] reduce as super \
inherit [_] KitTrivial.reduce \
inherit [_] VisitorsRuntime.addition_monoid \
method! CONCAT(visit_, term) env t = \
1 + super # CONCAT(visit_, term) env t \
method! VISIT(term) env t = \
1 + super # VISIT(term) env t \
end
#define SIZE(term) \
let CONCAT(size_, term) t = \
new __size # CONCAT(visit_, term) () t
new __size # VISIT(term) () t
(* -------------------------------------------------------------------------- *)
......@@ -133,7 +136,7 @@
#define EQUIV(term) \
let equiv t1 t2 = \
VisitorsRuntime.wrap2 \
(new __equiv # CONCAT(visit_, term) KitEquiv.empty) \
(new __equiv # VISIT(term) KitEquiv.empty) \
t1 t2
(* -------------------------------------------------------------------------- *)
......@@ -168,6 +171,6 @@
#define SUBST(thing, term) \
let CONCAT(subst_, CONCAT(thing, CONCAT(_, term))) sigma t = \
new CONCAT(__subst_, thing) # CONCAT(visit_, term) sigma t \
new CONCAT(__subst_, thing) # VISIT(term) sigma t \
let CONCAT(subst_, CONCAT(thing, CONCAT(_, CONCAT(term, 1)))) u x t = \
CONCAT(subst_, CONCAT(thing, CONCAT(_, term))) (Atom.Map.singleton x u) t
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment