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
|
|
14
|
open Machine_code_types
|
15
|
open Lustre_types
|
16
|
open Corelang
|
17
|
open Machine_code_common
|
18
|
|
19
|
open Ada_backend_common
|
20
|
|
21
|
module Main =
|
22
|
struct
|
23
|
|
24
|
let pp_machine_instr machine fmt instr =
|
25
|
fprintf fmt "instruction"
|
26
|
|
27
|
|
28
|
(** Keep only the MReset from an instruction list.
|
29
|
@param list to filter
|
30
|
**)
|
31
|
let filter_reset instr_list = List.map
|
32
|
(fun i -> match get_instr_desc i with MReset i -> i | _ -> assert false)
|
33
|
instr_list
|
34
|
|
35
|
(** Print the definition of a procedure
|
36
|
@param fmt the formater to print on
|
37
|
@param m the machine
|
38
|
@param pp_procedure_name the procedure name printer
|
39
|
@param pp_prototype the prototype printer
|
40
|
@param instrs the instructions of the procedure
|
41
|
**)
|
42
|
let pp_procedure_definition fmt (m, pp_procedure_name, pp_prototype, instrs) =
|
43
|
let pp_instr = pp_machine_instr m in
|
44
|
fprintf fmt "%a is@,begin@, @[<v>%a%t@]@,end %t"
|
45
|
pp_prototype m
|
46
|
(Utils.fprintf_list ~sep:";@," pp_instr) instrs
|
47
|
(Utils.pp_final_char_if_non_empty ";" instrs)
|
48
|
pp_procedure_name
|
49
|
|
50
|
(** Print the definition of the init procedure from a machine.
|
51
|
@param fmt the formater to print on
|
52
|
@param machine the machine
|
53
|
**)
|
54
|
let pp_init_definition fmt m =
|
55
|
pp_procedure_definition fmt
|
56
|
(m, pp_init_procedure_name, pp_init_prototype, m.minit)
|
57
|
|
58
|
(** Print the definition of the step procedure from a machine.
|
59
|
@param fmt the formater to print on
|
60
|
@param machine the machine
|
61
|
**)
|
62
|
let pp_step_definition fmt m =
|
63
|
pp_procedure_definition fmt
|
64
|
(m, pp_step_procedure_name, pp_step_prototype, m.minit)
|
65
|
|
66
|
(** Print the definition of the reset procedure from a machine.
|
67
|
@param fmt the formater to print on
|
68
|
@param machine the machine
|
69
|
**)
|
70
|
let pp_reset_definition fmt m =
|
71
|
pp_procedure_definition fmt
|
72
|
(m, pp_reset_procedure_name, pp_reset_prototype, filter_reset m.minit)
|
73
|
|
74
|
(** Print the definition of the clear procedure from a machine.
|
75
|
@param fmt the formater to print on
|
76
|
@param machine the machine
|
77
|
**)
|
78
|
let pp_clear_definition fmt m =
|
79
|
pp_procedure_definition fmt
|
80
|
(m, pp_clear_procedure_name, pp_clear_prototype, filter_reset m.minit)
|
81
|
|
82
|
(** Print the package definition(adb) of a machine.
|
83
|
@param fmt the formater to print on
|
84
|
@param machine the machine
|
85
|
**)
|
86
|
let print fmt machine =
|
87
|
fprintf fmt "%a@, @[<v>@,%a;@,@,%a;@,@,%a;@,@,%a;@,@]@,%a;@."
|
88
|
(pp_begin_package true) machine (*Begin the package*)
|
89
|
pp_init_definition machine (*Define the init procedure*)
|
90
|
pp_step_definition machine (*Define the step procedure*)
|
91
|
pp_reset_definition machine (*Define the reset procedure*)
|
92
|
pp_clear_definition machine (*Define the clear procedure*)
|
93
|
pp_end_package machine (*End the package*)
|
94
|
|
95
|
end
|