+ L.error BrgO.specs (L.Warn s :: L.Loc :: msg); flush ()
+
+let process_item f st =
+ let f ast = f {st with ast = ast} in
+ AP.process_item f st.ast
+
+(* kernel related ***********************************************************)
+
+type kernel = Brg | Bag
+
+type kernel_item = BrgItem of Brg.item
+ | BagItem of Bag.item
+
+let kernel = ref Brg
+
+let print_counters st = match !kernel with
+ | Brg -> BrgO.print_counters C.start st.brgc
+ | Bag -> BagO.print_counters C.start st.bagc
+
+let kernel_of_meta f st item = match !kernel with
+ | Brg ->
+ let f item = f st (BrgItem item) in
+ MBrg.brg_of_meta f item
+ | Bag ->
+ let f item = f st (BagItem item) in
+ MBag.bag_of_meta f item
+
+let count_item st = function
+ | BrgItem item -> {st with brgc = count BrgO.count_item st.brgc item}
+ | BagItem item -> {st with bagc = count BagO.count_item st.bagc item}
+
+let type_check f st g = function
+ | BrgItem item ->
+ let f _ = function
+ | None -> f st None
+ | Some (i, u, _) -> f st (Some (i, u))
+ in
+ BrgU.type_check f g item
+ | BagItem item ->
+ let f _ = function
+ | None -> f st None
+ | Some (i, u, _) -> f st (Some (i, u))
+ in
+ BagU.type_check f g item
+
+let si () = match !kernel with
+ | Brg -> BrgT.si := true
+ | Bag -> BagR.nsi := true
+
+(****************************************************************************)