Project

General

Profile

« Previous | Next » 

Revision 7f55f63f

Added by Arnaud Dieumegard over 3 years ago

Default value corrections

View differences:

src/backends/VHDL/vhdl_ast.ml
94 94
  }
95 95
and vhdl_element_assoc_t =
96 96
  {
97
    choices: vhdl_expr_t list;
97
    choices: vhdl_expr_t list [@default []];
98 98
    expr: vhdl_expr_t;
99 99
  }
100 100
and vhdl_array_attributes_t = 
......
223 223
      ports: vhdl_port_t list [@default []];
224 224
    } [@name "COMPONENT_DECLARATION"]
225 225
  | Subprogram of {
226
      name: vhdl_name_t [@default NoName]; 
226
      name: string [@default ""]; 
227 227
      kind: string [@default ""]; 
228
      spec: vhdl_subprogram_spec_t [@default {name="";typeMark=NoName;parameters=[];isPure=false}]; 
228
      spec: vhdl_subprogram_spec_t option [@default None]; 
229 229
      decl_part: vhdl_declaration_t list [@default []]; 
230 230
      stmts: vhdl_sequential_stmt_t list [@default []]
231 231
    } [@name "SUBPROGRAM_BODY"]
......
323 323
    name: vhdl_name_t [@default NoName];
324 324
    generics: vhdl_port_t list [@default []];
325 325
    ports: vhdl_port_t list [@default []];
326
    declaration: vhdl_declaration_t list [@key "ENTITY_DECLARATIVE_PART"] [@default []];
326
    declaration: vhdl_declarative_item_t list [@key "ENTITY_DECLARATIVE_PART"] [@default []];
327 327
    stmts: vhdl_concurrent_stmt_t list [@key "ENTITY_STATEMENT_PART"] [@default []]; 
328 328
  }
329 329
[@@deriving show { with_path = false }, yojson {strict = false}];;
src/backends/VHDL/vhdl_ast_deriving.ml
171 171
  actual_designator: vhdl_name_t option [@default None];
172 172
  actual_expr: vhdl_expr_t option [@default None]}
173 173
and vhdl_element_assoc_t = {
174
  choices: vhdl_expr_t list ;
174
  choices: vhdl_expr_t list [@default []];
175 175
  expr: vhdl_expr_t }
176 176
and vhdl_array_attributes_t =
177 177
  | AAttInt of {
......
2058 2058
        let fields = ("expr", ((fun x  -> vhdl_expr_t_to_yojson x) x.expr))
2059 2059
          :: fields  in
2060 2060
        let fields =
2061
          ("choices",
2062
            ((fun x  ->
2063
                `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x))
2064
               x.choices))
2065
          :: fields  in
2061
          if x.choices = []
2062
          then fields
2063
          else
2064
            ("choices",
2065
              (((fun x  ->
2066
                   `List (List.map (fun x  -> vhdl_expr_t_to_yojson x) x)))
2067
                 x.choices))
2068
            :: fields
2069
           in
2066 2070
        `Assoc fields)
2067 2071
  [@ocaml.warning "-A"])
2068 2072

  
......
2093 2097
                           Result.Ok { choices = arg0; expr = arg1 })))
2094 2098
            | _::xs -> loop xs _state  in
2095 2099
          loop xs
2096
            ((Result.Error "Vhdl_ast.vhdl_element_assoc_t.choices"),
2100
            ((Result.Ok []),
2097 2101
              (Result.Error "Vhdl_ast.vhdl_element_assoc_t.expr"))
2098 2102
      | _ -> Result.Error "Vhdl_ast.vhdl_element_assoc_t")
2099 2103
  [@ocaml.warning "-A"])
......
4048 4052
  ports: vhdl_port_t list [@default []]} [@name "COMPONENT_DECLARATION"]
4049 4053
  | Subprogram of
4050 4054
  {
4051
  name: vhdl_name_t [@default NoName];
4055
  name: string [@default ""];
4052 4056
  kind: string [@default ""];
4053
  spec: vhdl_subprogram_spec_t
4054
    [@default
4055
      { name = ""; typeMark = NoName; parameters = []; isPure = false }];
4057
  spec: vhdl_subprogram_spec_t option [@default None];
4056 4058
  decl_part: vhdl_declaration_t list [@default []];
4057 4059
  stmts: vhdl_sequential_stmt_t list [@default []]} [@name "SUBPROGRAM_BODY"]
4058 4060

  
4059 4061
(* Needs adaptation for: SubProgram *)
4060 4062
let rec pp_vhdl_declaration_t :
4061 4063
  Format.formatter -> vhdl_declaration_t -> Ppx_deriving_runtime.unit =
4062
  let __15 () = pp_vhdl_sequential_stmt_t
4063
  
4064
  and __14 () = pp_vhdl_declaration_t
4064
  let __14 () = pp_vhdl_sequential_stmt_t
4065 4065
  
4066
  and __13 () = pp_vhdl_subprogram_spec_t
4067
  
4068
  and __12 () = pp_vhdl_name_t
4066
  and __13 () = pp_vhdl_declaration_t
4069 4067
  
4068
  and __12 () = pp_vhdl_subprogram_spec_t
4069

  
4070 4070
  and __11 () = pp_vhdl_port_t
4071 4071
  
4072 4072
  and __10 () = pp_vhdl_port_t
......
4171 4171
            ->
4172 4172
            (Format.fprintf fmt "@[<2>Subprogram {@,";
4173 4173
             (((((Format.fprintf fmt "@[%s =@ " "name";
4174
                  ((__12 ()) fmt) aname;
4174
                  (Format.fprintf fmt "%S") aname;
4175 4175
                  Format.fprintf fmt "@]");
4176 4176
                 Format.fprintf fmt ";@ ";
4177 4177
                 Format.fprintf fmt "@[%s =@ " "kind";
......
4179 4179
                 Format.fprintf fmt "@]");
4180 4180
                Format.fprintf fmt ";@ ";
4181 4181
                Format.fprintf fmt "@[%s =@ " "spec";
4182
                ((__13 ()) fmt) aspec;
4182
                ((function
4183
                  | None  -> Format.pp_print_string fmt "None"
4184
                  | Some x ->
4185
                      (Format.pp_print_string fmt "(Some ";
4186
                       ((__12 ()) fmt) x;
4187
                       Format.pp_print_string fmt ")"))) aspec;
4183 4188
                Format.fprintf fmt "@]");
4184 4189
               Format.fprintf fmt ";@ ";
4185 4190
               Format.fprintf fmt "@[%s =@ " "decl_part";
......
4190 4195
                        (fun sep  ->
4191 4196
                           fun x  ->
4192 4197
                             if sep then Format.fprintf fmt ";@ ";
4193
                             ((__14 ()) fmt) x;
4198
                             ((__13 ()) fmt) x;
4194 4199
                             true) false x);
4195 4200
                   Format.fprintf fmt "@,]@]")) adecl_part;
4196 4201
               Format.fprintf fmt "@]");
......
4203 4208
                       (fun sep  ->
4204 4209
                          fun x  ->
4205 4210
                            if sep then Format.fprintf fmt ";@ ";
4206
                            ((__15 ()) fmt) x;
4211
                            ((__14 ()) fmt) x;
4207 4212
                            true) false x);
4208 4213
                  Format.fprintf fmt "@,]@]")) astmts;
4209 4214
              Format.fprintf fmt "@]");
......
4347 4352
                 :: fields
4348 4353
                in
4349 4354
             let fields =
4350
               if
4351
                 arg0.spec =
4352
                   {
4353
                     name = "";
4354
                     typeMark = NoName;
4355
                     parameters = [];
4356
                     isPure = false
4357
                   }
4355
               if arg0.spec = None
4358 4356
               then fields
4359 4357
               else
4360 4358
                 ("spec",
4361
                   (((fun x  -> vhdl_subprogram_spec_t_to_yojson x))
4359
                   (((function
4360
                      | None  -> `Null
4361
                      | Some x ->
4362
                          ((fun x  -> vhdl_subprogram_spec_t_to_yojson x)) x))
4362 4363
                      arg0.spec))
4363 4364
                 :: fields
4364 4365
                in
......
4372 4373
                 :: fields
4373 4374
                in
4374 4375
             let fields =
4375
               if arg0.name = NoName
4376
               if arg0.name = ""
4376 4377
               then fields
4377 4378
               else
4378
                 ("name", (((fun x  -> vhdl_name_t_to_yojson x)) arg0.name))
4379
                 ("name",
4380
                   (((fun (x : Ppx_deriving_runtime.string)  -> `String x))
4381
                      arg0.name))
4379 4382
                 :: fields
4380 4383
                in
4381 4384
             `Assoc fields)])
......
4569 4572
                  match xs with
4570 4573
                  | ("name",x)::xs ->
4571 4574
                      loop xs
4572
                        (((fun x  -> vhdl_name_t_of_yojson x) x), arg1, arg2,
4573
                          arg3, arg4)
4575
                        (((function
4576
                           | `String x -> Result.Ok x
4577
                           | _ ->
4578
                               Result.Error
4579
                                 "Vhdl_ast.vhdl_declaration_t.name") x),
4580
                          arg1, arg2, arg3, arg4)
4574 4581
                  | ("kind",x)::xs ->
4575 4582
                      loop xs
4576 4583
                        (arg0,
......
4583 4590
                  | ("spec",x)::xs ->
4584 4591
                      loop xs
4585 4592
                        (arg0, arg1,
4586
                          ((fun x  -> vhdl_subprogram_spec_t_of_yojson x) x),
4593
                          ((function
4594
                            | `Null -> Result.Ok None
4595
                            | x ->
4596
                                ((fun x  ->
4597
                                    vhdl_subprogram_spec_t_of_yojson x) x)
4598
                                  >>= ((fun x  -> Result.Ok (Some x)))) x),
4587 4599
                          arg3, arg4)
4588 4600
                  | ("decl_part",x)::xs ->
4589 4601
                      loop xs
......
4631 4643
                                                     })))))))
4632 4644
                  | _::xs -> loop xs _state  in
4633 4645
                loop xs
4634
                  ((Result.Ok NoName), (Result.Ok ""),
4635
                    (Result.Ok
4636
                       {
4637
                         name = "";
4638
                         typeMark = NoName;
4639
                         parameters = [];
4640
                         isPure = false
4641
                       }), (Result.Ok []), (Result.Ok []))
4646
                  ((Result.Ok ""), (Result.Ok ""), (Result.Ok None),
4647
                    (Result.Ok []), (Result.Ok []))
4642 4648
            | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")) arg0
4643 4649
      | _ -> Result.Error "Vhdl_ast.vhdl_declaration_t")
4644 4650
  [@ocaml.warning "-A"])
......
5861 5867
  name: vhdl_name_t [@default NoName];
5862 5868
  generics: vhdl_port_t list [@default []];
5863 5869
  ports: vhdl_port_t list [@default []];
5864
  declaration: vhdl_declaration_t list
5870
  declaration: vhdl_declarative_item_t list
5865 5871
    [@key "ENTITY_DECLARATIVE_PART"][@default []];
5866 5872
  stmts: vhdl_concurrent_stmt_t list
5867 5873
    [@key "ENTITY_STATEMENT_PART"][@default []]}
......
5870 5876
  Format.formatter -> vhdl_entity_t -> Ppx_deriving_runtime.unit =
5871 5877
  let __4 () = pp_vhdl_concurrent_stmt_t
5872 5878
  
5873
  and __3 () = pp_vhdl_declaration_t
