Project

General

Profile

Revision 00970bbf

View differences:

src/backends/VHDL/vhdl_ast.ml
80 80
  | NoName
81 81
and vhdl_assoc_element_t =
82 82
  {
83
    formal_name: vhdl_name_t option [@default Some NoName];
84
    formal_arg: vhdl_name_t option [@default Some NoName];
85
    actual_name: vhdl_name_t option [@default Some NoName];
86
    actual_designator: vhdl_name_t option [@default Some NoName];
87
    actual_expr: vhdl_expr_t option [@default Some IsNull];
83
    formal_name: vhdl_name_t option [@default None];
84
    formal_arg: vhdl_name_t option [@default None];
85
    actual_name: vhdl_name_t option [@default None];
86
    actual_designator: vhdl_name_t option [@default None];
87
    actual_expr: vhdl_expr_t option [@default None];
88 88
  }
89 89
and vhdl_element_assoc_t =
90 90
  {
......
133 133
    names: vhdl_name_t list;
134 134
    mode: string list [@default []];
135 135
    typ: vhdl_subtype_indication_t;
136
    init_val: vhdl_cst_val_t option [@default Some (CstInt (0))];
136
    init_val: vhdl_cst_val_t option [@default None];
137 137
  }
138 138
[@@deriving show { with_path = false }, yojson {strict = false}];;
139 139

  
......
182 182
  | VarDecl of {
183 183
      names : vhdl_name_t list; 
184 184
      typ : vhdl_subtype_indication_t; 
185
      init_val : vhdl_cst_val_t option [@default Some (CstInt (0))] 
185
      init_val : vhdl_cst_val_t option [@default None] 
186 186
    } [@name "VARIABLE_DECLARATION"]
187 187
  | CstDecl of { 
188 188
      names : vhdl_name_t list; 
......
192 192
  | SigDecl of { 
193 193
      names : vhdl_name_t list; 
194 194
      typ : vhdl_subtype_indication_t; 
195
      init_val : vhdl_cst_val_t option [@default Some (CstInt (0))] 
195
      init_val : vhdl_cst_val_t option [@default None] 
196 196
    } [@name "SIGNAL_DECLARATION"]
197 197
  | Subprogram of {
198 198
      name: vhdl_name_t [@default NoName]; 
src/backends/VHDL/vhdl_ast_deriving.ml
153 153
  | NoName 
154 154
and vhdl_assoc_element_t =
155 155
  {
156
  formal_name: vhdl_name_t option [@default Some NoName];
157
  formal_arg: vhdl_name_t option [@default Some NoName];
158
  actual_name: vhdl_name_t option [@default Some NoName];
159
  actual_designator: vhdl_name_t option [@default Some NoName];
160
  actual_expr: vhdl_expr_t option [@default Some IsNull]}
156
  formal_name: vhdl_name_t option [@default None];
157
  formal_arg: vhdl_name_t option [@default None];
158
  actual_name: vhdl_name_t option [@default None];
159
  actual_designator: vhdl_name_t option [@default None];
160
  actual_expr: vhdl_expr_t option [@default None]}
161 161
and vhdl_element_assoc_t = {
162 162
  choices: vhdl_expr_t list ;
163 163
  expr: vhdl_expr_t }
......
471 471
and show_vhdl_expr_t : vhdl_expr_t -> Ppx_deriving_runtime.string =
472 472
  fun x  -> Format.asprintf "%a" pp_vhdl_expr_t x
473 473

  
474
(* Missing adaptation for : Function *)
474
(* Adapted *)
475 475
and pp_vhdl_name_t :
476 476
  Format.formatter -> vhdl_name_t -> Ppx_deriving_runtime.unit =
477 477
  let __9 () = pp_vhdl_assoc_element_t
......
540 540
                ((__7 ()) fmt) aexpr;
541 541
                Format.fprintf fmt ")")
542 542
        | Function { id = aid; assoc_list = aassoc_list } ->
