Project

General

Profile

Revision 826063db src/backends/Ada/ada_backend_wrapper.ml

View differences:

src/backends/Ada/ada_backend_wrapper.ml
48 48
     @param fmt the formater to print on
49 49
     @param machine the main machine
50 50
  **)
51
  let pp_main_adb fmt machine =
51
  let pp_main_adb typed_submachines fmt machine =
52
    let statefull = is_machine_statefull machine in
52 53
    let pp_str str fmt = fprintf fmt "%s" str in
54
    
53 55
    (* Dependances *)
54 56
    let text_io = "Ada.Text_IO" in
55 57
    let float_io = "package Float_IO is new Ada.Text_IO.Float_IO(Float)" in
56 58
    let integer_io = "package Integer_IO is new Ada.Text_IO.Integer_IO(Integer)" in
57 59
    
58 60
    (* Locals *)
59
    let stateVar = "state" in
60
    let step_parameters = machine.mstep.step_inputs@machine.mstep.step_outputs in
61
    let stateVar = asprintf "%t" pp_state_name in
61 62
    let pp_local_state_var_decl fmt = pp_node_state_decl [] stateVar fmt machine in
62 63
    let apply_pp_var_decl var fmt = pp_machine_var_decl NoMode fmt var in
64
    let step_parameters = machine.mstep.step_inputs@machine.mstep.step_outputs in
63 65
    let locals = List.map apply_pp_var_decl step_parameters in
64
    let locals = (pp_str integer_io)::(pp_str float_io)::pp_local_state_var_decl::locals in
66
    let locals = [pp_str integer_io;pp_str float_io]@(if statefull then [pp_local_state_var_decl] else [])@locals in
65 67

  
66 68
    (* Node instructions *)
67 69
    let pp_reset fmt =
68
      fprintf fmt "%a.reset(%s)"
69
        pp_package_name machine
70
        stateVar in
70
      pp_package_call
71
        pp_reset_procedure_name
72
        fmt
73
        ([], machine, pp_state_name, None)
74
    in
75
    let pp_args fmt =
76
      fprintf fmt "@[%a@]"
77
        (Utils.fprintf_list ~sep:",@ " pp_var_name) step_parameters
78
    in
71 79
    let pp_step fmt =
72
      fprintf fmt "%a.step(@[%s,@ %a@])"
73
        pp_package_name machine
74
        stateVar
75
        (Utils.fprintf_list ~sep:",@ " pp_var_name) step_parameters in
80
          pp_package_call
81
            pp_step_procedure_name
82
            fmt
83
            ([], machine, pp_state_name, Some pp_args)
84
    in
76 85

  
77 86
    (* Stream instructions *)
78 87
    let get_basic var = match (Types.repr var.var_type ).Types.tdesc with
......
112 121
        (Utils.fprintf_list ~sep:";@," pp_write) machine.mstep.step_outputs in
113 122
    
114 123
    (* Print the file *)
115
    let instrs = [ pp_reset;
116
                   pp_loop] in
124
    let instrs = (if statefull then [pp_reset] else [])@[pp_loop] in
117 125
    fprintf fmt "@[<v>%a;@,%a;@,@,%a;@]"
118 126
      pp_private_with (pp_str text_io)
119 127
      pp_with_machine machine

Also available in: Unified diff