--- /dev/null
+(* Copyright (C) 2000, HELM Team.
+ *
+ * This file is part of HELM, an Hypertextual, Electronic
+ * Library of Mathematics, developed at the Computer Science
+ * Department, University of Bologna, Italy.
+ *
+ * HELM is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * HELM is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HELM; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ * MA 02111-1307, USA.
+ *
+ * For details, see the HELM World-Wide-Web page,
+ * http://cs.unibo.it/helm/.
+ *)
+
+module M = Meta
+
+type counters = {
+ eabsts: int;
+ eabbrs: int;
+ pabsts: int;
+ tsorts: int;
+ tlrefs: int;
+ tgrefs: int;
+ pappls: int;
+ tappls: int;
+ tabsts: int;
+}
+
+let initial_counters = {
+ eabsts = 0; eabbrs = 0; pabsts = 0; pappls = 0;
+ tsorts = 0; tlrefs = 0; tgrefs = 0; tappls = 0; tabsts = 0
+}
+
+let rec count_term f c = function
+ | M.Sort _ ->
+ f {c with tsorts = succ c.tsorts}
+ | M.LRef _ ->
+ f {c with tlrefs = succ c.tlrefs}
+ | M.GRef (_, ts) ->
+ let c = {c with tgrefs = succ c.tgrefs} in
+ let c = {c with pappls = c.pappls + List.length ts} in
+ Cps.list_fold_left f count_term c ts
+ | M.Appl (v, t) ->
+ let c = {c with tappls = succ c.tappls} in
+ let f c = count_term f c t in
+ count_term f c v
+ | M.Abst (_, w, t) ->
+ let c = {c with tabsts = succ c.tabsts} in
+ let f c = count_term f c t in
+ count_term f c w
+
+let count_par f c (_, w) = count_term f c w
+
+let count_item f c = function
+ | pars, _, w, None ->
+ let c = {c with eabsts = succ c.eabsts} in
+ let c = {c with pabsts = c.pabsts + List.length pars} in
+ let f c = count_term f c w in
+ Cps.list_fold_left f count_par c pars
+ | pars, _, w, Some (_, v) ->
+ let c = {c with eabbrs = succ c.eabbrs} in
+ let c = {c with pabsts = c.pabsts + List.length pars} in
+ let f c = count_term f c v in
+ let f c = count_term f c w in
+ Cps.list_fold_left f count_par c pars
+
+let count f c b =
+ Cps.list_fold_left f count_item c b
+
+let print_counters f c =
+ let terms = c.tsorts + c.tgrefs + c.tgrefs + c.tappls + c.tabsts in
+ let pars = c.pabsts + c.pappls in
+ let items = c.eabsts + c.eabbrs in
+ Printf.printf " Intermediate representation summary\n";
+ Printf.printf " Total entry items: %6u\n" items;
+ Printf.printf " Declaration items: %6u\n" c.eabsts;
+ Printf.printf " Definition items: %6u\n" c.eabbrs;
+ Printf.printf " Total parameter items: %6u\n" pars;
+ Printf.printf " Application items: %6u\n" c.pappls;
+ Printf.printf " Abstraction items: %6u\n" c.pabsts;
+ Printf.printf " Total term items: %6u\n" terms;
+ Printf.printf " Sort items: %6u\n" c.tsorts;
+ Printf.printf " Local reference items: %6u\n" c.tlrefs;
+ Printf.printf " Global reference items: %6u\n" c.tgrefs;
+ Printf.printf " Application items: %6u\n" c.tappls;
+ Printf.printf " Abstraction items: %6u\n" c.tabsts;
+ flush stdout; f ()
+
+let string_of_qid (id, path) =
+ let path = String.concat "/" path in
+ Filename.concat path id
+