543
            (Format.fprintf fmt "@[<2>Function {@,";
544
             ((Format.fprintf fmt "@[%s =@ " "id";
545
               ((__8 ()) fmt) aid;
546
               Format.fprintf fmt "@]");
547
              Format.fprintf fmt ";@ ";
548
              Format.fprintf fmt "@[%s =@ " "assoc_list";
549
              ((fun x  ->
550
                  Format.fprintf fmt "@[<2>[";
551
                  ignore
552
                    (List.fold_left
553
                       (fun sep  ->
554
                          fun x  ->
555
                            if sep then Format.fprintf fmt ";@ ";
556
                            ((__9 ()) fmt) x;
557
                            true) false x);
558
                  Format.fprintf fmt "@,]@]")) aassoc_list;
559
              Format.fprintf fmt "@]");
560
             Format.fprintf fmt "@]}")
543
            (((__8 ()) fmt) aid;
544
            Format.fprintf fmt "(";
545
            ((fun x  ->
546
              Format.fprintf fmt "@[";
547
              ignore
548
                (List.fold_left
549
                   (fun sep  ->
550
                      fun x  ->
551
                        if sep then Format.fprintf fmt ";@ ";
552
                        ((__9 ()) fmt) x;
553
                        true) false x);
554
            Format.fprintf fmt "@]")) aassoc_list;
555
            Format.fprintf fmt ")";)
561 556
        | NoName  -> Format.pp_print_string fmt "")
562 557
    [@ocaml.warning "-A"])
563 558

  
564 559
and show_vhdl_name_t : vhdl_name_t -> Ppx_deriving_runtime.string =
565 560
  fun x  -> Format.asprintf "%a" pp_vhdl_name_t x
566 561

  
562
(* Adapted *)
567 563
and pp_vhdl_assoc_element_t :
568 564
  Format.formatter -> vhdl_assoc_element_t -> Ppx_deriving_runtime.unit =
569 565
  let __4 () = pp_vhdl_expr_t
......
579 575
  ((let open! Ppx_deriving_runtime in
580 576
      fun fmt  ->
581 577
        fun x  ->
582
          Format.fprintf fmt "@[<2>{ ";
583
          (((((Format.fprintf fmt "@[%s =@ " "formal_name";
584
               ((function
585
                 | None  -> Format.pp_print_string fmt "None"
586
                 | Some x ->
587
                     (Format.pp_print_string fmt "(Some ";
588
                      ((__0 ()) fmt) x;
589
                      Format.pp_print_string fmt ")"))) x.formal_name;
590
               Format.fprintf fmt "@]");
591
              Format.fprintf fmt ";@ ";
592
              Format.fprintf fmt "@[%s =@ " "formal_arg";
593
              ((function
594
                | None  -> Format.pp_print_string fmt "None"
595
                | Some x ->
596
                    (Format.pp_print_string fmt "(Some ";
597
                     ((__1 ()) fmt) x;
598
                     Format.pp_print_string fmt ")"))) x.formal_arg;
599
              Format.fprintf fmt "@]");
600
             Format.fprintf fmt ";@ ";
601
             Format.fprintf fmt "@[%s =@ " "actual_name";
602
             ((function
603
               | None  -> Format.pp_print_string fmt "None"
604
               | Some x ->
605
                   (Format.pp_print_string fmt "(Some ";
606
                    ((__2 ()) fmt) x;
607
                    Format.pp_print_string fmt ")"))) x.actual_name;
608
             Format.fprintf fmt "@]");
609
            Format.fprintf fmt ";@ ";
610
            Format.fprintf fmt "@[%s =@ " "actual_designator";
611
            ((function
612
              | None  -> Format.pp_print_string fmt "None"
613
              | Some x ->
614
                  (Format.pp_print_string fmt "(Some ";
615
                   ((__3 ()) fmt) x;
616
                   Format.pp_print_string fmt ")"))) x.actual_designator;
617
            Format.fprintf fmt "@]");
618
           Format.fprintf fmt ";@ ";
619
           Format.fprintf fmt "@[%s =@ " "actual_expr";
620
           ((function
621
             | None  -> Format.pp_print_string fmt "None"
622
             | Some x ->
623
                 (Format.pp_print_string fmt "(Some ";
624
                  ((__4 ()) fmt) x;
625
                  Format.pp_print_string fmt ")"))) x.actual_expr;
626
           Format.fprintf fmt "@]");
627
          Format.fprintf fmt "@ }@]")
578
          (match x.formal_name with
579
          | None -> Format.pp_print_string fmt ""
580
          | Some NoName -> Format.pp_print_string fmt ""
581
          | Some a -> 
582
              (((__0 ()) fmt) a;
583
              (match x.formal_arg with
584
              | None -> ()
585
              | Some b -> Format.fprintf fmt "(";
586
                          ((__1 ()) fmt) b;
587
                          Format.fprintf fmt ")");
588
              Format.fprintf fmt " => "));
589
          (match x.actual_name with
590
          | None -> Format.pp_print_string fmt ""
591
          | Some a -> 
592
              (((__2 ()) fmt) a;
593
              (match x.actual_designator with
594
              | None -> ()
595
              | Some NoName -> Format.pp_print_string fmt ""
596
              | Some b -> (Format.fprintf fmt "(";
597
                          ((__3 ()) fmt) b;
598
                          Format.fprintf fmt ")"));
599
              (match x.actual_expr with
600
              | None -> ()
601
              | Some IsNull -> Format.pp_print_string fmt ""
602
              | Some c -> (Format.fprintf fmt "(";
603
                          ((__4 ()) fmt) c;
604
                          Format.fprintf fmt ")"))));)
