Project

General

Profile

Download (2.04 KB) Statistics
| Branch: | Tag: | Revision:
1
(********************************************************************)
2
(*                                                                  *)
3
(*  The LustreC compiler toolset   /  The LustreC Development Team  *)
4
(*  Copyright 2012 -    --   ONERA - CNRS - INPT - ISAE-SUPAERO     *)
5
(*                                                                  *)
6
(*  LustreC is free software, distributed WITHOUT ANY WARRANTY      *)
7
(*  under the terms of the GNU Lesser General Public License        *)
8
(*  version 2.1.                                                    *)
9
(*                                                                  *)
10
(********************************************************************)
11

    
12
open Format
13
open Machine_code_types
14

    
15
let gen_ada destname print suffix machine =
16
  (* Next line permit to get the final package name mostly to clean the
17
    identifier for Ada *)
18
  let name = asprintf "%a" Ada_backend_common.pp_package_name machine.mname in
19
  let name = String.lowercase_ascii name in
20
  let path = destname ^ name ^ suffix in
21
  let out = open_out path in
22
  let fmt = formatter_of_out_channel out in
23
  print fmt machine;
24
  close_out out;
25
  Log.report ~level:2 (fun fmt -> fprintf fmt "    .. %s generated @." path)
26

    
27
exception CheckFailed of string
28

    
29
let check machine =
30
  match machine.mconst with
31
    | [] -> ()
32
    | _ -> raise (CheckFailed "machine.mconst should be void")
33

    
34
let translate_to_ada basename prog machines dependencies =
35
  let module Ads = Ada_backend_ads.Main in
36
  let module Adb = Ada_backend_adb.Main in
37
  let module Wrapper = Ada_backend_wrapper.Main in
38

    
39
  let destname = !Options.dest_dir ^ "/" in
40

    
41
  Log.report ~level:2 (fun fmt -> fprintf fmt "  .. Checking machines@.");
42

    
43
  List.iter check machines;
44

    
45
  Log.report ~level:2 (fun fmt -> fprintf fmt "  .. Generating ads@.");
46

    
47
  List.iter (gen_ada destname Ads.print ".ads") machines;
48

    
49
  Log.report ~level:2 (fun fmt -> fprintf fmt "  .. Generating adb@.");
50

    
51
  List.iter (gen_ada destname Adb.print ".adb") machines
52

    
53
(* Local Variables: *)
54
(* compile-command:"make -C ../../.." *)
55
(* End: *)
(2-2/6)