Project

General

Profile

Revision 568b5a26

View differences:

src/backends/EMF/EMF_backend.ml
280 280
	 remove guard's variable from inputs *)
281 281
      (VSet.elements inputs)
282 282
    ;
283
    fprintf fmt "@[<v 2>\"branches\": {@ %a@]}@ "
283
    fprintf fmt "@[<v 2>\"branches\": {@ @[<v 0>%a@]@]@ }"
284 284
      (fprintf_list ~sep:",@ "
285 285
	 (fun fmt (tag, instrs_tag) ->
286 286
	   let branch_all_lhs, _, branch_inputs = branch_block_vars instrs_tag in
......
290 290
	   fprintf fmt "\"inputs\": [%a],@ " pp_emf_vars_decl (VSet.elements branch_inputs); 
291 291
	   fprintf fmt "@[<v 2>\"instrs\": {@ ";
292 292
	   (pp_emf_instrs m) fmt instrs_tag;
293
	   fprintf fmt "@]}@ ";
294
	   fprintf fmt "@]}"
295

  
293
	   fprintf fmt "@]@ }";
294
	   fprintf fmt "@]@ }"
296 295
	 )
297 296
      )
298 297
      hl
......
332 331
  )
333 332
  | _ -> (
334 333
    fprintf fmt "@[ @[<v 2>\"%a\": {@ " get_instr_id i;
335
    fprintf fmt "%a@ " pp_content i;
336
    fprintf fmt "}@]"
334
    fprintf fmt "%a" pp_content i;
335
    fprintf fmt "@]@]@ }"
337 336
  )
338 337
and pp_emf_instrs m fmt instrs = fprintf_list ~sep:",@ " (pp_emf_instr m) fmt instrs
339 338
       
......
384 383
  (* Previous alternative: mapping normalized lustre to EMF: 
385 384
     fprintf_list ~sep:",@ " pp_decl fmt prog; *)
386 385
  fprintf_list ~sep:",@ " pp_machine fmt (List.rev machines);
387
  fprintf fmt "@ @]}";
388
  fprintf fmt "@ @]}"
386
  fprintf fmt "@]@ }";
387
  fprintf fmt "@]@ }"
389 388

  
390 389
(* Local Variables: *)
391 390
(* compile-command: "make -C ../.." *)
src/backends/EMF/EMF_common.ml
34 34
    
35 35
(* Basic printing functions *)
36 36

  
37
let hash_map = Hashtbl.create 13
38
  
37 39
(* If string length of f is longer than 50 chars, we select the 10 first and
38 40
   last and put a hash in the middle *)
39 41
let print_protect fmt f =
......
41 43
  let s = flush_str_formatter () in
42 44
  let l = String.length s in
43 45
  if l > 30 then
44
    let prefix = String.sub s 0 10 and
45
	suffix = String.sub s (l-10) 10 in
46
    let hash = Hashtbl.hash s in
47
    fprintf fmt "%s_%i_%s" prefix hash suffix
46
    let _ = Format.eprintf "Looking for variable %s in hash @[<v 0>%t@]@."
47
      s
48
      (fun fmt -> Hashtbl.iter (fun s new_s -> fprintf fmt "%s -> %s@ " s new_s) hash_map)
49
    in
50
    if Hashtbl.mem hash_map s then
51
    fprintf fmt "%s" (Hashtbl.find hash_map s)
52
    else
53
      let prefix = String.sub s 0 10 and
54
	  suffix = String.sub s (l-10) 10 in
55
      let hash = Hashtbl.hash s in
56
      fprintf str_formatter "%s_%i_%s" prefix hash suffix;
57
      let new_s = flush_str_formatter () in
58
      Hashtbl.add hash_map s new_s;
59
      fprintf fmt "%s" new_s
48 60
  else
49 61
    fprintf fmt "%s" s
50 62
    
51
let pp_var_string fmt v = print_protect fmt (fun fmt -> fprintf fmt "\"%s\"" v) 
63
let pp_var_string fmt v = print_protect fmt (fun fmt -> fprintf fmt "%s" v) 
52 64
let pp_var_name fmt v = print_protect fmt (fun fmt -> Printers.pp_var_name fmt v) 
53 65
(*let pp_node_args = fprintf_list ~sep:", " pp_var_name*)
54 66

  

Also available in: Unified diff