Project

General

Profile

Revision 568b5a26 src/backends/EMF/EMF_common.ml

View differences:

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