Skip to content

Commit 7cf5b9b

Browse files
committed
Refactor parameter names in STL parse tree IO
1 parent 9db61cf commit 7cf5b9b

File tree

2 files changed

+93
-93
lines changed

2 files changed

+93
-93
lines changed

src/statement-list/statement_list_parse_tree_io.cpp

Lines changed: 69 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -19,36 +19,36 @@ Author: Matthias Weiss, [email protected]
1919
#define NO_VALUE "(none)"
2020

2121
/// 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.
2323
/// \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)
2525
{
2626
mp_integer ivalue;
2727
if(!to_integer(constant, ivalue))
28-
out << ivalue;
28+
os << ivalue;
2929
else if(can_cast_type<floatbv_typet>(constant.type()))
3030
{
3131
ieee_floatt real{get_real_type()};
3232
real.from_expr(constant);
33-
out << real.to_float();
33+
os << real.to_float();
3434
}
3535
else
36-
out << constant.get_value();
36+
os << constant.get_value();
3737
}
3838

3939
/// 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.
4141
/// \param assignment: Assignment that shall be printed.
4242
static void
43-
output_parameter_assignment(std::ostream &out, const equal_exprt &assignment)
43+
output_parameter_assignment(std::ostream &os, const equal_exprt &assignment)
4444
{
45-
out << assignment.lhs().get(ID_identifier) << " := ";
45+
os << assignment.lhs().get(ID_identifier) << " := ";
4646
const constant_exprt *const constant =
4747
expr_try_dynamic_cast<constant_exprt>(assignment.rhs());
4848
if(constant)
49-
output_constant(out, *constant);
49+
output_constant(os, *constant);
5050
else
51-
out << assignment.rhs().get(ID_identifier);
51+
os << assignment.rhs().get(ID_identifier);
5252
}
5353

5454
void output_parse_tree(
@@ -81,178 +81,178 @@ void output_parse_tree(
8181
}
8282

8383
void output_function_block(
84-
std::ostream &out,
84+
std::ostream &os,
8585
const statement_list_parse_treet::function_blockt &function_block)
8686
{
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);
9191
}
9292

9393
void output_function(
94-
std::ostream &out,
94+
std::ostream &os,
9595
const statement_list_parse_treet::functiont &function)
9696
{
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);
101101
}
102102

103103
void output_tia_module_properties(
104104
const statement_list_parse_treet::tia_modulet &module,
105-
std::ostream &out)
105+
std::ostream &os)
106106
{
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";
109109
}
110110

111111
void output_return_value(
112112
const statement_list_parse_treet::functiont &function,
113-
std::ostream &out)
113+
std::ostream &os)
114114
{
115-
out << "Return type: ";
115+
os << "Return type: ";
116116
if(function.return_type.is_nil())
117-
out << "Void";
117+
os << "Void";
118118
else
119-
out << function.return_type.id();
120-
out << "\n\n";
119+
os << function.return_type.id();
120+
os << "\n\n";
121121
}
122122

123123
void output_common_var_declarations(
124-
std::ostream &out,
124+
std::ostream &os,
125125
const statement_list_parse_treet::tia_modulet &module)
126126
{
127127
if(!module.var_input.empty())
128128
{
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);
131131
}
132132

133133
if(!module.var_inout.empty())
134134
{
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);
137137
}
138138

139139
if(!module.var_output.empty())
140140
{
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);
143143
}
144144

145145
if(!module.var_constant.empty())
146146
{
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);
149149
}
150150

151151
if(!module.var_temp.empty())
152152
{
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);
155155
}
156156
}
157157

158158
void output_static_var_declarations(
159-
std::ostream &out,
159+
std::ostream &os,
160160
const statement_list_parse_treet::function_blockt &block)
161161
{
162162
if(!block.var_static.empty())
163163
{
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);
166166
}
167167
}
168168

169169
void output_var_declaration_list(
170-
std::ostream &out,
170+
std::ostream &os,
171171
const statement_list_parse_treet::var_declarationst &declarations)
172172
{
173173
for(const auto &declaration : declarations)
174174
{
175-
output_var_declaration(out, declaration);
176-
out << "\n\n";
175+
output_var_declaration(os, declaration);
176+
os << "\n\n";
177177
}
178178
}
179179

180180
void output_var_declaration(
181-
std::ostream &out,
181+
std::ostream &os,
182182
const statement_list_parse_treet::var_declarationt &declaration)
183183
{
184-
out << declaration.variable.pretty() << '\n';
185-
out << " * default_value: ";
184+
os << declaration.variable.pretty() << '\n';
185+
os << " * default_value: ";
186186
if(declaration.default_value)
187187
{
188188
const constant_exprt &constant =
189189
to_constant_expr(declaration.default_value.value());
190-
output_constant(out, constant);
190+
output_constant(os, constant);
191191
}
192192
else
193-
out << NO_VALUE;
193+
os << NO_VALUE;
194194
}
195195

196196
void output_network_list(
197-
std::ostream &out,
197+
std::ostream &os,
198198
const statement_list_parse_treet::networkst &networks)
199199
{
200-
out << "-------------- Networks --------------\n\n";
200+
os << "-------------- Networks --------------\n\n";
201201
for(const auto &network : networks)
202202
{
203-
output_network(out, network);
204-
out << '\n';
203+
output_network(os, network);
204+
os << '\n';
205205
}
206206
}
207207

208208
void output_network(
209-
std::ostream &out,
209+
std::ostream &os,
210210
const statement_list_parse_treet::networkt &network)
211211
{
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: ";
214214
if(network.instructions.empty())
215-
out << NO_VALUE;
216-
out << '\n';
215+
os << NO_VALUE;
216+
os << '\n';
217217
for(const auto &instruction : network.instructions)
218218
{
219-
output_instruction(out, instruction);
220-
out << '\n';
219+
output_instruction(os, instruction);
220+
os << '\n';
221221
}
222222
}
223223

224224
void output_instruction(
225-
std::ostream &out,
225+
std::ostream &os,
226226
const statement_list_parse_treet::instructiont &instruction)
227227
{
228228
for(const codet &token : instruction.tokens)
229229
{
230-
out << token.get_statement();
230+
os << token.get_statement();
231231
for(const auto &expr : token.operands())
232232
{
233233
const symbol_exprt *const symbol =
234234
expr_try_dynamic_cast<symbol_exprt>(expr);
235235
if(symbol)
236236
{
237-
out << '\t' << symbol->get_identifier();
237+
os << '\t' << symbol->get_identifier();
238238
continue;
239239
}
240240
const constant_exprt *const constant =
241241
expr_try_dynamic_cast<constant_exprt>(expr);
242242
if(constant)
243243
{
244-
out << '\t';
245-
output_constant(out, *constant);
244+
os << '\t';
245+
output_constant(os, *constant);
246246
continue;
247247
}
248248
const equal_exprt *const equal = expr_try_dynamic_cast<equal_exprt>(expr);
249249
if(equal)
250250
{
251-
out << "\n\t";
252-
output_parameter_assignment(out, *equal);
251+
os << "\n\t";
252+
output_parameter_assignment(os, *equal);
253253
continue;
254254
}
255-
out << '\t' << expr.id();
255+
os << '\t' << expr.id();
256256
}
257257
}
258258
}

0 commit comments

Comments
 (0)