let ctype ?bitsize ty =
let tnode = match unrollType ty with
| TVoid _attr -> JCPTnative Tunit
| TInt(_ik,_attr) ->
if Jessie_options.IntModel.get_val () = Jessie_options.IMexact then
JCPTnative Tinteger
else
JCPTidentifier (name_of_integral_type ?bitsize ty)
| TFloat(fk,_attr) ->
begin
match !float_model with
| `Real ->
JCPTnative Treal
| `Strict | `Full | `Multirounding ->
begin
match fk with
| FFloat -> JCPTnative (Tgenfloat `Float)
| FDouble -> JCPTnative (Tgenfloat `Double)
| FLongDouble -> failwith "Jessie does not handle long double yet"
end
end
| TPtr(_elemty,_attr) ->
if is_reference_type ty then
begin match unrollType (pointed_type ty) with
| TComp(compinfo,_,_) ->
let min_bound = Num.num_of_string "0" in
let max_bound =
Num.num_of_string (Int64.to_string (reference_size ty - 1L))
in
JCPTpointer(compinfo.cname,[],Some min_bound,Some max_bound)
| _ -> assert false
end
else
begin match unrollType (pointed_type ty) with
| TComp(compinfo,_,_) ->
JCPTpointer(compinfo.cname,[],None,None)
| _ -> assert false
end
| TArray _ -> assert false
| TFun _ ->
unsupported "Function pointer type %a not allowed"
!Ast_printer.d_type ty
| TNamed _ -> assert false
| TComp(compinfo,_,_) -> JCPTidentifier compinfo.cname
| TEnum(enuminfo,_) -> JCPTidentifier enuminfo.ename
| TBuiltin_va_list _ -> unsupported "Type builtin_va_list not allowed"
in
mktype tnode