+
+module NodeSummary =
+struct
+ (* Pack into an integer the result of the is_* and has_ predicates
+ for a given node *)
+ type t = int
+ let dummy = -1
+ (*
+ ...44443210
+ ...4444 -> kind
+ 3 -> has_right
+ 2 -> has_left
+ 1 -> is_right
+ 0 -> is_left
+ *)
+ let is_left (s : t) : bool =
+ s land 1 != 0
+
+ let is_right (s : t) : bool =
+ s land 0b10 != 0
+
+ let has_left (s : t) : bool =
+ s land 0b100 != 0
+
+ let has_right (s : t) : bool =
+ s land 0b1000 != 0
+
+ let kind (s : t) : NodeKind.t =
+ Obj.magic (s lsr 4)
+
+ let make is_left is_right has_left has_right kind =
+ (int_of_bool is_left) lor
+ ((int_of_bool is_right) lsl 1) lor
+ ((int_of_bool has_left) lsl 2) lor
+ ((int_of_bool has_right) lsl 3) lor
+ ((Obj.magic kind) lsl 4)
+end
+
+