let rec const ~in_code pos = function
  | CInt64(_i,_ik,Some s) -> JCPEconst(JCCinteger s)
      (* Use the textual representation if available *)

  | CInt64(i,_ik,None-> JCPEconst(JCCinteger(Int64.to_string i))

  | CStr _ | CWStr _ -> assert false  (* Should have been rewritten *)

  | CChr c -> JCPEconst(JCCinteger(string_of_int (Char.code c)))

  | CReal(_f,fk,Some s) ->
      (* Use the textual representation if available *)
      let s = strip_float_suffix s in
      begin match in_code,!float_model with
        | false,_ | _,`Real -> JCPEconst(JCCreal s)
        | true, (`Strict | `Full | `Multirounding->
            (* add a cast to float or double depending on the value of fk *)
            JCPEcast(mkexpr (JCPEconst(JCCreal s)) pos, mktype (JCPTnative (native_type_of_fkind fk)))
      end
  | CReal(f,_fk,None->
      (* otherwise use the float value *)
      JCPEconst(JCCreal(string_of_float f))

  | CEnum item ->
      let e = mkexpr (const_of_expr ~in_code pos item.eival) pos in
      JCPEcast(e,ctype (TEnum(item.eihost,[])))

and const_of_expr ~in_code pos e =
  match (stripInfo e).enode with
      Const c -> const ~in_code pos c
    | _ -> assert false

and boolean_const = function
  | CInt64(i,_ik,_text) ->
      if i = Int64.zero then JCCboolean false else JCCboolean true

  | CStr _ | CWStr _ -> JCCboolean true

  | CChr c ->
      if Char.code c = 0 then JCCboolean false else JCCboolean true

  | CReal(f,_fk,_text) ->
      if f = 0.0 then JCCboolean false else JCCboolean true

  | CEnum {eival = e} -> boolean_const_of_expr e

and boolean_const_of_expr e =
  match (stripInfo e).enode with Const c -> boolean_const c | _ -> assert false