Skip to content
Snippets Groups Projects
Commit 7ab09585 authored by Thibaut Benjamin's avatar Thibaut Benjamin Committed by Julien Signoles
Browse files

[e-acsl] refactor Gmp: remove Rational.name_arith_bop

parent e3d526b7
No related branches found
No related tags found
No related merge requests found
...@@ -159,6 +159,14 @@ module Z = struct ...@@ -159,6 +159,14 @@ module Z = struct
end end
module Q = struct module Q = struct
let name_arith_bop = function
| PlusA -> "__gmpq_add"
| MinusA -> "__gmpq_sub"
| Mult -> "__gmpq_mul"
| Div -> "__gmpq_div"
| Mod | Lt | Gt | Le | Ge | Eq | Ne | BAnd | BXor | BOr | LAnd | LOr
| Shiftlt | Shiftrt | PlusPI | MinusPI | MinusPP -> assert false
exception Not_a_decimal of string exception Not_a_decimal of string
exception Is_a_float exception Is_a_float
......
...@@ -48,6 +48,14 @@ module Z : sig ...@@ -48,6 +48,14 @@ module Z : sig
end end
module Q : sig
val name_arith_bop: binop -> string
(** [name_of_mpz_arith_bop bop] returns the name of the GMP function on integer
corresponding to the [bop] arithmetic operation. *)
end
val normalize_str: string -> string val normalize_str: string -> string
(** Normalize the string so that it fits the representation used by the (** Normalize the string so that it fits the representation used by the
underlying real library. For example, "0.1" is a real number in ACSL underlying real library. For example, "0.1" is a real number in ACSL
......
...@@ -111,16 +111,8 @@ let new_var_and_init ~loc ?scope ?name env kf t_opt mk_stmts = ...@@ -111,16 +111,8 @@ let new_var_and_init ~loc ?scope ?name env kf t_opt mk_stmts =
(Gmp_types.Q.t ()) (Gmp_types.Q.t ())
(fun v e -> Gmp.init ~loc e :: mk_stmts v e) (fun v e -> Gmp.init ~loc e :: mk_stmts v e)
let name_arith_bop = function
| PlusA -> "__gmpq_add"
| MinusA -> "__gmpq_sub"
| Mult -> "__gmpq_mul"
| Div -> "__gmpq_div"
| Mod | Lt | Gt | Le | Ge | Eq | Ne | BAnd | BXor | BOr | LAnd | LOr
| Shiftlt | Shiftrt | PlusPI | MinusPI | MinusPP -> assert false
let binop ~loc bop e1 e2 env kf t_opt = let binop ~loc bop e1 e2 env kf t_opt =
let name = name_arith_bop bop in let name = Gmp.Q.name_arith_bop bop in
(* TODO: [t1_opt] and [t2_opt] could be provided when creating [e1] and (* TODO: [t1_opt] and [t2_opt] could be provided when creating [e1] and
[e2] *) [e2] *)
let e1, env = Gmp_gen.Q.create ~loc None env kf e1 in let e1, env = Gmp_gen.Q.create ~loc None env kf e1 in
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment