Commit 735ff34c authored by Julien Signoles's avatar Julien Signoles
Browse files

[typing] reimplement Typing.Datatype

parent e20c54bf
...@@ -56,27 +56,33 @@ module D = ...@@ -56,27 +56,33 @@ module D =
let reprs = [ Gmpz; Real; Nan; c_int ] let reprs = [ Gmpz; Real; Nan; c_int ]
include Datatype.Undefined include Datatype.Undefined
(* TODO RATIONAL: re-implement this datatype *)
(*
let compare ty1 ty2 = match ty1, ty2 with let compare ty1 ty2 = match ty1, ty2 with
| C_type i1, C_type i2 -> | C_type i1, C_type i2 ->
if i1 = i2 then 0 if i1 = i2 then 0
else if Cil.intTypeIncluded i1 i2 then -1 else 1 else if Cil.intTypeIncluded i1 i2 then -1 else 1
| (Other | C_type _), Gmp | Other, C_type _ -> -1 | (C_type _ | Gmpz | Real), Nan
| Gmp, (C_type _ | Other) | C_type _, Other -> 1 | (C_type _ | Gmpz), Real
| Gmp, Gmp | Other, Other -> 0 | C_type _, Gmpz ->
-1
| (Gmpz | Real | Nan), C_type _
| (Real | Nan), Gmpz
| Nan, Real ->
1
| Gmpz, Gmpz | Real, Real | Nan, Nan -> 0
let equal = Datatype.from_compare let equal = Datatype.from_compare
let hash = function let hash = function
| Gmp -> 787 | C_type ik -> 7 * Hashtbl.hash ik
| Other -> 1011 | Gmpz -> 787
| C_type ik -> Hashtbl.hash ik | Real -> 1011
| Nan -> 1277
let pretty fmt = function let pretty fmt = function
| Gmp -> Format.pp_print_string fmt "GMP"
| C_type k -> Printer.pp_ikind fmt k | C_type k -> Printer.pp_ikind fmt k
| Other -> Format.pp_print_string fmt "OTHER"*) | Gmpz -> Format.pp_print_string fmt "Gmpz"
| Real -> Format.pp_print_string fmt "Real"
| Nan -> Format.pp_print_string fmt "Nan"
end) 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