Project

General

Profile

« Previous | Next » 

Revision a7062da6

Added by LĂ©lio Brun over 3 years ago

another step towards refactoring

View differences:

src/backends/EMF/EMF_common.ml
1
open Utils
1 2
open Lustre_types
3
open Corelang
2 4
open Machine_code_types
3
module VSet = Corelang.VSet
4 5
open Format
5 6
open Machine_code_common
6 7

  
......
92 93
    fprintf fmt "\"kind\": \"ident\",@ \"value\": \"%s\"" s
93 94
  | Dappl (f, args) ->
94 95
    fprintf fmt "\"kind\": \"fun\",@ \"id\": \"%s\",@ \"args\": [@[%a@]]" f
95
      (Utils.fprintf_list ~sep:",@ " pp_emf_dim)
96
      args
96
      (pp_comma_list pp_emf_dim) args
97 97
  | Dite (i, t, e) ->
98 98
    fprintf fmt
99 99
      "\"kind\": \"ite\",@ \"guard\": \"%a\",@ \"then\": %a,@ \"else\": %a"
......
137 137
     prefix of the lustre file. They shall not be associated to variables *)
138 138
  | Tydec_array (dim, e) ->
139 139
    let inf_base =
140
      match infered_t.Typing.tdesc with
141
      | Typing.Tarray (_, t) ->
140
      match infered_t.Types.tdesc with
141
      | Types.Tarray (_, t) ->
142 142
        t
143 143
      | _ ->
144 144
        (* returing something useless, hoping that the concrete datatype will
145 145
           return something usefull *)
146
        Typing.new_var ()
146
        Types.new_var ()
147 147
    in
148 148
    fprintf fmt "{ \"kind\": \"array\", \"base_type\": %t, \"dim\": %a }"
149 149
      (pp_concrete_type e inf_base)
......
232 232
    ()
233 233
  | _ ->
234 234
    fprintf fmt "@[";
235
    Utils.fprintf_list ~sep:",@ " pp fmt l;
235
    pp_comma_list pp fmt l;
236 236
    fprintf fmt "@]%(%)" eol
237 237

  
238 238
(* Print the variable declaration *)
......
330 330
    assert false
331 331

  
332 332
and pp_emf_cst_or_var_list m =
333
  Utils.fprintf_list ~sep:",@ " (pp_emf_cst_or_var m)
333
  pp_comma_list (pp_emf_cst_or_var m)
334 334

  
335 335
(* Printer lustre expr and eexpr *)
336 336

  
......
349 349
    fprintf fmt "@]}"
350 350
  | Expr_tuple el ->
351 351
    fprintf fmt "[@[<hov 0>%a@ @]]"
352
      (Utils.fprintf_list ~sep:",@ " pp_emf_expr)
352
      (pp_comma_list pp_emf_expr)
353 353
      el
354 354
  (* Missing these | Expr_ite of expr * expr * expr | Expr_arrow of expr * expr
355 355
     | Expr_fby of expr * expr | Expr_array of expr list | Expr_access of expr *
......
394 394
        ()
395 395
      | Some name ->
396 396
        Format.fprintf fmt "\"name\": \"%s\",@ " name)
397
    (Utils.fprintf_list ~sep:"; " Printers.pp_quantifiers)
397
    (pp_print_list ~pp_sep:pp_print_semicolon Printers.pp_quantifiers)
398 398
    ee.eexpr_quantifiers pp_emf_expr ee.eexpr_qfexpr
399 399

  
400 400
let pp_emf_eexprs = pp_emf_list pp_emf_eexpr
......
411 411
    assert false
412 412
  | Eq eq ->
413 413
    fprintf fmt "@[ @[<v 2>\"%a\": {@ "
414
      (Utils.fprintf_list ~sep:"_" pp_print_string)
414
      (pp_print_list ~pp_sep:(fun fmt () -> pp_print_string fmt "_") pp_print_string)
415 415
      eq.eq_lhs;
416 416
    fprintf fmt "\"lhs\": [%a],@ "
417
      (Utils.fprintf_list ~sep:", " (fun fmt vid -> fprintf fmt "\"%s\"" vid))
417
      (pp_comma_list (fun fmt vid -> fprintf fmt "\"%s\"" vid))
418 418
      eq.eq_lhs;
419 419
    fprintf fmt "\"rhs\": %a,@ " pp_emf_expr eq.eq_rhs;
420 420
    fprintf fmt "@]@]@ }"
......
439 439
    fprintf fmt "\"kind\": \"alias\",@ \"value\": \"%s\"" c
440 440
  | Tydec_enum el ->
441 441
    fprintf fmt "\"kind\": \"enum\",@ \"elements\": [%a]"
442
      (Utils.fprintf_list ~sep:", " (fun fmt e -> fprintf fmt "\"%s\"" e))
443
      el
442
      (pp_comma_list (fun fmt e -> fprintf fmt "\"%s\"" e)) el
444 443
  | Tydec_struct s ->
445 444
    fprintf fmt "\"kind\": \"struct\",@ \"fields\": [%a]"
446
      (Utils.fprintf_list ~sep:", " (fun fmt (id, typ) ->
445
      (pp_comma_list (fun fmt (id, typ) ->
447 446
           fprintf fmt "\"%s\": %a" id pp_emf_typ_dec typ))
448 447
      s
449 448
  | Tydec_array (dim, typ) ->

Also available in: Unified diff