Project

General

Profile

Revision 1174cdd9

View differences:

src/c_backend.ml
172 172
   - if it's not a scalar output, then its name is enough
173 173
   - otherwise, dereference it (it has been declared as a pointer,
174 174
     despite its scalar Lustre type)
175
   - moreover, cast arrays variables into their original array type.
175
   - moreover, dereference memory array variables.
176 176
*)
177 177
let pp_c_var_read m fmt id =
178 178
  if Types.is_address_type id.var_type
179 179
  then
180
    fprintf fmt "%s" id.var_id
180
    if is_memory m id
181
    then fprintf fmt "(*%s)" id.var_id
182
    else fprintf fmt "%s" id.var_id
181 183
  else
182
    if List.exists (fun o -> o.var_id = id.var_id) m.mstep.step_outputs (* id is output *)
184
    if is_output m id
183 185
    then fprintf fmt "*%s" id.var_id
184 186
    else fprintf fmt "%s" id.var_id
185 187

  
......
193 195
  then
194 196
    fprintf fmt "%s" id.var_id
195 197
  else
196
    if List.exists (fun o -> o.var_id = id.var_id) m.mstep.step_outputs (* id is output *)
198
    if is_output m id
197 199
    then
198 200
      fprintf fmt "%s" id.var_id
199 201
    else
......
227 229
    | Power (v, n)  -> assert false
228 230
    | LocalVar v    -> pp_var fmt v
229 231
    | StateVar v    ->
232
    (* array memory vars are represented by an indirection to a local var with the right type,
233
       in order to avoid casting everywhere. *)
230 234
      if Types.is_array_type v.var_type
231
      then fprintf fmt "*%a" pp_var v
235
      then fprintf fmt "%a" pp_var v
232 236
      else fprintf fmt "%s->_reg.%a" self pp_var v
233 237
    | Fun (n, vl)   -> Basic_library.pp_c n (pp_c_val self pp_var) fmt vl
234 238

  
src/machine_code.ml
128 128
let get_stateless_status m =
129 129
 (m.mname.node_dec_stateless, Utils.desome m.mname.node_stateless)
130 130

  
131
let is_input m id =
132
  List.exists (fun o -> o.var_id = id.var_id) m.mstep.step_inputs
133

  
131 134
let is_output m id =
132 135
  List.exists (fun o -> o.var_id = id.var_id) m.mstep.step_outputs
133 136

  
137
let is_memory m id =
138
  List.exists (fun o -> o.var_id = id.var_id) m.mmemory
139

  
134 140
let conditional c t e =
135 141
  MBranch(c, [ (tag_true, t); (tag_false, e) ])
136 142

  

Also available in: Unified diff