628 605
    [@ocaml.warning "-A"])
629 606

  
630 607
and show_vhdl_assoc_element_t :
......
1696 1673
      fun x  ->
1697 1674
        let fields = []  in
1698 1675
        let fields =
1699
          if x.actual_expr = (Some IsNull)
1676
          if x.actual_expr = None
1700 1677
          then fields
1701 1678
          else
1702 1679
            ("actual_expr",
......
1707 1684
            :: fields
1708 1685
           in
1709 1686
        let fields =
1710
          if x.actual_designator = (Some NoName)
1687
          if x.actual_designator = None
1711 1688
          then fields
1712 1689
          else
1713 1690
            ("actual_designator",
......
1718 1695
            :: fields
1719 1696
           in
1720 1697
        let fields =
1721
          if x.actual_name = (Some NoName)
1698
          if x.actual_name = None
1722 1699
          then fields
1723 1700
          else
1724 1701
            ("actual_name",
......
1729 1706
            :: fields
1730 1707
           in
1731 1708
        let fields =
1732
          if x.formal_arg = (Some NoName)
1709
          if x.formal_arg = None
1733 1710
          then fields
1734 1711
          else
1735 1712
            ("formal_arg",
......
1740 1717
            :: fields
1741 1718
           in
1742 1719
        let fields =
1743
          if x.formal_name = (Some NoName)
1720
          if x.formal_name = None
1744 1721
          then fields
1745 1722
          else
1746 1723
            ("formal_name",
......
2295 2272
  names: vhdl_name_t list ;
2296 2273
  mode: string list [@default []];
2297 2274
  typ: vhdl_subtype_indication_t ;
2298
  init_val: vhdl_cst_val_t option [@default Some (CstInt 0)]}
2275
  init_val: vhdl_cst_val_t option [@default None]}
2299 2276

  
2300 2277
let rec pp_vhdl_parameter_t :
2301 2278
  Format.formatter -> vhdl_parameter_t -> Ppx_deriving_runtime.unit =
......
2358 2335
      fun x  ->
2359 2336
        let fields = []  in
2360 2337
        let fields =
2361
          if x.init_val = (Some (CstInt 0))
2338
          if x.init_val = None
2362 2339
          then fields
2363 2340
          else
2364 2341
            ("init_val",
......
2759 2736
                        ((__5 ()) fmt) x;
2760 2737
                        Format.fprintf fmt ";";
2761 2738
                        true) false x);
2762
             Format.fprintf fmt "@]@]")) arhs;
