Project

General

Profile

« Previous | Next » 

Revision c419ca44

Added by Guillaume DAVY almost 3 years ago

Ada: Changed type name for states and normalized variable name to match ada requirements.

View differences:

src/backends/Ada/ada_backend_common.ml
57 57
   @param fmt the formater to print on
58 58
*)
59 59
let pp_state_type fmt =
60
  fprintf fmt "State"
60
  fprintf fmt "TState"
61 61

  
62 62
(** Print the type of a variable.
63 63
   @param fmt the formater to print on
......
99 99
   @param id the variable
100 100
*)
101 101
let pp_var_name fmt id =
102
  fprintf fmt "%s" id.var_id
102
  let base_size = String.length id.var_id in
103
  assert(base_size > 0);
104
  let rec remove_double_underscore s = function
105
    | i when i == String.length s - 1 -> s
106
    | i when String.get s i == '_' && String.get s (i+1) == '_' ->
107
        remove_double_underscore (sprintf "%s%s" (String.sub s 0 i) (String.sub s (i+1) (String.length s-i-1))) i
108
    | i -> remove_double_underscore s (i+1)
109
  in
110
  let name = remove_double_underscore id.var_id 0 in
111
  let prefix = if String.length name == base_size
112
                  || String.get id.var_id 0 == '_' then
113
                  "ada"
114
               else
115
                  ""
116
  in
117
  fprintf fmt "%s%s" prefix name
103 118

  
104 119
(** Print a variable declaration
105 120
   @param mode input/output mode of the parameter
......
133 148
  let pp_type = pp_state_type in
134 149
  pp_var_decl fmt (mode, pp_name, pp_type)
135 150

  
136
(** Print a record definition.
137
   @param fmt the formater to print on
138
   @param var_list list of machine variable
139
*)
140
let pp_record_definition fmt var_list =
141
  fprintf fmt "@,  @[<v>record@,  @[<v>%a%t@]@,end record@]"
142
    (Utils.fprintf_list ~sep:";@;" (pp_machine_var_decl NoMode)) var_list
143
    (Utils.pp_final_char_if_non_empty "," var_list)
144

  
145 151

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

  
......
170 176
  fprintf fmt "procedure %t(@[<v>%a%t@[%a@]%t@[%a@])@]"
171 177
    pp_name
172 178
    pp_state_var_decl state_mode
173
    (Utils.pp_final_char_if_non_empty ",@," input)
174
    (Utils.fprintf_list ~sep:",@ " (pp_machine_var_decl In)) input
175
    (Utils.pp_final_char_if_non_empty ",@," output)
176
    (Utils.fprintf_list ~sep:",@ " (pp_machine_var_decl Out)) output
179
    (Utils.pp_final_char_if_non_empty ";@," input)
180
    (Utils.fprintf_list ~sep:";@ " (pp_machine_var_decl In)) input
181
    (Utils.pp_final_char_if_non_empty ";@," output)
182
    (Utils.fprintf_list ~sep:";@ " (pp_machine_var_decl Out)) output
177 183

  
178 184
(** Print the prototype of the init procedure of a machine.
179 185
   @param fmt the formater to print on

Also available in: Unified diff