Project

General

Profile

Download (1.24 KB) Statistics
| Branch: | Tag: | Revision:
1
(** 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
    moment, modular compilation of multiple lustre sources as one output JSON is
4
    not considered. *)
5

    
6
open Utils
7
open Lustre_types
8
open Machine_code_types
9
open Format
10
open EMF_common
11

    
12
let pp_call fmt m f outputs inputs =
13
  let decl, _ = List.assoc f m.mcalls in
14
  if Corelang.is_imported_node decl then (
15
    let inode = Corelang.imported_node_of_top decl in
16
    match inode.nodei_id, Filename.basename decl.top_decl_owner with
17
    | name, (("lustrec_math" | "simulink_math_fcn" | "conv") as lib) ->
18
      fprintf fmt
19
        "\"kind\": \"functioncall\",@ \"name\": \"%s\",@ \"library\": \"%s\",@ "
20
        name lib;
21
      fprintf fmt "\"lhs\": [@[%a@]],@ \"args\": [@[%a@]]"
22
        (pp_comma_list (fun fmt v -> fprintf fmt "\"%a\"" Printers.pp_var_name v))
23
        outputs (pp_emf_cst_or_var_list m) inputs
24
    | _ ->
25
      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

    
32
(* Local Variables: *)
33
(* compile-command: "make -C ../.." *)
34
(* End: *)
(6-6/7)