Project

General

Profile

« Previous | Next » 

Revision 3c3414c5

Added by Pierre-Loïc Garoche over 5 years ago

Solved issue with typing of enumerated types

View differences:

src/features/machine_types/machine_types.ml
278 278
    let typ = get_specified_type v in
279 279
    match (MTypes.dynamic_type typ).MTypes.tdesc with
280 280
    | MTypes.Tbasic b -> MT.is_exportable b
281
    | MTypes.Tconst _ -> false (* Enumerated types are not "machine type" customizeable *)
281 282
    | _ -> assert false  (* TODO deal with other constructs *)
282 283
  )      
283 284
(* could depend on the actual computed type *)
......
307 308
    Format.eprintf "Subtype mismatch %a vs %a@." MTypes.print_ty subtyp Types.print_ty typ; false
308 309
  in
309 310
  match (MTypes.dynamic_type subtype).MTypes.tdesc with
310
  
311
  | MTypes.Tconst c -> Types.is_const_type typ c
311 312
  | MTypes.Tbasic MT.MTint _ -> Types.is_int_type typ
312 313
  | MTypes.Tbasic MT.MTreal _ -> Types.is_real_type typ
313 314
  | MTypes.Tbasic MT.MTbool -> Types.is_bool_type typ
......
470 471

  
471 472
let has_machine_type () =
472 473
  let annl = Annotations.get_expr_annotations keyword in
473
  Format.eprintf "has _mchine _type annotations: %i@." (List.length annl);
474
  (* Format.eprintf "has _mchine _type annotations: %i@." (List.length annl); *)
474 475
  List.length annl > 0
475 476
      
476 477
(* Local Variables: *)
src/types.ml
326 326
 | Tbasic t -> BasicT.is_bool_type t
327 327
 | _     -> false
328 328

  
329
let rec is_const_type ty c =
330
  match (repr ty).tdesc with
331
  | Tstatic (_, ty) -> is_const_type ty c
332
  | Tconst c' -> c = c'
333
  | _     -> false
334

  
329 335
let get_clock_base_type ty =
330 336
 match (repr ty).tdesc with
331 337
 | Tclock ty -> Some ty
......
508 514
  val is_real_type: type_expr -> bool
509 515
  val is_int_type: type_expr -> bool
510 516
  val is_bool_type: type_expr -> bool
517
  val is_const_type: type_expr -> ident -> bool
511 518
  val is_static_type: type_expr -> bool
512 519
  val is_array_type: type_expr -> bool
513 520
  val is_dimension_type: type_expr -> bool
src/typing.ml
599 599
 | Tydec_clock ty
600 600
 | Tydec_array (_, ty) -> check_type_declaration loc ty
601 601
 | Tydec_const tname   ->
602
    Format.printf "TABLE: %a@." print_type_table ();
603
   (* TODO REMOVE *)
604
   if not (Hashtbl.mem type_table cty)
605
   then raise (Error (loc, Unbound_type tname));
602
    (* Format.eprintf "TABLE: %a@." print_type_table (); *)
603
    if not (Hashtbl.mem type_table cty)
604
    then raise (Error (loc, Unbound_type tname));
606 605
 | _                   -> ()
607 606

  
608 607
let type_var_decl vd_env env vdecl =

Also available in: Unified diff