summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/Types.ml54
1 files changed, 53 insertions, 1 deletions
diff --git a/src/Types.ml b/src/Types.ml
index c9eeff7e..8b2b0bd9 100644
--- a/src/Types.ml
+++ b/src/Types.ml
@@ -68,6 +68,39 @@ type assumed_ty = Box [@@deriving show]
type type_id = AdtId of TypeDefId.id | Tuple | Assumed of assumed_ty
[@@deriving show]
+(** Ancestor for iter visitor for [ty] *)
+class ['self] iter_ty_base =
+ object (_self : 'self)
+ inherit [_] VisitorsRuntime.iter
+
+ method visit_'r : 'env -> 'r -> unit = fun _ _ -> ()
+
+ method visit_id : 'env -> TypeVarId.id -> unit = fun _ _ -> ()
+
+ method visit_type_id : 'env -> type_id -> unit = fun _ _ -> ()
+
+ method visit_integer_type : 'env -> integer_type -> unit = fun _ _ -> ()
+
+ method visit_ref_kind : 'env -> ref_kind -> unit = fun _ _ -> ()
+ end
+
+(** Ancestor for map visitor for [ty] *)
+class ['self] map_ty_base =
+ object (_self : 'self)
+ inherit [_] VisitorsRuntime.map
+
+ method visit_'r : 'env -> 'r -> 'r = fun _ r -> r
+
+ method visit_id : 'env -> TypeVarId.id -> TypeVarId.id = fun _ id -> id
+
+ method visit_type_id : 'env -> type_id -> type_id = fun _ id -> id
+
+ method visit_integer_type : 'env -> integer_type -> integer_type =
+ fun _ ity -> ity
+
+ method visit_ref_kind : 'env -> ref_kind -> ref_kind = fun _ rk -> rk
+ end
+
type 'r ty =
| Adt of type_id * 'r list * 'r ty list
(** [Adt] encodes ADTs, tuples and assumed types *)
@@ -80,7 +113,26 @@ type 'r ty =
| Array of 'r ty (* TODO: there should be a constant with the array *)
| Slice of 'r ty
| Ref of 'r * 'r ty * ref_kind
-[@@deriving show]
+[@@deriving
+ show,
+ visitors
+ {
+ name = "iter_ty";
+ variety = "iter";
+ ancestors = [ "iter_ty_base" ];
+ nude = true (* Don't inherit [VisitorsRuntime.iter] *);
+ concrete = true;
+ polymorphic = false;
+ },
+ visitors
+ {
+ name = "map_ty";
+ variety = "map";
+ ancestors = [ "map_ty_base" ];
+ nude = true (* Don't inherit [VisitorsRuntime.iter] *);
+ concrete = true;
+ polymorphic = false;
+ }]
(* TODO: group Bool, Char, etc. in Constant *)
type sty = RegionVarId.id region ty [@@deriving show]