From ede2cc7a69f8d025353ee9df75eca7da8a3cd0c3 Mon Sep 17 00:00:00 2001 From: Kathy Gray Date: Thu, 6 Feb 2014 16:13:12 +0000 Subject: coerce bit to bool when not a literal bit. Note: this will only add a conversion function for expressions of bit type, an explicit cast to bit would be needed to come from an enum or nat. --- src/type_internal.ml | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src') diff --git a/src/type_internal.ml b/src/type_internal.ml index 80aee5cb..b1baa982 100644 --- a/src/type_internal.ml +++ b/src/type_internal.ml @@ -497,6 +497,9 @@ let rec type_coerce l d_env t1 e t2 = (l,Some(([],t2),Emp,[],pure_e)))) enums), (l,Some(([],t2),Emp,[],pure_e)))) | None -> eq_error l ("Type mismatch: " ^ (t_to_string t1) ^ " , " ^ (t_to_string t2)))) + | Tid("bit"),Tid("bool") -> + let e' = E_aux(E_app((Id_aux(Id "is_one",l)),[e]),(l,Some(([],bool_t),External,[],pure_e))) in + (t2,[],e') | Tid(i),Tapp("enum",[TA_nexp b1;TA_nexp r1;]) -> (match get_abbrev d_env t1 with | Some(t1,cs1,ef1) -> -- cgit v1.2.3