1 |
2475c9e8
|
ploc
|
(** This function focuses on standard library calls: conversion functions and
|
2 |
|
|
math library. It could be later extended to handle more functions. For the
|
3 |
ca7ff3f7
|
Lélio Brun
|
moment, modular compilation of multiple lustre sources as one output JSON is
|
4 |
|
|
not considered. *)
|
5 |
2475c9e8
|
ploc
|
|
6 |
8446bf03
|
ploc
|
open Lustre_types
|
7 |
089f94be
|
ploc
|
open Machine_code_types
|
8 |
2475c9e8
|
ploc
|
open Format
|
9 |
|
|
open EMF_common
|
10 |
|
|
|
11 |
|
|
let pp_call fmt m f outputs inputs =
|
12 |
ca7ff3f7
|
Lélio Brun
|
let decl, _ = List.assoc f m.mcalls in
|
13 |
|
|
if Corelang.is_imported_node decl then (
|
14 |
2475c9e8
|
ploc
|
let inode = Corelang.imported_node_of_top decl in
|
15 |
|
|
match inode.nodei_id, Filename.basename decl.top_decl_owner with
|
16 |
ca7ff3f7
|
Lélio Brun
|
| name, (("lustrec_math" | "simulink_math_fcn" | "conv") as lib) ->
|
17 |
|
|
fprintf fmt
|
18 |
|
|
"\"kind\": \"functioncall\",@ \"name\": \"%s\",@ \"library\": \"%s\",@ "
|
19 |
2475c9e8
|
ploc
|
name lib;
|
20 |
|
|
fprintf fmt "\"lhs\": [@[%a@]],@ \"args\": [@[%a@]]"
|
21 |
ca7ff3f7
|
Lélio Brun
|
(Utils.fprintf_list ~sep:",@ " (fun fmt v ->
|
22 |
|
|
fprintf fmt "\"%a\"" Printers.pp_var_name v))
|
23 |
|
|
outputs (pp_emf_cst_or_var_list m) inputs
|
24 |
2475c9e8
|
ploc
|
| _ ->
|
25 |
ca7ff3f7
|
Lélio Brun
|
Format.eprintf "Calls to function %s in library %s are not handled yet.@."
|
26 |
|
|
inode.nodei_id
|
27 |
|
|
(Filename.basename decl.top_decl_owner);
|
28 |
|
|
assert false)
|
29 |
|
|
else assert false
|
30 |
|
|
(* shall not happen *)
|
31 |
2475c9e8
|
ploc
|
|
32 |
ca7ff3f7
|
Lélio Brun
|
(* Local Variables: *)
|
33 |
|
|
(* compile-command: "make -C ../.." *)
|
34 |
|
|
(* End: *)
|