2739
            Format.fprintf fmt "@]@]")) arhs;
2763 2740
        | If { label = alabel; if_cases = aif_cases; default = adefault } ->
2764 2741
            (match alabel with
2765 2742
              | NoName -> Format.fprintf fmt "";
......
2777 2754
                                true
2778 2755
                 ) false x);
2779 2756
             )) aif_cases;
2780
            Format.fprintf fmt "@]";
2781
            (match adefault with
2757
             (match adefault with
2782 2758
              | [] -> Format.fprintf fmt "";
2783 2759
              | _  -> (Format.fprintf fmt "@;else";
2784 2760
                      ((fun x  ->
......
2789 2765
                                fun x  ->
2790 2766
                                        if sep then Format.fprintf fmt "";
2791 2767
                          ((__8 ()) fmt) x;
2792
                          true) false x);
2793
             )) adefault;))
2768
                          true) false x))) adefault));
2769
            Format.fprintf fmt "@;end if;@]"
2794 2770
        | Case { label = alabel; guard = aguard; branches = abranches } ->
2795 2771
            (match alabel with
2796 2772
              | NoName -> Format.fprintf fmt "";
......
2808 2784
                          if sep then Format.fprintf fmt "";
2809 2785
                          ((__11 ()) fmt) x;
2810 2786
                          true) false x);)) abranches;
2811
            Format.fprintf fmt "@]";
2787
            Format.fprintf fmt "@;end case;@]";
2812 2788
        | Exit
2813 2789
            { label = alabel; loop_label = aloop_label;
2814 2790
              condition = acondition }
......
3549 3525
  {
3550 3526
  names: vhdl_name_t list ;
3551 3527
  typ: vhdl_subtype_indication_t ;
3552
  init_val: vhdl_cst_val_t option [@default Some (CstInt 0)]}
3528
  init_val: vhdl_cst_val_t option [@default None]}
3553 3529
  [@name "VARIABLE_DECLARATION"]
3554 3530
  | CstDecl of
3555 3531
  {
......
3560 3536
  {
3561 3537
  names: vhdl_name_t list ;
3562 3538
  typ: vhdl_subtype_indication_t ;
3563
  init_val: vhdl_cst_val_t option [@default Some (CstInt 0)]}
3539
  init_val: vhdl_cst_val_t option [@default None]}
3564 3540
  [@name "SIGNAL_DECLARATION"]
3565 3541
  | Subprogram of
3566 3542
  {
......
3719 3695
            [`String "VARIABLE_DECLARATION";
3720 3696
            (let fields = []  in
3721 3697
             let fields =
3722
               if arg0.init_val = (Some (CstInt 0))
3698
               if arg0.init_val = None
3723 3699
               then fields
3724 3700
               else
3725 3701
                 ("init_val",
......
3764 3740
            [`String "SIGNAL_DECLARATION";
3765 3741
            (let fields = []  in
3766 3742
             let fields =
3767
               if arg0.init_val = (Some (CstInt 0))
3743
               if arg0.init_val = None
3768 3744
               then fields
3769 3745
               else
3770 3746
                 ("init_val",
......
5495 5471
                        fun x  ->
5496 5472
                          if sep then Format.fprintf fmt "@ ";
5497 5473
                          ((__2 ()) fmt) x;
5474
                          Format.fprintf fmt ";";
5498 5475
                          true) false x);
5499 5476
                Format.fprintf fmt "@]")) x.declarations;
5500 5477
            Format.fprintf fmt "@]");

Also available in: Unified diff