5879
  and __3 () = pp_vhdl_declarative_item_t
5874 5880
  
5875 5881
  and __2 () = pp_vhdl_port_t
5876 5882
  
......
5881 5887
  ((let open! Ppx_deriving_runtime in
5882 5888
      fun fmt  ->
5883 5889
        fun x  ->
5884
          (((((
5885
               ((__0 ()) fmt) x.name;
5886
               Format.fprintf fmt " is@ ");
5887
              Format.fprintf fmt "@[<v>";
5890
          ((__0 ()) fmt) x.name;
5891
          Format.fprintf fmt " is@;";
5892
          (match x.generics with
5893
          | [] -> Format.fprintf fmt "";
5894
          | _ -> 
5895
              Format.fprintf fmt "generic (@[<v>";
5896
              ((fun x  ->
5897
                ignore
5898
                (List.fold_left
5899
                  (fun sep  ->
5900
                    fun x  ->
5901
                      if sep then Format.fprintf fmt ";@;";
5902
                        ((__1 ()) fmt) x;
5903
                        true) false x))) x.generics;
5904
              Format.fprintf fmt "@]);");
5905
          (match x.ports with
5906
          | [] -> Format.fprintf fmt "";
5907
          | _ -> 
5908
              Format.fprintf fmt "port (@[<v>";
5888 5909
              ((fun x  ->
5889
                  ignore
5890
                    (List.fold_left
5891
                       (fun sep  ->
5892
                          fun x  ->
5893
                            if sep then Format.fprintf fmt ";@;";
5894
                            ((__1 ()) fmt) x;
5895
                            true) false x))) x.generics;
5896
              Format.fprintf fmt "@]");
5897
             Format.fprintf fmt "port (@[<v>";
5898
             ((fun x  ->
5899 5910
                 ignore
5900 5911
                   (List.fold_left
5901 5912
                      (fun sep  ->
......
5903 5914
                           if sep then Format.fprintf fmt ";@;";
5904 5915
                           ((__2 ()) fmt) x;
5905 5916
                           true) false x))) x.ports;
5906
             Format.fprintf fmt "@]);");
5907
            Format.fprintf fmt "@[<v>";
5908
            ((fun x  ->
5909
                Format.fprintf fmt "@[";
5917
              Format.fprintf fmt "@]);");
5918
          (match x.declaration with
5919
          | [] -> Format.fprintf fmt "";
5920
          | _ ->
5921
              Format.fprintf fmt "@;";
5922
              ((fun x  ->
5910 5923
                ignore
5911 5924
                  (List.fold_left
5912 5925
                     (fun sep  ->
5913 5926
                        fun x  ->
5914
                          if sep then Format.fprintf fmt ";@ ";
5927
                          if sep then Format.fprintf fmt ";@;";
5915 5928
                          ((__3 ()) fmt) x;
5916
                          true) false x);
5917
                Format.fprintf fmt "@]")) x.declaration;
5918
            Format.fprintf fmt "@]");
5919
           Format.fprintf fmt "@[<v>";
5920
           ((fun x  ->
5921
               Format.fprintf fmt "@[";
5922
               ignore
5923
                 (List.fold_left
5929
                          true) false x))) x.declaration;
5930
              Format.fprintf fmt ";");
5931
          (match x.stmts with
5932
          | [] -> Format.fprintf fmt "";
5933
          | _ ->
5934
              Format.fprintf fmt "@;@[<v 2>begin@;";
5935
              ((fun x  ->
5936
                ignore
5937
                  (List.fold_left
5924 5938
                    (fun sep  ->
5925 5939
                       fun x  ->
5926
                         if sep then Format.fprintf fmt ";@ ";
5940
                         if sep then Format.fprintf fmt ";@;";
5927 5941
                         ((__4 ()) fmt) x;
5928
                         true) false x);
5929
               Format.fprintf fmt "@]")) x.stmts;
5930
           Format.fprintf fmt "@]");
5931
          Format.fprintf fmt "@]")
5942
                         true) false x))) x.stmts;
