Project

General

Profile

« Previous | Next » 

Revision aaa8e454

Added by LĂ©lio Brun 7 months ago

it works

View differences:

src/backends/C/c_backend_common.ml
299 299
  | Const_modeid _ -> assert false (* string occurs in annotations not in C *)
300 300

  
301 301
let reset_flag_name = "_reset"
302
let pp_reset_flag ?(indirect=true) fmt self =
303
  fprintf fmt "%s%s%s" self (if indirect then "->" else ".") reset_flag_name
302
let pp_reset_flag ?(indirect=true) pp_stru fmt stru =
303
  fprintf fmt "%a%s%s"
304
    pp_stru stru
305
    (if indirect then "->" else ".")
306
    reset_flag_name
307
let pp_reset_flag' ?indirect fmt =
308
  pp_reset_flag ?indirect pp_print_string fmt
304 309

  
305 310
let pp_reset_assign self fmt b =
306 311
  fprintf fmt "%a = %i;"
307
    (pp_reset_flag ~indirect:true) self (if b then 1 else 0)
312
    (pp_reset_flag' ~indirect:true) self (if b then 1 else 0)
308 313

  
309 314
(* Prints a value expression [v], with internal function calls only.
310 315
   [pp_var] is a printer for variables (typically [pp_c_var_read]),
......
337 342
  | Fun (n, vl) ->
338 343
    pp_basic_lib_fun (Types.is_int_type v.value_type) n pp_c_val fmt vl
339 344
  | ResetFlag ->
340
    pp_reset_flag fmt self
345
    pp_reset_flag' fmt self
341 346

  
342 347

  
343 348
(* Access to the value of a variable:
......
346 351
     despite its scalar Lustre type)
347 352
   - moreover, dereference memory array variables.
348 353
*)
349
let pp_c_var_read m fmt id =
354
let pp_c_var_read ?(test_output=true) m fmt id =
350 355
  (* mpfr_t is a static array, not treated as general arrays *)
351 356
  if Types.is_address_type id.var_type
352 357
  then
......
355 360
    then fprintf fmt "(*%s)" id.var_id
356 361
    else fprintf fmt "%s" id.var_id
357 362
  else
358
    if Machine_code_common.is_output m id
363
    if test_output && Machine_code_common.is_output m id
359 364
    then fprintf fmt "*%s" id.var_id
360 365
    else fprintf fmt "%s" id.var_id
361 366

  
......
616 621
  | _, Cst cst ->
617 622
    pp_c_const_suffix var_type fmt cst
618 623
  | _, ResetFlag ->
619
    pp_reset_flag fmt self
624
    pp_reset_flag' fmt self
620 625
  | _, _ ->
621 626
    eprintf "internal error: C_backend_src.pp_value_suffix %a %a %a@."
622 627
      Types.print_ty var_type (pp_val m) value pp_suffix loop_vars;

Also available in: Unified diff