Revision 695db4da
Added by Guillaume DAVY over 4 years ago
src/backends/Ada/ada_backend_adb.ml | ||
---|---|---|
28 | 28 |
@param var_name the name of the variable |
29 | 29 |
@param value the value to be assigned |
30 | 30 |
**) |
31 |
let pp_basic_assign fmt var_name value = |
|
31 |
let pp_basic_assign m fmt var_name value =
|
|
32 | 32 |
fprintf fmt "%a := %a" |
33 | 33 |
pp_var_name var_name |
34 |
pp_value value
|
|
34 |
(pp_value m) value
|
|
35 | 35 |
|
36 | 36 |
(** Printing function for assignement. For the moment, only use |
37 | 37 |
[pp_basic_assign] function. |
... | ... | |
41 | 41 |
@param var_name the name of the variable |
42 | 42 |
@param value the value to be assigned |
43 | 43 |
**) |
44 |
let pp_assign pp_var fmt var_name value = pp_basic_assign
|
|
44 |
let pp_assign m pp_var fmt var_name value = pp_basic_assign m
|
|
45 | 45 |
|
46 | 46 |
(* Printing function for reset function *) |
47 | 47 |
(* TODO: clean the call to extract_node *) |
... | ... | |
85 | 85 |
| MReset ident -> |
86 | 86 |
pp_machine_reset machine fmt ident |
87 | 87 |
| MLocalAssign (ident, value) -> |
88 |
pp_basic_assign fmt ident value |
|
88 |
pp_basic_assign machine fmt ident value
|
|
89 | 89 |
| MStateAssign (ident, value) -> |
90 |
pp_basic_assign fmt ident value |
|
90 |
pp_basic_assign machine fmt ident value
|
|
91 | 91 |
| MStep ([i0], i, vl) when Basic_library.is_value_internal_fun |
92 | 92 |
(mk_val (Fun (i, vl)) i0.var_type) -> |
93 |
fprintf fmt "MStep basic"
|
|
93 |
fprintf fmt "Null"
|
|
94 | 94 |
(* pp_machine_instr dependencies m self fmt |
95 | 95 |
* (update_instr_desc instr (MLocalAssign (i0, mk_val (Fun (i, vl)) i0.var_type))) *) |
96 |
| MStep (il, i, vl) -> fprintf fmt "MStep"
|
|
96 |
| MStep (il, i, vl) -> fprintf fmt "Null"
|
|
97 | 97 |
|
98 | 98 |
(* pp_basic_instance_call m self fmt i vl il *) |
99 |
| MBranch (_, []) -> fprintf fmt "MBranch []"
|
|
99 |
| MBranch (_, []) -> fprintf fmt "Null"
|
|
100 | 100 |
|
101 | 101 |
(* (Format.eprintf "internal error: C_backend_src.pp_machine_instr %a@." (pp_instr m) instr; assert false) *) |
102 |
| MBranch (g, hl) -> fprintf fmt "MBranch gen"
|
|
102 |
| MBranch (g, hl) -> fprintf fmt "Null"
|
|
103 | 103 |
(* if let t = fst (List.hd hl) in t = tag_true || t = tag_false |
104 | 104 |
* then (\* boolean case, needs special treatment in C because truth value is not unique *\) |
105 | 105 |
* (\* may disappear if we optimize code by replacing last branch test with default *\) |
src/backends/Ada/ada_backend_common.ml | ||
---|---|---|
277 | 277 |
let pp_var_name fmt id = |
278 | 278 |
fprintf fmt "%a" pp_clean_ada_identifier id.var_id |
279 | 279 |
|
280 |
(** Print the complete name of variable state. |
|
281 |
@param fmt the formater to print on |
|
282 |
@param var the variable |
|
283 |
**) |
|
284 |
let pp_access_var fmt var = |
|
285 |
fprintf fmt "%t.%a" pp_state_name pp_var_name var |
|
286 |
|
|
280 | 287 |
(** Print a variable declaration |
281 | 288 |
@param mode input/output mode of the parameter |
282 | 289 |
@param pp_name a format printer wich print the variable name |
... | ... | |
519 | 526 |
|
520 | 527 |
(** Printing function for values. |
521 | 528 |
|
529 |
@param m the machine to know the state variable |
|
522 | 530 |
@param fmt the formater to use |
523 | 531 |
@param value the value to print. Should be a |
524 | 532 |
{!type:Machine_code_types.value_t} value |
525 | 533 |
**) |
526 |
let rec pp_value fmt value = |
|
534 |
let rec pp_value m fmt value =
|
|
527 | 535 |
match value.value_desc with |
528 | 536 |
| Cst c -> pp_ada_const fmt c |
529 |
| Var var_name -> pp_var_name fmt var_name |
|
530 |
| Fun (f_ident, vl) -> pp_basic_lib_fun pp_value f_ident fmt vl |
|
537 |
| Var var -> |
|
538 |
if is_memory m var then |
|
539 |
pp_access_var fmt var |
|
540 |
else |
|
541 |
pp_var_name fmt var |
|
542 |
| Fun (f_ident, vl) -> pp_basic_lib_fun (pp_value m) f_ident fmt vl |
|
531 | 543 |
| _ -> |
532 | 544 |
raise (Ada_not_supported |
533 | 545 |
"unsupported: Ada_backend.adb.pp_value does not support this value type") |
Also available in: Unified diff
Ada: - Replace MStep and Mbranch output by Null to have compilable Ada.
- Correct pp_value to print state access when the variable is memory