5943
              Format.fprintf fmt ";@]");)
5932 5944
    [@ocaml.warning "-A"])
5933 5945

  
5934 5946
and show_vhdl_entity_t : vhdl_entity_t -> Ppx_deriving_runtime.string =
......
5956 5968
            ("ENTITY_DECLARATIVE_PART",
5957 5969
              (((fun x  ->
5958 5970
                   `List
5959
                     (List.map (fun x  -> vhdl_declaration_t_to_yojson x) x)))
5971
                     (List.map
5972
                        (fun x  -> vhdl_declarative_item_t_to_yojson x) x)))
5960 5973
                 x.declaration))
5961 5974
            :: fields
5962 5975
           in
......
6022 6035
                  (arg0, arg1, arg2,
6023 6036
                    ((function
6024 6037
                      | `List xs ->
6025
                          map_bind (fun x  -> vhdl_declaration_t_of_yojson x)
6038
                          map_bind
6039
                            (fun x  -> vhdl_declarative_item_t_of_yojson x)
6026 6040
                            [] xs
6027 6041
                      | _ ->
6028 6042
                          Result.Error "Vhdl_ast.vhdl_entity_t.declaration")
src/backends/VHDL/vhdl_ast_map.ml
375 375
            let ports = self#list self#vhdl_port_t ports  in
376 376
            ComponentDecl { name; generics; ports }
377 377
        | Subprogram { name; kind; spec; decl_part; stmts } ->
378
            let name = self#vhdl_name_t name  in
378
            let name = self#string name  in
379 379
            let kind = self#string kind  in
380
            let spec = self#vhdl_subprogram_spec_t spec  in
380
            let spec = self#option self#vhdl_subprogram_spec_t spec  in
381 381
            let decl_part = self#list self#vhdl_declaration_t decl_part  in
382 382
            let stmts = self#list self#vhdl_sequential_stmt_t stmts  in
383 383
            Subprogram { name; kind; spec; decl_part; stmts }
......
465 465
        let name = self#vhdl_name_t name  in
466 466
        let generics = self#list self#vhdl_port_t generics  in
467 467
        let ports = self#list self#vhdl_port_t ports  in
468
        let declaration = self#list self#vhdl_declaration_t declaration  in
468
        let declaration = self#list self#vhdl_declarative_item_t declaration
469
           in
469 470
        let stmts = self#list self#vhdl_concurrent_stmt_t stmts  in
470 471
        { name; generics; ports; declaration; stmts }
471 472

  
src/tools/importer/vhdl_to_lustre.ml
377 377
            let ports = self#list self#vhdl_port_t ports  in
378 378
            ComponentDecl { name; generics; ports }
379 379
        | Subprogram { name; kind; spec; decl_part; stmts } ->
380
            let name = self#vhdl_name_t name  in
380
            let name = self#string name  in
381 381
            let kind = self#string kind  in
382
            let spec = self#vhdl_subprogram_spec_t spec  in
382
            let spec = self#option self#vhdl_subprogram_spec_t spec  in
383 383
            let decl_part = self#list self#vhdl_declaration_t decl_part  in
384 384
            let stmts = self#list self#vhdl_sequential_stmt_t stmts  in
385 385
            Subprogram { name; kind; spec; decl_part; stmts }
......
466 466
        let name = self#vhdl_name_t name  in
467 467
        let generics = self#list self#vhdl_port_t generics  in
468 468
        let ports = self#list self#vhdl_port_t ports  in
469
        let declaration = self#list self#vhdl_declaration_t declaration  in
469
        let declaration = self#list self#vhdl_declarative_item_t declaration
470
           in
470 471
        let stmts = self#list self#vhdl_concurrent_stmt_t stmts  in
471 472
        { name; generics; ports; declaration; stmts }
472 473

  

Also available in: Unified diff