Commit d5751924 authored by Raphael Rieu-Helft's avatar Raphael Rieu-Helft

[wip] extraction

parent ad39ce95
......@@ -258,21 +258,21 @@ module mach.c.C
syntax type ptr "%1 *"
syntax type bool "int" (* ? *)
syntax val malloc "malloc(%1 * sizeof(%v0))"
syntax val malloc "malloc((%1) * sizeof(%v0))"
syntax val free "free(%1)"
syntax val realloc "realloc(%1, %2 * sizeof(%v0))"
syntax val realloc "realloc(%1, (%2) * sizeof(%v0))"
(* syntax val is_null "(%1) == NULL" *)
syntax val is_not_null "(%1) != NULL"
syntax val null "NULL"
syntax val incr "%1+%2"
syntax val incr "%1+(%2)"
syntax val get "*(%1)"
syntax val get_ofs "*(%1+%2)"
syntax val get_ofs "*(%1+(%2))"
syntax val set "*(%1) = %2"
syntax val set_ofs "*(%1+%2) = %3"
syntax val set_ofs "*(%1+(%2)) = %3"
syntax val p2i "%1"
syntax converter p2i "%1"
......
......@@ -2,7 +2,7 @@ all: why3 extract
why3:
make -C ../../..
extract: why3
why3 extract -D c -D mp.drv -o build -L . -T mp2.N
why3 extract -D c -D mp.drv -o build/N.c -L . mp2.N
tests: extract check-gmp
gcc -O3 -Wall -g -std=gnu99 tests.c build/N.c -I$(GMP_DIR) -lgmp -o tests
why3addbench: extract check-gmp
......
......@@ -61,7 +61,7 @@ module ML = struct
type pat =
| Pwild
| Pident of ident
| Pvar of vsymbol
| Papp of lsymbol * pat list
| Ptuple of pat list
| Por of pat * pat
......@@ -185,7 +185,7 @@ module ML = struct
List.iter (iter_deps_pat f) patl
and iter_deps_pat f = function
| Pwild | Pident _ -> ()
| Pwild | Pvar _ -> ()
| Papp (ls, patl) ->
f ls.ls_name;
iter_deps_pat_list f patl
......@@ -353,7 +353,7 @@ module Translate = struct
| Pvar vs when (restore_pv vs).pv_ghost ->
ML.Pwild
| Pvar vs ->
ML.Pident vs.vs_name
ML.Pvar vs
| Por (p1, p2) ->
ML.Por (pat p1, pat p2)
| Pas (p, vs) when (restore_pv vs).pv_ghost ->
......@@ -534,7 +534,7 @@ module Translate = struct
(* expressions *)
let rec expr info ({e_effect = eff} as e) =
assert (not eff.eff_ghost);
(* assert (not eff.eff_ghost); *) (*FIXME add this back*)
match e.e_node with
| Econst c ->
let c = match c with Number.ConstInt c -> c | _ -> assert false in
......
This diff is collapsed.
......@@ -74,7 +74,7 @@ module Print = struct
let rec forget_pat = function
| Pwild -> ()
| Pident id -> forget_id id
| Pvar {vs_name=id} -> forget_id id
| Papp (_, pl) | Ptuple pl -> List.iter forget_pat pl
| Por (p1, p2) -> forget_pat p1; forget_pat p2
| Pas (p, _) -> forget_pat p
......@@ -196,7 +196,7 @@ module Print = struct
let rec print_pat info fmt = function
| Pwild ->
fprintf fmt "_"
| Pident id ->
| Pvar {vs_name=id} ->
print_ident fmt id
| Pas (p, id) ->
fprintf fmt "%a as %a" (print_pat info) p print_ident id
......@@ -229,6 +229,7 @@ module Print = struct
let ht_rs = Hrs.create 7 (* rec_rsym -> rec_sym *)
(* FIXME put these in Compile*)
let is_true e = match e.e_node with
| Eapp (s, []) -> rs_equal s rs_true
| _ -> false
......
......@@ -146,6 +146,9 @@ let print_mdecls ?fname m mdecls =
let cout, old = get_cout_old fg m ?fname in
let fmt = formatter_of_out_channel cout in
let flat = opt_modu_flat = Flat in
List.iter
(fun s -> fprintf fmt "%s@." s)
pargs.Pdriver.prelude;
List.iter (pr pargs ?old ?fname ~flat m fmt) mdecls;
if cout <> stdout then close_out cout end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment