Project

General

Profile

« Previous | Next » 

Revision 785b64f9

Added by Pierre-Loïc Garoche about 6 years ago

[EMF] Protecting print of names to ensure a length < 50. Remove the middle part of the string and inject a hash of it.

View differences:

src/backends/EMF/EMF_backend.ml
146 146
let branch_cpt = ref 0
147 147
let get_instr_id fmt i =
148 148
  match Corelang.get_instr_desc i with
149
  | MLocalAssign(lhs,_) | MStateAssign (lhs, _) -> Printers.pp_var_name fmt lhs
149
  | MLocalAssign(lhs,_) | MStateAssign (lhs, _) -> pp_var_name fmt lhs
150 150
  | MReset i | MNoReset i -> fprintf fmt "%s" (reset_name i)
151 151
  | MBranch (g, _) -> incr branch_cpt; fprintf fmt "branch_%i" !branch_cpt
152
  | MStep (outs, id, _) -> fprintf fmt "%a_%s" (fprintf_list ~sep:"_" Printers.pp_var_name) outs id
152
  | MStep (outs, id, _) ->
153
     print_protect fmt 
154
       (fun fmt -> fprintf fmt "%a_%s" (fprintf_list ~sep:"_" pp_var_name) outs id)
153 155
  | _ -> () (* No name *)
154 156

  
155 157
let rec branch_block_vars il =
......
299 301
  | MStep ([var], f, _) when is_arrow_fun m i -> (* Arrow case *) (
300 302
    fprintf fmt "\"kind\": \"arrow\",@ \"name\": \"%s\",@ \"lhs\": \"%a\",@ \"rhs\": \"%s\""
301 303
      f
302
      Printers.pp_var_name var
304
      pp_var_name var
303 305
      (reset_name f)
304 306
  )
305 307

  
306 308
  | MStep (outputs, f, inputs) when not (is_imported_node f m) -> (
307 309
    let node_f = Machine_code.get_node_def f m in
308 310
    let is_stateful = List.mem_assoc f m.minstances in 
309
    fprintf fmt "\"kind\": \"%s\",@ \"name\": \"%s\",@ \"id\": \"%s\",@ "
311
    fprintf fmt "\"kind\": \"%s\",@ \"name\": \"%a\",@ \"id\": \"%s\",@ "
310 312
      (if is_stateful then "statefulcall" else "statelesscall")
311
      (node_f.node_id) 
313
      print_protect (fun fmt -> pp_print_string fmt (node_f.node_id)) 
312 314
      f;
313 315
    fprintf fmt "\"lhs\": [@[%a@]],@ \"args\": [@[%a@]]"
314 316
      (fprintf_list ~sep:",@ " (fun fmt v -> fprintf fmt "\"%a\"" Printers.pp_var_name v)) outputs

Also available in: Unified diff