]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/software/lambda-delta/toplevel/metaOutput.ml
some renaming. final commit for version 0.8.0
[helm.git] / helm / software / lambda-delta / toplevel / metaOutput.ml
index 03995e15382dc741e02b6a2f1d79c8afeb569a21..7f62c8abc0c71a6e6646e9bdb44fa5140cf9d1ba 100644 (file)
@@ -25,67 +25,82 @@ type counters = {
    pappls: int;
    tappls: int;
    tabsts: int;
+   uris  : U.uri list;
+   nodes : int;
+   xnodes: int
 }
 
 let initial_counters = {
    eabsts = 0; eabbrs = 0; pabsts = 0; pappls = 0;
-   tsorts = 0; tlrefs = 0; tgrefs = 0; tappls = 0; tabsts = 0
+   tsorts = 0; tlrefs = 0; tgrefs = 0; tappls = 0; tabsts = 0;
+   uris = []; nodes = 0; xnodes = 0
 }
 
 let rec count_term f c = function
    | M.Sort _          -> 
-      f {c with tsorts = succ c.tsorts}
+      f {c with tsorts = succ c.tsorts; nodes = succ c.nodes}
    | M.LRef _          -> 
-      f {c with tlrefs = succ c.tlrefs}
-   | M.GRef (_, _, ts) -> 
+      f {c with tlrefs = succ c.tlrefs; nodes = succ c.nodes}
+   | M.GRef (_, u, ts) -> 
       let c = {c with tgrefs = succ c.tgrefs} in
       let c = {c with pappls = c.pappls + List.length ts} in
+      let c = {c with nodes = c.nodes + List.length ts} in
+      let c =    
+        if Cps.list_mem ~eq:U.eq u c.uris
+        then {c with nodes = succ c.nodes}
+        else {c with xnodes = succ c.xnodes}
+      in
       Cps.list_fold_left f count_term c ts
    | M.Appl (v, t)     -> 
-      let c = {c with tappls = succ c.tappls} in
+      let c = {c with tappls = succ c.tappls; nodes = succ c.nodes} 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 c = {c with tabsts = succ c.tabsts; nodes = succ c.nodes} 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_entry f c = function
-   | _, pars, _, w, None        ->
+   | _, pars, u, w, None        ->
       let c = {c with eabsts = succ c.eabsts} in
       let c = {c with pabsts = c.pabsts + List.length pars} in
+      let c = {c with uris = u :: c.uris; nodes = succ c.nodes + 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 eabbrs = succ c.eabbrs; xnodes = succ c.xnodes} in
       let c = {c with pabsts = c.pabsts + List.length pars} in
+      let c = {c with nodes = c.nodes + 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_item f c = function
+let count_entity f c = function
    | Some e -> count_entry f c e
    | None   -> f c
 
 let print_counters f c =
-   let terms = c.tsorts + c.tgrefs + c.tgrefs + c.tappls + c.tabsts in
+   let terms = c.tsorts + c.tlrefs + c.tgrefs + c.tappls + c.tabsts in
    let pars = c.pabsts + c.pappls in
-   let items = c.eabsts + c.eabbrs in
+   let entries = c.eabsts + c.eabbrs in
+   let nodes = c.nodes + c.xnodes in
    L.warn (P.sprintf "  Intermediate representation summary");
-   L.warn (P.sprintf "    Total entry items:        %6u" items);
-   L.warn (P.sprintf "      Declaration items:      %6u" c.eabsts);
-   L.warn (P.sprintf "      Definition items:       %6u" c.eabbrs);
-   L.warn (P.sprintf "    Total parameter items:    %6u" pars);
-   L.warn (P.sprintf "      Application items:      %6u" c.pappls);
-   L.warn (P.sprintf "      Abstraction items:      %6u" c.pabsts);
-   L.warn (P.sprintf "    Total term items:         %6u" terms);
-   L.warn (P.sprintf "      Sort items:             %6u" c.tsorts);
-   L.warn (P.sprintf "      Local reference items:  %6u" c.tlrefs);
-   L.warn (P.sprintf "      Global reference items: %6u" c.tgrefs);
-   L.warn (P.sprintf "      Application items:      %6u" c.tappls);
-   L.warn (P.sprintf "      Abstraction items:      %6u" c.tabsts);
+   L.warn (P.sprintf "    Total entries:            %7u" entries);
+   L.warn (P.sprintf "      Declaration items:      %7u" c.eabsts);
+   L.warn (P.sprintf "      Definition items:       %7u" c.eabbrs);
+   L.warn (P.sprintf "    Total parameter items:    %7u" pars);
+   L.warn (P.sprintf "      Application items:      %7u" c.pappls);
+   L.warn (P.sprintf "      Abstraction items:      %7u" c.pabsts);
+   L.warn (P.sprintf "    Total term items:         %7u" terms);
+   L.warn (P.sprintf "      Sort items:             %7u" c.tsorts);
+   L.warn (P.sprintf "      Local reference items:  %7u" c.tlrefs);
+   L.warn (P.sprintf "      Global reference items: %7u" c.tgrefs);
+   L.warn (P.sprintf "      Application items:      %7u" c.tappls);
+   L.warn (P.sprintf "      Abstraction items:      %7u" c.tabsts);
+   L.warn (P.sprintf "    Global Int. Complexity:   %7u" c.nodes);
+   L.warn (P.sprintf "      + Abbreviation nodes:   %7u" nodes);
    f ()
 
 let string_of_sort = function
@@ -135,6 +150,6 @@ let pp_entry frm (l, pars, uri, u, body) =
    F.fprintf frm "@[%u@@%s%a%a:%a@]@\n%!" 
       l (U.string_of_uri uri) pp_pars pars pp_body body pp_term u
 
-let pp_item f frm = function 
+let pp_entity f frm = function 
    | Some entry -> pp_entry frm entry; f ()
    | None       -> f ()