Commit cf6265e7 authored by Julien Signoles's avatar Julien Signoles
Browse files

[typing] minor changes in typing of reals

parent d8902fc0
...@@ -60,9 +60,12 @@ let rec interv_of_typ_with_real ty is_real = match Cil.unrollType ty with ...@@ -60,9 +60,12 @@ let rec interv_of_typ_with_real ty is_real = match Cil.unrollType ty with
| TEnum(enuminfo, _) -> | TEnum(enuminfo, _) ->
interv_of_typ_with_real (TInt (enuminfo.ekind, [])) is_real interv_of_typ_with_real (TInt (enuminfo.ekind, [])) is_real
| TFloat _ -> | TFloat _ ->
(* TODO RATIONAL: examine TODO below. In particular this case is equivalent
* to the next case when [Real.is_t ty]. *)
(* TODO: Do not systematically consider floats as reals for efficiency *) (* TODO: Do not systematically consider floats as reals for efficiency *)
Ival.bottom, true Ival.bottom, true
| _ when Real.is_t ty -> | _ when Real.is_t ty ->
(* TODO RATIONAL: why bottom and not top? Why not raising Is_a_real? *)
Ival.bottom, true Ival.bottom, true
| _ -> | _ ->
raise Not_a_number raise Not_a_number
...@@ -71,6 +74,7 @@ let interv_of_logic_typ = function ...@@ -71,6 +74,7 @@ let interv_of_logic_typ = function
| Ctype ty -> interv_of_typ_with_real ty false | Ctype ty -> interv_of_typ_with_real ty false
| Linteger -> Ival.inject_range None None, false | Linteger -> Ival.inject_range None None, false
| Lreal -> Ival.bottom, true | Lreal -> Ival.bottom, true
(* TODO RATIONAL: why bottom and not top? Why not raising Is_a_real? *)
| Ltype _ -> Error.not_yet "user-defined logic type" | Ltype _ -> Error.not_yet "user-defined logic type"
| Lvar _ -> Error.not_yet "type variable" | Lvar _ -> Error.not_yet "type variable"
| Larrow _ -> Error.not_yet "functional type" | Larrow _ -> Error.not_yet "functional type"
...@@ -385,9 +389,12 @@ and infer_term_host thost is_real = ...@@ -385,9 +389,12 @@ and infer_term_host thost is_real =
match v.lv_type with match v.lv_type with
| Linteger -> | Linteger ->
Ival.inject_range None None, false Ival.inject_range None None, false
| Ctype (TFloat _) -> (* TODO: handle in MR !226 *) | Ctype (TFloat _) ->
(* TODO RATIONAL: examine below. That is MR !226! *)
(* TODO: handle in MR !226 *)
raise Not_an_integer raise Not_an_integer
| Lreal -> | Lreal ->
(* TODO RATIONAL: why bottom and not top? Why not raising Is_a_real? *)
Ival.bottom, true Ival.bottom, true
| Ctype _ -> | Ctype _ ->
(* TODO RATIONAL: check if [false] is the correct value *) (* TODO RATIONAL: check if [false] is the correct value *)
......
...@@ -905,11 +905,11 @@ let term_to_exp typ t = ...@@ -905,11 +905,11 @@ let term_to_exp typ t =
(* infer a context from the given [typ] whenever possible *) (* infer a context from the given [typ] whenever possible *)
let ctx_of_typ ty = let ctx_of_typ ty =
if Gmp.Z.is_t ty then Typing.gmpz if Gmp.Z.is_t ty then Typing.gmpz
else if Real.is_t ty then Typing.libr else if Real.is_t ty then Typing.real
else else
match ty with match ty with
| TInt(ik, _) -> Typing.ikind ik | TInt(ik, _) -> Typing.ikind ik
| TFloat _ -> Typing.libr | TFloat _ -> Typing.real
| _ -> Typing.nan | _ -> Typing.nan
in in
let ctx = Extlib.opt_map ctx_of_typ typ in let ctx = Extlib.opt_map ctx_of_typ typ in
......
This diff is collapsed.
...@@ -65,7 +65,7 @@ module Datatype: Datatype.S_with_collections with type t = number_ty ...@@ -65,7 +65,7 @@ module Datatype: Datatype.S_with_collections with type t = number_ty
val c_int: number_ty val c_int: number_ty
val ikind: ikind -> number_ty val ikind: ikind -> number_ty
val gmpz: number_ty val gmpz: number_ty
val libr: number_ty val real: number_ty
val nan: number_ty val nan: number_ty
(** {3 Useful operations over {!number_ty}} *) (** {3 Useful operations over {!number_ty}} *)
......
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