aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2021-12-09 20:07:40 +0000
committerYann Herklotz <git@yannherklotz.com>2021-12-09 20:07:40 +0000
commitbf4a0ae5142e7838c322b6009ff5cdcbaf2dfd42 (patch)
treec46b1bf23f1434cbd20a24bb2a22f9cf616bb387
parent26dcc7c33db422e93082c25d72de04fd4d1375ca (diff)
downloadvericert-bf4a0ae5142e7838c322b6009ff5cdcbaf2dfd42.tar.gz
vericert-bf4a0ae5142e7838c322b6009ff5cdcbaf2dfd42.zip
Add PrintLoops for bourdoncle code
-rw-r--r--src/bourdoncle/PrintLoops.ml22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/bourdoncle/PrintLoops.ml b/src/bourdoncle/PrintLoops.ml
new file mode 100644
index 0000000..f70f075
--- /dev/null
+++ b/src/bourdoncle/PrintLoops.ml
@@ -0,0 +1,22 @@
+open Camlcoq
+
+let indent i = String.make (2 * i) ' '
+
+let rec print_bourdoncle i pp =
+ function
+ | Bourdoncle.I n ->
+ Printf.fprintf pp "%sI %d\n" (indent i) (P.to_int n)
+ | Bourdoncle.L (h, b) ->
+ Printf.fprintf pp "%sL %d\n" (indent i) (P.to_int h);
+ List.iter (fun a -> Printf.fprintf pp "%a" (print_bourdoncle (i+1)) a) b
+
+let print_if optdest loop =
+ match !optdest with
+ | None -> ()
+ | Some f ->
+ let oc = open_out f in
+ print_bourdoncle 0 oc loop;
+ close_out oc
+
+let destination_loops : string option ref = ref None
+let print_loops = print_if destination_loops