Project

General

Profile

Revision 3d85297f

View differences:

src/backends/Ada/ada_backend_adb.ml
24 24
let pp_machine_instr machine fmt instr =
25 25
    fprintf fmt "instruction"
26 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@]@,end %t"
45
    pp_prototype m
46
    (Utils.fprintf_list ~sep:";@," pp_instr) instrs
47
    pp_procedure_name
48

  
49
(** Print the definition of the init procedure from a machine.
50
   @param fmt the formater to print on
51
   @param machine the machine
52
**)
53
let pp_init_definition fmt m =
54
  pp_procedure_definition fmt
55
    (m, pp_init_procedure_name, pp_init_prototype, m.minit)
56

  
57
(** Print the definition of the step procedure from a machine.
58
   @param fmt the formater to print on
59
   @param machine the machine
60
**)
61
let pp_step_definition fmt m =
62
  pp_procedure_definition fmt
63
    (m, pp_step_procedure_name, pp_step_prototype, m.minit)
64

  
65
(** Print the definition of the reset procedure from a machine.
66
   @param fmt the formater to print on
67
   @param machine the machine
68
**)
69
let pp_reset_definition fmt m =
70
  pp_procedure_definition fmt
71
    (m, pp_reset_procedure_name, pp_reset_prototype, filter_reset m.minit)
72

  
73
(** Print the definition of the clear procedure from a machine.
74
   @param fmt the formater to print on
75
   @param machine the machine
76
**)
77
let pp_clear_definition fmt m =
78
  pp_procedure_definition fmt
79
    (m, pp_clear_procedure_name, pp_clear_prototype, filter_reset m.minit)
80

  
81
(** Print the package definition(adb) of a machine.
82
   @param fmt the formater to print on
83
   @param machine the machine
84
*)
27 85
let print fmt machine =
28
  let pp_instr = pp_machine_instr machine in
29
  fprintf fmt "@[<v 2>%a@,%a@]@,%a@."
30
    (pp_begin_package true) machine
31
    (Utils.fprintf_list ~sep:"@," pp_instr) machine.mstep.step_instrs
32
    pp_end_package machine
86
  fprintf fmt "%a@,  @[<v>@,%a;@,@,%a;@,@,%a;@,@,%a;@,@]@,%a;@."
87
    (pp_begin_package true) machine (*Begin the package*)
88
    pp_init_definition machine (*Define the init procedure*)
89
    pp_step_definition machine (*Define the step procedure*)
90
    pp_reset_definition machine (*Define the reset procedure*)
91
    pp_clear_definition machine (*Define the clear procedure*)
92
    pp_end_package machine  (*End the package*)
33 93

  
34 94
end
src/backends/Ada/ada_backend_ads.ml
22 22
module Main =
23 23
struct
24 24

  
25
(** Print the package declaration(ads) of a lustre node.
25
(** Print the package declaration(ads) of a machine.
26 26
   @param fmt the formater to print on
27 27
   @param machine the machine
28 28
*)
29 29
let print fmt machine =
30 30
  let pp_record fmt = pp_record_definition fmt machine.mmemory in
31
  fprintf fmt "@[<v 2>%a;@,@,%a;@,@,%a;@,@,%a;@,@,%a;@,@,%a;@,@,private@,@,%a;@,@]@,%a@."
31
  fprintf fmt "%a@,  @[<v>@,%a;@,@,%a;@,@,%a;@,@,%a;@,@,%a;@,@,private@,@,%a;@,@]@,%a;@."
32 32
    (pp_begin_package false) machine (*Begin the package*)
33 33
    pp_private_type_decl pp_state_type (*Declare the state type*)
34 34
    pp_init_prototype machine (*Declare the init procedure*)
......
37 37
    pp_clear_prototype machine (*Declare the clear procedure*)
38 38
    pp_type_decl (pp_state_type, pp_record) (*Define the state type*)
39 39
    pp_end_package machine  (*End the package*)
40
    (*(Utils.fprintf_list ~sep:"@," pp_var_decl) machine.mmemory*)
41 40

  
42 41
end
src/backends/Ada/ada_backend_common.ml
32 32
   @param machine the machine
33 33
*)
34 34
let pp_end_package fmt machine =
35
  fprintf fmt "end %a;" pp_package_name machine
35
  fprintf fmt "end %a" pp_package_name machine
36 36

  
37 37

  
38 38
(* Type pretty print functions *)
......
145 145

  
146 146
(* Prototype pretty print functions *)
147 147

  
148
(** Print the name of the init procedure **)
149
let pp_init_procedure_name fmt = fprintf fmt "init"
150

  
151
(** Print the step of the init procedure **)
152
let pp_step_procedure_name fmt = fprintf fmt "step"
153

  
154
(** Print the reset of the init procedure **)
155
let pp_reset_procedure_name fmt = fprintf fmt "reset"
156

  
157
(** Print the clear of the init procedure **)
158
let pp_clear_procedure_name fmt = fprintf fmt "clear"
159

  
148 160
(** Print the prototype of a machine procedure. The first parameter is always
149 161
the state, state_modifier specify the modifier applying to it. The next
150 162
parameters are inputs and the last parameters are the outputs.
......
154 166
   @param input list of the input parameter of the procedure
155 167
   @param output list of the output parameter of the procedure
156 168
*)
157
let pp_simple_prototype fmt (name, state_mode, input, output) =
158
  fprintf fmt "procedure %s(@[<v>%a%t@[%a@]%t@[%a@])@]"
159
    name
169
let pp_simple_prototype fmt (pp_name, state_mode, input, output) =
170
  fprintf fmt "procedure %t(@[<v>%a%t@[%a@]%t@[%a@])@]"
171
    pp_name
160 172
    pp_state_var_decl state_mode
161 173
    (Utils.pp_final_char_if_non_empty ",@," input)
162 174
    (Utils.fprintf_list ~sep:",@ " (pp_machine_var_decl In)) input
......
168 180
   @param m the machine
169 181
*)
170 182
let pp_init_prototype fmt m =
171
  pp_simple_prototype fmt ("init", Out, m.mstatic, [])
183
  pp_simple_prototype fmt (pp_init_procedure_name, Out, m.mstatic, [])
172 184

  
173 185
(** Print the prototype of the step procedure of a machine.
174 186
   @param fmt the formater to print on
175 187
   @param m the machine
176 188
*)
177 189
let pp_step_prototype fmt m =
178
  pp_simple_prototype fmt ("step", InOut, m.mstep.step_inputs, m.mstep.step_outputs)
190
  pp_simple_prototype fmt (pp_step_procedure_name, InOut, m.mstep.step_inputs, m.mstep.step_outputs)
179 191

  
180 192
(** Print the prototype of the reset procedure of a machine.
181 193
   @param fmt the formater to print on
182 194
   @param m the machine
183 195
*)
184 196
let pp_reset_prototype fmt m =
185
  pp_simple_prototype fmt ("reset", InOut, m.mstatic, [])
197
  pp_simple_prototype fmt (pp_reset_procedure_name, InOut, m.mstatic, [])
186 198

  
187 199
(** Print the prototype of the clear procedure of a machine.
188 200
   @param fmt the formater to print on
189 201
   @param m the machine
190 202
*)
191 203
let pp_clear_prototype fmt m =
192
  pp_simple_prototype fmt ("clear", InOut, m.mstatic, [])
204
  pp_simple_prototype fmt (pp_clear_procedure_name, InOut, m.mstatic, [])

Also available in: Unified diff