Revision f4cba4b8 src/backends/EMF/EMF_backend.ml
src/backends/EMF/EMF_backend.ml | ||
---|---|---|
393 | 393 |
fprintf fmt "\"contract\": \"%s\",@ " |
394 | 394 |
i.import_nodeid; |
395 | 395 |
fprintf fmt "\"inputs\": [%a],@ " |
396 |
pp_emf_exprs i.inputs;
|
|
396 |
pp_emf_expr i.inputs; |
|
397 | 397 |
fprintf fmt "\"outputs\": [%a],@ " |
398 |
pp_emf_exprs i.outputs;
|
|
398 |
pp_emf_expr i.outputs; |
|
399 | 399 |
fprintf fmt "@]}" |
400 | 400 |
|
401 | 401 |
let pp_emf_spec_imports = pp_emf_list pp_emf_spec_import |
... | ... | |
421 | 421 |
let pp_emf_annots cpt fmt annots = fprintf_list ~sep:",@ " (pp_emf_annot cpt) fmt annots.annots |
422 | 422 |
let pp_emf_annots_list cpt fmt annots_list = fprintf_list ~sep:",@ " (pp_emf_annots cpt) fmt annots_list |
423 | 423 |
|
424 |
let pp_emf_contract fmt nd = |
|
425 |
let c = Printers.node_as_contract nd in |
|
426 |
fprintf fmt "@[v 2>\"%a\": {@ " |
|
427 |
print_protect (fun fmt -> pp_print_string fmt nd.node_id); |
|
428 |
fprintf fmt "\"contract\": %a@ " |
|
429 |
pp_emf_spec c; |
|
430 |
fprintf fmt "@]@ }" |
|
424 | 431 |
|
425 |
|
|
426 | 432 |
let pp_machine fmt m = |
427 | 433 |
let instrs = (*merge_branches*) m.mstep.step_instrs in |
428 | 434 |
try |
... | ... | |
445 | 451 |
fprintf fmt "\"original_name\": \"%s\",@ " m.mname.node_id; |
446 | 452 |
fprintf fmt "\"instrs\": {@[<v 0> %a@]@ },@ " |
447 | 453 |
(pp_emf_instrs m) instrs; |
448 |
(match m.mspec with None -> () | Some spec -> fprintf fmt "\"spec\": %a,@ " pp_emf_spec spec); |
|
454 |
(match m.mspec with | None -> () |
|
455 |
| Some (Contract _) -> assert false |
|
456 |
| Some (NodeSpec id) -> fprintf fmt "\"coco_contract\": %s" id |
|
457 |
); |
|
449 | 458 |
fprintf fmt "\"annots\": {@[<v 0> %a@]@ }" (pp_emf_annots_list (ref 0)) m.mannot; |
450 | 459 |
fprintf fmt "@]@ }" |
451 | 460 |
with Unhandled msg -> ( |
... | ... | |
455 | 464 |
eprintf "node skipped - no output generated@ @]@." |
456 | 465 |
) |
457 | 466 |
|
467 |
let pp_machine fmt m = |
|
468 |
match m.mspec with |
|
469 |
| None | Some (NodeSpec _) -> pp_machine fmt m |
|
470 |
| Some (Contract _) -> pp_emf_contract fmt m.mname |
|
471 |
|
|
458 | 472 |
let pp_emf_imported_node fmt top = |
459 | 473 |
let ind = Corelang.imported_node_of_top top in |
460 |
try
|
|
474 |
try |
|
461 | 475 |
fprintf fmt "@[<v 2>\"%a\": {@ " |
462 | 476 |
print_protect (fun fmt -> pp_print_string fmt ind.nodei_id); |
463 | 477 |
fprintf fmt "\"imported\": \"true\",@ "; |
... | ... | |
466 | 480 |
fprintf fmt "\"outputs\": [%a],@ " |
467 | 481 |
pp_emf_vars_decl ind.nodei_outputs; |
468 | 482 |
fprintf fmt "\"original_name\": \"%s\",@ " ind.nodei_id; |
469 |
(match ind.nodei_spec with None -> () | Some spec -> fprintf fmt "\"spec\": %a" pp_emf_spec spec); |
|
483 |
(match ind.nodei_spec with None -> () |
|
484 |
| Some (Contract _) -> assert false (* should have been processed *) |
|
485 |
| Some (NodeSpec id) -> fprintf fmt "\"coco_contract\": %s" id |
|
486 |
); |
|
470 | 487 |
fprintf fmt "@]@ }" |
471 | 488 |
with Unhandled msg -> ( |
472 | 489 |
eprintf "[Error] @[<v 0>EMF backend@ Issues while translating node %s@ " |
Also available in: Unified diff