@@ -49,66 +49,59 @@ goto_programt::instructiont goto_programt::make_incomplete_goto(
49
49
// / {representation of the instruction}
50
50
// / ```
51
51
// / \param ns: the namespace to resolve the expressions in
52
- // / \param identifier: the identifier used to find a symbol to identify the
53
- // / source language
54
52
// / \param out: the stream to write the goto string to
55
- // / \param instruction: the instruction to convert
56
53
// / \return Appends to out a two line representation of the instruction
57
- std::ostream &goto_programt::output_instruction (
54
+ std::ostream &goto_programt::instructiont::output (
58
55
const namespacet &ns,
59
- const irep_idt &identifier,
60
- std::ostream &out,
61
- const instructiont &instruction) const
56
+ std::ostream &out) const
62
57
{
63
- out << " // " << instruction. location_number << " " ;
58
+ out << " // " << location_number << " " ;
64
59
65
- if (!instruction. source_location ().is_nil ())
66
- out << instruction. source_location ().as_string ();
60
+ if (!source_location ().is_nil ())
61
+ out << source_location ().as_string ();
67
62
else
68
63
out << " no location" ;
69
64
70
65
out << " \n " ;
71
66
72
- if (!instruction. labels .empty ())
67
+ if (!labels.empty ())
73
68
{
74
69
out << " // Labels:" ;
75
- for (const auto &label : instruction. labels )
70
+ for (const auto &label : labels)
76
71
out << " " << label;
77
72
78
73
out << ' \n ' ;
79
74
}
80
75
81
- if (instruction. is_target ())
82
- out << std::setw (6 ) << instruction. target_number << " : " ;
76
+ if (is_target ())
77
+ out << std::setw (6 ) << target_number << " : " ;
83
78
else
84
79
out << " " ;
85
80
86
- switch (instruction. type ())
81
+ switch (type ())
87
82
{
88
83
case NO_INSTRUCTION_TYPE:
89
84
out << " NO INSTRUCTION TYPE SET" << ' \n ' ;
90
85
break ;
91
86
92
87
case GOTO:
93
88
case INCOMPLETE_GOTO:
94
- if (!instruction. condition ().is_true ())
89
+ if (!condition ().is_true ())
95
90
{
96
- out << " IF " << format (instruction. condition ()) << " THEN " ;
91
+ out << " IF " << format (condition ()) << " THEN " ;
97
92
}
98
93
99
94
out << " GOTO " ;
100
95
101
- if (instruction. is_incomplete_goto ())
96
+ if (is_incomplete_goto ())
102
97
{
103
98
out << " (incomplete)" ;
104
99
}
105
100
else
106
101
{
107
- for (auto gt_it = instruction.targets .begin ();
108
- gt_it != instruction.targets .end ();
109
- gt_it++)
102
+ for (auto gt_it = targets.begin (); gt_it != targets.end (); gt_it++)
110
103
{
111
- if (gt_it != instruction. targets .begin ())
104
+ if (gt_it != targets.begin ())
112
105
out << " , " ;
113
106
out << (*gt_it)->target_number ;
114
107
}
@@ -118,9 +111,9 @@ std::ostream &goto_programt::output_instruction(
118
111
break ;
119
112
120
113
case OTHER:
121
- if (instruction. get_other ().id () == ID_code)
114
+ if (get_other ().id () == ID_code)
122
115
{
123
- const auto &code = instruction. get_other ();
116
+ const auto &code = get_other ();
124
117
if (code.get_statement () == ID_array_copy)
125
118
{
126
119
out << " ARRAY_COPY " << format (code.op0 ()) << ' ' << format (code.op1 ())
@@ -174,31 +167,31 @@ std::ostream &goto_programt::output_instruction(
174
167
// fallthrough
175
168
}
176
169
177
- out << " OTHER " << format (instruction. get_other ()) << ' \n ' ;
170
+ out << " OTHER " << format (get_other ()) << ' \n ' ;
178
171
break ;
179
172
180
173
case SET_RETURN_VALUE:
181
- out << " SET RETURN VALUE " << format (instruction. return_value ()) << ' \n ' ;
174
+ out << " SET RETURN VALUE " << format (return_value ()) << ' \n ' ;
182
175
break ;
183
176
184
177
case DECL:
185
- out << " DECL " << format (instruction. decl_symbol ()) << " : "
186
- << format (instruction. decl_symbol ().type ()) << ' \n ' ;
178
+ out << " DECL " << format (decl_symbol ()) << " : "
179
+ << format (decl_symbol ().type ()) << ' \n ' ;
187
180
break ;
188
181
189
182
case DEAD:
190
- out << " DEAD " << format (instruction. dead_symbol ()) << ' \n ' ;
183
+ out << " DEAD " << format (dead_symbol ()) << ' \n ' ;
191
184
break ;
192
185
193
186
case FUNCTION_CALL:
194
187
out << " CALL " ;
195
188
{
196
- if (instruction. call_lhs ().is_not_nil ())
197
- out << format (instruction. call_lhs ()) << " := " ;
198
- out << format (instruction. call_function ());
189
+ if (call_lhs ().is_not_nil ())
190
+ out << format (call_lhs ()) << " := " ;
191
+ out << format (call_function ());
199
192
out << ' (' ;
200
193
bool first = true ;
201
- for (const auto &argument : instruction. call_arguments ())
194
+ for (const auto &argument : call_arguments ())
202
195
{
203
196
if (first)
204
197
first = false ;
@@ -212,21 +205,21 @@ std::ostream &goto_programt::output_instruction(
212
205
break ;
213
206
214
207
case ASSIGN:
215
- out << " ASSIGN " << format (instruction. assign_lhs ())
216
- << " := " << format (instruction. assign_rhs ()) << ' \n ' ;
208
+ out << " ASSIGN " << format (assign_lhs ()) << " := " << format ( assign_rhs ())
209
+ << ' \n ' ;
217
210
break ;
218
211
219
212
case ASSUME:
220
213
case ASSERT:
221
- if (instruction. is_assume ())
214
+ if (is_assume ())
222
215
out << " ASSUME " ;
223
216
else
224
217
out << " ASSERT " ;
225
218
226
219
{
227
- out << format (instruction. condition ());
220
+ out << format (condition ());
228
221
229
- const irep_idt &comment = instruction. source_location ().get_comment ();
222
+ const irep_idt &comment = source_location ().get_comment ();
230
223
if (!comment.empty ())
231
224
out << " // " << comment;
232
225
}
@@ -251,49 +244,48 @@ std::ostream &goto_programt::output_instruction(
251
244
252
245
{
253
246
const irept::subt &exception_list =
254
- instruction. code ().find (ID_exception_list).get_sub ();
247
+ code ().find (ID_exception_list).get_sub ();
255
248
256
249
for (const auto &ex : exception_list)
257
250
out << " " << ex.id ();
258
251
}
259
252
260
- if (instruction. code ().operands ().size () == 1 )
261
- out << " : " << format (instruction. code ().op0 ());
253
+ if (code ().operands ().size () == 1 )
254
+ out << " : " << format (code ().op0 ());
262
255
263
256
out << ' \n ' ;
264
257
break ;
265
258
266
259
case CATCH:
267
260
{
268
- if (instruction. code ().get_statement () == ID_exception_landingpad)
261
+ if (code ().get_statement () == ID_exception_landingpad)
269
262
{
270
- const auto &landingpad = to_code_landingpad (instruction. code ());
263
+ const auto &landingpad = to_code_landingpad (code ());
271
264
out << " EXCEPTION LANDING PAD (" << format (landingpad.catch_expr ().type ())
272
265
<< ' ' << format (landingpad.catch_expr ()) << " )" ;
273
266
}
274
- else if (instruction. code ().get_statement () == ID_push_catch)
267
+ else if (code ().get_statement () == ID_push_catch)
275
268
{
276
269
out << " CATCH-PUSH " ;
277
270
278
271
unsigned i=0 ;
279
272
const irept::subt &exception_list =
280
- instruction. code ().find (ID_exception_list).get_sub ();
273
+ code ().find (ID_exception_list).get_sub ();
281
274
DATA_INVARIANT (
282
- instruction. targets .size () == exception_list.size (),
275
+ targets.size () == exception_list.size (),
283
276
" unexpected discrepancy between sizes of instruction"
284
277
" targets and exception list" );
285
- for (instructiont::targetst::const_iterator
286
- gt_it=instruction.targets .begin ();
287
- gt_it!=instruction.targets .end ();
278
+ for (instructiont::targetst::const_iterator gt_it = targets.begin ();
279
+ gt_it != targets.end ();
288
280
gt_it++, i++)
289
281
{
290
- if (gt_it!=instruction. targets .begin ())
282
+ if (gt_it != targets.begin ())
291
283
out << " , " ;
292
284
out << exception_list[i].id () << " ->"
293
285
<< (*gt_it)->target_number ;
294
286
}
295
287
}
296
- else if (instruction. code ().get_statement () == ID_pop_catch)
288
+ else if (code ().get_statement () == ID_pop_catch)
297
289
{
298
290
out << " CATCH-POP" ;
299
291
}
@@ -315,9 +307,7 @@ std::ostream &goto_programt::output_instruction(
315
307
break ;
316
308
317
309
case START_THREAD:
318
- out << " START THREAD "
319
- << instruction.get_target ()->target_number
320
- << ' \n ' ;
310
+ out << " START THREAD " << get_target ()->target_number << ' \n ' ;
321
311
break ;
322
312
323
313
case END_THREAD:
@@ -638,13 +628,12 @@ void goto_programt::update()
638
628
639
629
std::ostream &goto_programt::output (
640
630
const namespacet &ns,
641
- const irep_idt &identifier,
642
631
std::ostream &out) const
643
632
{
644
633
// output program
645
634
646
635
for (const auto &instruction : instructions)
647
- output_instruction (ns, identifier, out, instruction );
636
+ instruction. output (ns, out);
648
637
649
638
return out;
650
639
}
0 commit comments