Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed extraction #15

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions kernel/uint63.mli
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,8 @@ val compare : t -> t -> int
val head0 : t -> t
val tail0 : t -> t

val foldi_cont :
(t -> ('a -> 'b) -> 'a -> 'b) -> t -> t -> ('a -> 'b) -> 'a -> 'b
val foldi_down_cont :
(t -> ('a -> 'b) -> 'a -> 'b) -> t -> t -> ('a -> 'b) -> 'a -> 'b
val print_uint : t -> t
16 changes: 16 additions & 0 deletions kernel/uint63_amd64.ml
Original file line number Diff line number Diff line change
Expand Up @@ -181,3 +181,19 @@ let tail0 x =
if !x land 0x3 = 0 then (x := !x lsr 2; r := !r + 2);
if !x land 0x1 = 0 then ( r := !r + 1);
!r

let rec foldi_cont f min max cont a =
if lt min max then f min (foldi_cont f (add min 1) max cont) a
else if min = max then f min cont a
else cont a

let rec foldi_down_cont f max min cont a =
if lt min max then
f max (foldi_down_cont f (sub max 1) min cont) a
else if min = max then f min cont a
else cont a

let print_uint x =
Printf.fprintf stderr "%s" (to_string x);
flush stderr;
x
16 changes: 16 additions & 0 deletions kernel/uint63_x86.ml
Original file line number Diff line number Diff line change
Expand Up @@ -115,3 +115,19 @@ let tail0 x =
if Int64.logand !x 0x3L = 0L then (x := Int64.shift_right !x 2; r := !r + 2);
if Int64.logand !x 0x1L = 0L then ( r := !r + 1);
Int64.of_int !r

let rec foldi_cont f min max cont a =
if lt min max then f min (foldi_cont f (add min 1) max cont) a
else if min = max then f min cont a
else cont a

let rec foldi_down_cont f max min cont a =
if lt min max then
f max (foldi_down_cont f (sub max 1) min cont) a
else if min = max then f min cont a
else cont a

let print_uint x =
Printf.fprintf stderr "%s" (to_string x);
flush stderr;
x
53 changes: 53 additions & 0 deletions plugins/extraction/ExtractNative.v
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
Require Import Int63.
Require Import PArray.

Extract Inductive bool => "bool" ["true" "false"].
Extract Inductive comparison => "int" ["0" "(-1)" "1"].
Extract Inductive prod => "(*)" [ "(,)" ].
Extract Inductive carry => "Uint63.carry" ["Uint63.C0" "Uint63.C1"].

Extract Constant int => "Uint63.t".
Extract Constant lsl => "Uint63.l_sl".
Extract Constant lsr => "Uint63.l_sr".
Extract Constant Int63Native.land => "Uint63.l_and".
Extract Constant Int63Native.lor => "Uint63.l_or".
Extract Constant Int63Native.lxor => "Uint63.l_xor".
Extract Constant add => "Uint63.add".
Extract Constant sub => "Uint63.sub".
Extract Constant mul => "Uint63.mul".
Extract Constant mulc => "Uint63.mulc".
Extract Constant div => "Uint63.div".
Extract Constant Int63Native.mod => "Uint63.rem".
Extract Constant eqb => "Uint63.eq".
Extract Constant ltb => "Uint63.lt".
Extract Constant leb => "Uint63.le".
Extract Constant compare => "Uint63.compare".
Extract Constant head0 => "Uint63.head0".
Extract Constant tail0 => "Uint63.tail0".

Extract Constant addc => "Uint63.addc".
Extract Constant addcarryc => "Uint63.addcarryc".
Extract Constant subc => "Uint63.subc".
Extract Constant subcarryc => "Uint63.subcarryc".
Extract Constant diveucl => "Uint63.diveucl".

Extract Constant diveucl_21 => "Uint63.diveucl_21".
Extract Constant addmuldiv => "Uint63.addmuldiv".

(* Pierre que faut-il faire pour celui la *)
(* Extract Constant eqb_correct => "Uint63.eqb_correct". *)
Extract Constant foldi_cont => "Uint63.foldi_cont".
Extract Constant foldi_down_cont => "Uint63.foldi_down_cont".
Extract Constant print_int => "Uint63.print_uint".

(** Extraction of Array *)
Extract Constant array "'a" => "'a Parray.t".
Extract Constant make => "Parray.make".
Extract Constant get => "Parray.get".
Extract Constant default => "Parray.default".
Extract Constant set => "Parray.set".
Extract Constant length => "Parray.length".
Extract Constant copy => "Parray.copy".
Extract Constant reroot => "Parray.reroot".
Extract Constant init => "Parray.init".
Extract Constant map => "Parray.map".
2 changes: 1 addition & 1 deletion plugins/extraction/ocaml.ml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ let keywords =
"module"; "mutable"; "new"; "object"; "of"; "open"; "or";
"parser"; "private"; "rec"; "sig"; "struct"; "then"; "to"; "true";
"try"; "type"; "val"; "virtual"; "when"; "while"; "with"; "mod";
"land"; "lor"; "lxor"; "lsl"; "lsr"; "asr" ; "unit" ; "_" ; "__" ]
"land"; "lor"; "lxor"; "lsl"; "lsr"; "asr" ; "unit" ; "int" ; "_" ; "__" ]
Idset.empty

let pp_open mp = str ("open "^ string_of_modfile mp ^"\n")
Expand Down
1 change: 1 addition & 0 deletions plugins/extraction/vo.itarget
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ExtractNative.vo
ExtrOcamlBasic.vo
ExtrOcamlIntConv.vo
ExtrOcamlBigIntConv.vo
Expand Down
53 changes: 0 additions & 53 deletions theories/Array/ExtractNative.v

This file was deleted.

Loading