Project

General

Profile

Revision 8446bf03 src/backends/C/c_backend_common.ml

View differences:

src/backends/C/c_backend_common.ml
10 10
(********************************************************************)
11 11

  
12 12
open Format
13
open LustreSpec
13
open Lustre_types
14 14
open Corelang
15 15
open Machine_code
16 16

  
......
194 194
   but an offset suffix may be added for array variables
195 195
*)
196 196
let rec pp_c_val self pp_var fmt v =
197
  let open Machine_code_types in
197 198
  match v.value_desc with
198 199
  | Cst c         -> pp_c_const fmt c
199 200
  | Array vl      -> fprintf fmt "{%a}" (Utils.fprintf_list ~sep:", " (pp_c_val self pp_var)) vl
......
462 463
  else
463 464
    fprintf fmt "&%s" id.var_id
464 465

  
465
let pp_main_call mname self fmt m (inputs: value_t list) (outputs: var_decl list) =
466
let pp_main_call mname self fmt m (inputs: Machine_code_types.value_t list) (outputs: var_decl list) =
466 467
  if fst (get_stateless_status m)
467 468
  then
468 469
    fprintf fmt "%a (%a%t%a);"
......
480 481
      self
481 482

  
482 483
let pp_c_var m self pp_var fmt var =
484
  let open Machine_code_types in
483 485
  if is_memory m var
484 486
  then
485 487
    pp_c_val self pp_var fmt (mk_val (StateVar var) var.var_type)
......
516 518
    end
517 519

  
518 520
let pp_const_initialize pp_var fmt const =
521
  let open Machine_code_types in
519 522
  let var = mk_val (LocalVar (Corelang.var_decl_of_const const)) const.const_type in
520 523
  let rec aux indices value fmt typ =
521 524
    if Types.is_array_type typ
......
594 597
      aux [] fmt var.var_type
595 598
    end
596 599

  
597
let pp_call m self pp_read pp_write fmt i (inputs: value_t list) (outputs: var_decl list) =
600
let pp_call m self pp_read pp_write fmt i (inputs: Machine_code_types.value_t list) (outputs: var_decl list) =
598 601
 try (* stateful node instance *)
599 602
   let (n,_) = List.assoc i m.minstances in
600 603
   fprintf fmt "%a (%a%t%a%t%s->%s);"
......
613 616
     (Utils.pp_final_char_if_non_empty ", " inputs) 
614 617
     (Utils.fprintf_list ~sep:", " pp_write) outputs 
615 618

  
616
let pp_basic_instance_call m self fmt i (inputs: value_t list) (outputs: var_decl list) =
619
let pp_basic_instance_call m self fmt i (inputs: Machine_code_types.value_t list) (outputs: var_decl list) =
617 620
  pp_call m self (pp_c_var_read m) (pp_c_var_write m) fmt i inputs outputs
618 621
(*
619 622
 try (* stateful node instance *)
......
635 638
     (Utils.fprintf_list ~sep:", " (pp_c_var_write m)) outputs 
636 639
*)
637 640

  
638
let pp_instance_call m self fmt i (inputs: value_t list) (outputs: var_decl list) =
641
let pp_instance_call m self fmt i (inputs: Machine_code_types.value_t list) (outputs: var_decl list) =
639 642
  let pp_offset pp_var indices fmt var =
640 643
    match indices with
641 644
    | [] -> fprintf fmt "%a" pp_var var
......
655 658
  in
656 659
  begin
657 660
    reset_loop_counter ();
658
    aux [] fmt (List.hd inputs).value_type
661
    aux [] fmt (List.hd inputs).Machine_code_types.value_type
659 662
  end
660 663

  
661 664
  (*** Common functions for main ***)

Also available in: Unified diff