|
19 | 19 | #define NO_VALUE "(none)"
|
20 | 20 |
|
21 | 21 | /// Prints a constant to the given output stream.
|
22 |
| -/// \param [out] out: Stream that should receive the result. |
| 22 | +/// \param [out] os: Stream that should receive the result. |
23 | 23 | /// \param constant: Constant that shall be printed.
|
24 |
| -static void output_constant(std::ostream &out, const constant_exprt &constant) |
| 24 | +static void output_constant(std::ostream &os, const constant_exprt &constant) |
25 | 25 | {
|
26 | 26 | mp_integer ivalue;
|
27 | 27 | if(!to_integer(constant, ivalue))
|
28 |
| - out << ivalue; |
| 28 | + os << ivalue; |
29 | 29 | else if(can_cast_type<floatbv_typet>(constant.type()))
|
30 | 30 | {
|
31 | 31 | ieee_floatt real{get_real_type()};
|
32 | 32 | real.from_expr(constant);
|
33 |
| - out << real.to_float(); |
| 33 | + os << real.to_float(); |
34 | 34 | }
|
35 | 35 | else
|
36 |
| - out << constant.get_value(); |
| 36 | + os << constant.get_value(); |
37 | 37 | }
|
38 | 38 |
|
39 | 39 | /// Prints the assignment of a module parameter to the given output stream.
|
40 |
| -/// \param [out] out: Stream that should receive the result. |
| 40 | +/// \param [out] os: Stream that should receive the result. |
41 | 41 | /// \param assignment: Assignment that shall be printed.
|
42 | 42 | static void
|
43 |
| -output_parameter_assignment(std::ostream &out, const equal_exprt &assignment) |
| 43 | +output_parameter_assignment(std::ostream &os, const equal_exprt &assignment) |
44 | 44 | {
|
45 |
| - out << assignment.lhs().get(ID_identifier) << " := "; |
| 45 | + os << assignment.lhs().get(ID_identifier) << " := "; |
46 | 46 | const constant_exprt *const constant =
|
47 | 47 | expr_try_dynamic_cast<constant_exprt>(assignment.rhs());
|
48 | 48 | if(constant)
|
49 |
| - output_constant(out, *constant); |
| 49 | + output_constant(os, *constant); |
50 | 50 | else
|
51 |
| - out << assignment.rhs().get(ID_identifier); |
| 51 | + os << assignment.rhs().get(ID_identifier); |
52 | 52 | }
|
53 | 53 |
|
54 | 54 | void output_parse_tree(
|
@@ -81,178 +81,178 @@ void output_parse_tree(
|
81 | 81 | }
|
82 | 82 |
|
83 | 83 | void output_function_block(
|
84 |
| - std::ostream &out, |
| 84 | + std::ostream &os, |
85 | 85 | const statement_list_parse_treet::function_blockt &function_block)
|
86 | 86 | {
|
87 |
| - output_tia_module_properties(function_block, out); |
88 |
| - output_common_var_declarations(out, function_block); |
89 |
| - output_static_var_declarations(out, function_block); |
90 |
| - output_network_list(out, function_block.networks); |
| 87 | + output_tia_module_properties(function_block, os); |
| 88 | + output_common_var_declarations(os, function_block); |
| 89 | + output_static_var_declarations(os, function_block); |
| 90 | + output_network_list(os, function_block.networks); |
91 | 91 | }
|
92 | 92 |
|
93 | 93 | void output_function(
|
94 |
| - std::ostream &out, |
| 94 | + std::ostream &os, |
95 | 95 | const statement_list_parse_treet::functiont &function)
|
96 | 96 | {
|
97 |
| - output_tia_module_properties(function, out); |
98 |
| - output_return_value(function, out); |
99 |
| - output_common_var_declarations(out, function); |
100 |
| - output_network_list(out, function.networks); |
| 97 | + output_tia_module_properties(function, os); |
| 98 | + output_return_value(function, os); |
| 99 | + output_common_var_declarations(os, function); |
| 100 | + output_network_list(os, function.networks); |
101 | 101 | }
|
102 | 102 |
|
103 | 103 | void output_tia_module_properties(
|
104 | 104 | const statement_list_parse_treet::tia_modulet &module,
|
105 |
| - std::ostream &out) |
| 105 | + std::ostream &os) |
106 | 106 | {
|
107 |
| - out << "Name: " << module.name << '\n'; |
108 |
| - out << "Version: " << module.version << "\n\n"; |
| 107 | + os << "Name: " << module.name << '\n'; |
| 108 | + os << "Version: " << module.version << "\n\n"; |
109 | 109 | }
|
110 | 110 |
|
111 | 111 | void output_return_value(
|
112 | 112 | const statement_list_parse_treet::functiont &function,
|
113 |
| - std::ostream &out) |
| 113 | + std::ostream &os) |
114 | 114 | {
|
115 |
| - out << "Return type: "; |
| 115 | + os << "Return type: "; |
116 | 116 | if(function.return_type.is_nil())
|
117 |
| - out << "Void"; |
| 117 | + os << "Void"; |
118 | 118 | else
|
119 |
| - out << function.return_type.id(); |
120 |
| - out << "\n\n"; |
| 119 | + os << function.return_type.id(); |
| 120 | + os << "\n\n"; |
121 | 121 | }
|
122 | 122 |
|
123 | 123 | void output_common_var_declarations(
|
124 |
| - std::ostream &out, |
| 124 | + std::ostream &os, |
125 | 125 | const statement_list_parse_treet::tia_modulet &module)
|
126 | 126 | {
|
127 | 127 | if(!module.var_input.empty())
|
128 | 128 | {
|
129 |
| - out << "--------- Input Variables ----------\n\n"; |
130 |
| - output_var_declaration_list(out, module.var_input); |
| 129 | + os << "--------- Input Variables ----------\n\n"; |
| 130 | + output_var_declaration_list(os, module.var_input); |
131 | 131 | }
|
132 | 132 |
|
133 | 133 | if(!module.var_inout.empty())
|
134 | 134 | {
|
135 |
| - out << "--------- In/Out Variables ---------\n\n"; |
136 |
| - output_var_declaration_list(out, module.var_inout); |
| 135 | + os << "--------- In/Out Variables ---------\n\n"; |
| 136 | + output_var_declaration_list(os, module.var_inout); |
137 | 137 | }
|
138 | 138 |
|
139 | 139 | if(!module.var_output.empty())
|
140 | 140 | {
|
141 |
| - out << "--------- Output Variables ---------\n\n"; |
142 |
| - output_var_declaration_list(out, module.var_output); |
| 141 | + os << "--------- Output Variables ---------\n\n"; |
| 142 | + output_var_declaration_list(os, module.var_output); |
143 | 143 | }
|
144 | 144 |
|
145 | 145 | if(!module.var_constant.empty())
|
146 | 146 | {
|
147 |
| - out << "-------- Constant Variables --------\n\n"; |
148 |
| - output_var_declaration_list(out, module.var_constant); |
| 147 | + os << "-------- Constant Variables --------\n\n"; |
| 148 | + output_var_declaration_list(os, module.var_constant); |
149 | 149 | }
|
150 | 150 |
|
151 | 151 | if(!module.var_temp.empty())
|
152 | 152 | {
|
153 |
| - out << "---------- Temp Variables ----------\n\n"; |
154 |
| - output_var_declaration_list(out, module.var_temp); |
| 153 | + os << "---------- Temp Variables ----------\n\n"; |
| 154 | + output_var_declaration_list(os, module.var_temp); |
155 | 155 | }
|
156 | 156 | }
|
157 | 157 |
|
158 | 158 | void output_static_var_declarations(
|
159 |
| - std::ostream &out, |
| 159 | + std::ostream &os, |
160 | 160 | const statement_list_parse_treet::function_blockt &block)
|
161 | 161 | {
|
162 | 162 | if(!block.var_static.empty())
|
163 | 163 | {
|
164 |
| - out << "--------- Static Variables ---------\n\n"; |
165 |
| - output_var_declaration_list(out, block.var_static); |
| 164 | + os << "--------- Static Variables ---------\n\n"; |
| 165 | + output_var_declaration_list(os, block.var_static); |
166 | 166 | }
|
167 | 167 | }
|
168 | 168 |
|
169 | 169 | void output_var_declaration_list(
|
170 |
| - std::ostream &out, |
| 170 | + std::ostream &os, |
171 | 171 | const statement_list_parse_treet::var_declarationst &declarations)
|
172 | 172 | {
|
173 | 173 | for(const auto &declaration : declarations)
|
174 | 174 | {
|
175 |
| - output_var_declaration(out, declaration); |
176 |
| - out << "\n\n"; |
| 175 | + output_var_declaration(os, declaration); |
| 176 | + os << "\n\n"; |
177 | 177 | }
|
178 | 178 | }
|
179 | 179 |
|
180 | 180 | void output_var_declaration(
|
181 |
| - std::ostream &out, |
| 181 | + std::ostream &os, |
182 | 182 | const statement_list_parse_treet::var_declarationt &declaration)
|
183 | 183 | {
|
184 |
| - out << declaration.variable.pretty() << '\n'; |
185 |
| - out << " * default_value: "; |
| 184 | + os << declaration.variable.pretty() << '\n'; |
| 185 | + os << " * default_value: "; |
186 | 186 | if(declaration.default_value)
|
187 | 187 | {
|
188 | 188 | const constant_exprt &constant =
|
189 | 189 | to_constant_expr(declaration.default_value.value());
|
190 |
| - output_constant(out, constant); |
| 190 | + output_constant(os, constant); |
191 | 191 | }
|
192 | 192 | else
|
193 |
| - out << NO_VALUE; |
| 193 | + os << NO_VALUE; |
194 | 194 | }
|
195 | 195 |
|
196 | 196 | void output_network_list(
|
197 |
| - std::ostream &out, |
| 197 | + std::ostream &os, |
198 | 198 | const statement_list_parse_treet::networkst &networks)
|
199 | 199 | {
|
200 |
| - out << "-------------- Networks --------------\n\n"; |
| 200 | + os << "-------------- Networks --------------\n\n"; |
201 | 201 | for(const auto &network : networks)
|
202 | 202 | {
|
203 |
| - output_network(out, network); |
204 |
| - out << '\n'; |
| 203 | + output_network(os, network); |
| 204 | + os << '\n'; |
205 | 205 | }
|
206 | 206 | }
|
207 | 207 |
|
208 | 208 | void output_network(
|
209 |
| - std::ostream &out, |
| 209 | + std::ostream &os, |
210 | 210 | const statement_list_parse_treet::networkt &network)
|
211 | 211 | {
|
212 |
| - out << "Title: " << network.title.value_or(NO_VALUE) << '\n'; |
213 |
| - out << "Instructions: "; |
| 212 | + os << "Title: " << network.title.value_or(NO_VALUE) << '\n'; |
| 213 | + os << "Instructions: "; |
214 | 214 | if(network.instructions.empty())
|
215 |
| - out << NO_VALUE; |
216 |
| - out << '\n'; |
| 215 | + os << NO_VALUE; |
| 216 | + os << '\n'; |
217 | 217 | for(const auto &instruction : network.instructions)
|
218 | 218 | {
|
219 |
| - output_instruction(out, instruction); |
220 |
| - out << '\n'; |
| 219 | + output_instruction(os, instruction); |
| 220 | + os << '\n'; |
221 | 221 | }
|
222 | 222 | }
|
223 | 223 |
|
224 | 224 | void output_instruction(
|
225 |
| - std::ostream &out, |
| 225 | + std::ostream &os, |
226 | 226 | const statement_list_parse_treet::instructiont &instruction)
|
227 | 227 | {
|
228 | 228 | for(const codet &token : instruction.tokens)
|
229 | 229 | {
|
230 |
| - out << token.get_statement(); |
| 230 | + os << token.get_statement(); |
231 | 231 | for(const auto &expr : token.operands())
|
232 | 232 | {
|
233 | 233 | const symbol_exprt *const symbol =
|
234 | 234 | expr_try_dynamic_cast<symbol_exprt>(expr);
|
235 | 235 | if(symbol)
|
236 | 236 | {
|
237 |
| - out << '\t' << symbol->get_identifier(); |
| 237 | + os << '\t' << symbol->get_identifier(); |
238 | 238 | continue;
|
239 | 239 | }
|
240 | 240 | const constant_exprt *const constant =
|
241 | 241 | expr_try_dynamic_cast<constant_exprt>(expr);
|
242 | 242 | if(constant)
|
243 | 243 | {
|
244 |
| - out << '\t'; |
245 |
| - output_constant(out, *constant); |
| 244 | + os << '\t'; |
| 245 | + output_constant(os, *constant); |
246 | 246 | continue;
|
247 | 247 | }
|
248 | 248 | const equal_exprt *const equal = expr_try_dynamic_cast<equal_exprt>(expr);
|
249 | 249 | if(equal)
|
250 | 250 | {
|
251 |
| - out << "\n\t"; |
252 |
| - output_parameter_assignment(out, *equal); |
| 251 | + os << "\n\t"; |
| 252 | + output_parameter_assignment(os, *equal); |
253 | 253 | continue;
|
254 | 254 | }
|
255 |
| - out << '\t' << expr.id(); |
| 255 | + os << '\t' << expr.id(); |
256 | 256 | }
|
257 | 257 | }
|
258 | 258 | }
|
0 commit comments