Revision 65de9931
Added by Pierre-Loïc Garoche about 5 years ago
src/backends/C/c_backend_main.ml | ||
---|---|---|
51 | 51 |
fprintf fmt "@ %a;" pi ((idx+1), v', v); |
52 | 52 |
) m.mname.node_inputs m.mstep.step_inputs |
53 | 53 |
|
54 |
|
|
54 | 55 |
let print_put_outputs fmt m = |
55 | 56 |
let po fmt (id, o', o) = |
56 |
match (Types.unclock_type o.var_type).Types.tdesc with |
|
57 |
| Types.Tint -> fprintf fmt "_put_int(f_out%i, \"%s\", %s)" id o'.var_id o.var_id |
|
58 |
| Types.Tbool -> fprintf fmt "_put_bool(f_out%i, \"%s\", %s)" id o'.var_id o.var_id |
|
59 |
| Types.Treal when !Options.mpfr -> fprintf fmt "_put_double(f_out%i, \"%s\", mpfr_get_d(%s, %s))" id o'.var_id o.var_id (Mpfr.mpfr_rnd ()) |
|
60 |
| Types.Treal -> fprintf fmt "_put_double(f_out%i, \"%s\", %s)" id o'.var_id o.var_id |
|
61 |
| _ -> assert false |
|
57 |
let suff = string_of_int id in |
|
58 |
print_put_var fmt suff o'.var_id o.var_type o.var_id |
|
62 | 59 |
in |
63 | 60 |
Utils.List.iteri2 (fun idx v' v -> fprintf fmt "@ %a;" po ((idx+1), v', v)) m.mname.node_outputs m.mstep.step_outputs |
64 | 61 |
|
... | ... | |
142 | 139 |
fprintf fmt "@ /* Infinite loop */@ "; |
143 | 140 |
fprintf fmt "@[<v 2>while(1){@ "; |
144 | 141 |
fprintf fmt "fflush(stdout);@ "; |
145 |
List.iteri (fun idx _ -> fprintf fmt "fflush(f_in%i);@ " (idx+1)) m.mstep.step_inputs; |
|
146 |
List.iteri (fun idx _ -> fprintf fmt "fflush(f_out%i);@ " (idx+1)) m.mstep.step_outputs; |
|
147 | 142 |
fprintf fmt "%a@ %t%a" |
148 | 143 |
print_get_inputs m |
149 | 144 |
(fun fmt -> pp_main_call mname main_mem fmt m input_values m.mstep.step_outputs) |
... | ... | |
158 | 153 |
else "main_mem" in |
159 | 154 |
fprintf fmt "@[<v 2>int main (int argc, char *argv[]) {@ "; |
160 | 155 |
print_main_inout_declaration basename fmt m; |
156 |
Plugins.c_backend_main_loop_body_prefix basename mname fmt (); |
|
161 | 157 |
print_main_memory_allocation mname main_mem fmt m; |
162 | 158 |
if !Options.mpfr then |
163 | 159 |
begin |
Also available in: Unified diff
New feature to specify the number of digits to be printed