Project

General

Profile

« Previous | Next » 

Revision 81d69074

Added by LĂ©lio Brun 10 months ago

fix bug where singleton tuples were generated

View differences:

src/backends/C/c_backend_spec.ml
98 98

  
99 99
let pp_bool_cast pp fmt x = pp_cast pp_print_string pp fmt ("_Bool", x)
100 100

  
101
let pp_double_cast pp fmt x = pp_cast pp_print_string pp fmt ("double", x)
102

  
101 103
let pp_true_c_bool fmt () = pp_bool_cast pp_print_string fmt "1"
102 104

  
103 105
let pp_false fmt () = pp_print_string fmt "\\false"
......
412 414
  let pp_expr ?(test_output = false) m mem fmt = function
413 415
    | Val v ->
414 416
      let pp = pp_c_val m mem (pp_c_var_read ~test_output m) in
415
      (if not_var v && Types.is_bool_type v.value_type then pp_bool_cast pp else pp) fmt v
417
      (if not_var v
418
       then if Types.is_bool_type v.value_type
419
         then pp_bool_cast pp
420
         else if Types.is_real_type v.value_type
421
         then pp_double_cast pp
422
         else pp
423
       else pp) fmt v
416 424
    | Tag t ->
417 425
      pp_print_string fmt t
418 426
    | Var v ->
src/types.ml
143 143

  
144 144
  val get_static_value : t -> Dimension.t option
145 145

  
146
  val types_of_tuple_type : t -> t list
147

  
146 148
  val is_tuple_type : t -> bool
147 149

  
148 150
  val type_of_type_list : t list -> t
......
497 499
    let ty = repr ty in
498 500
    match ty.tdesc with Tstatic (_, ty') -> ty' | _ -> ty
499 501

  
502
  let types_of_tuple_type ty =
503
    match (repr ty).tdesc with Ttuple ts -> ts | _ -> []
504

  
500 505
  let is_tuple_type ty =
501 506
    match (repr ty).tdesc with Ttuple _ -> true | _ -> false
502 507

  
src/types.mli
129 129

  
130 130
  val get_static_value : t -> Dimension.t option
131 131

  
132
  val types_of_tuple_type : t -> t list
133

  
132 134
  val is_tuple_type : t -> bool
133 135

  
134 136
  val type_of_type_list : t list -> t
src/typing.ml
644 644
        let touts = type_appl env in_main expr.expr_loc const id args_list in
645 645
        let targs =
646 646
          new_ty
647
            (Ttuple
648
               (List.map (fun a -> Expr_type_hub.import a.expr_type) args_list))
647
            (match args_list with
648
             | [a] -> (Expr_type_hub.import a.expr_type).tdesc
649
             | _ ->
650
               Ttuple
651
                 (List.map (fun a -> Expr_type_hub.import a.expr_type) args_list))
649 652
        in
650 653
        args.expr_type <- Expr_type_hub.export targs;
651 654
        expr.expr_type <- Expr_type_hub.export touts;

Also available in: Unified diff