@@ -49,66 +49,59 @@ goto_programt::instructiont goto_programt::make_incomplete_goto(
4949// / {representation of the instruction}
5050// / ```
5151// / \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
5452// / \param out: the stream to write the goto string to
55- // / \param instruction: the instruction to convert
5653// / \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 (
5855 const namespacet &ns,
59- const irep_idt &identifier,
60- std::ostream &out,
61- const instructiont &instruction) const
56+ std::ostream &out) const
6257{
63- out << " // " << instruction. location_number << " " ;
58+ out << " // " << location_number << " " ;
6459
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 ();
6762 else
6863 out << " no location" ;
6964
7065 out << " \n " ;
7166
72- if (!instruction. labels .empty ())
67+ if (!labels.empty ())
7368 {
7469 out << " // Labels:" ;
75- for (const auto &label : instruction. labels )
70+ for (const auto &label : labels)
7671 out << " " << label;
7772
7873 out << ' \n ' ;
7974 }
8075
81- if (instruction. is_target ())
82- out << std::setw (6 ) << instruction. target_number << " : " ;
76+ if (is_target ())
77+ out << std::setw (6 ) << target_number << " : " ;
8378 else
8479 out << " " ;
8580
86- switch (instruction. type ())
81+ switch (type ())
8782 {
8883 case NO_INSTRUCTION_TYPE:
8984 out << " NO INSTRUCTION TYPE SET" << ' \n ' ;
9085 break ;
9186
9287 case GOTO:
9388 case INCOMPLETE_GOTO:
94- if (!instruction. condition ().is_true ())
89+ if (!condition ().is_true ())
9590 {
96- out << " IF " << format (instruction. condition ()) << " THEN " ;
91+ out << " IF " << format (condition ()) << " THEN " ;
9792 }
9893
9994 out << " GOTO " ;
10095
101- if (instruction. is_incomplete_goto ())
96+ if (is_incomplete_goto ())
10297 {
10398 out << " (incomplete)" ;
10499 }
105100 else
106101 {
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++)
110103 {
111- if (gt_it != instruction. targets .begin ())
104+ if (gt_it != targets.begin ())
112105 out << " , " ;
113106 out << (*gt_it)->target_number ;
114107 }
@@ -118,9 +111,9 @@ std::ostream &goto_programt::output_instruction(
118111 break ;
119112
120113 case OTHER:
121- if (instruction. get_other ().id () == ID_code)
114+ if (get_other ().id () == ID_code)
122115 {
123- const auto &code = instruction. get_other ();
116+ const auto &code = get_other ();
124117 if (code.get_statement () == ID_array_copy)
125118 {
126119 out << " ARRAY_COPY " << format (code.op0 ()) << ' ' << format (code.op1 ())
@@ -174,31 +167,31 @@ std::ostream &goto_programt::output_instruction(
174167 // fallthrough
175168 }
176169
177- out << " OTHER " << format (instruction. get_other ()) << ' \n ' ;
170+ out << " OTHER " << format (get_other ()) << ' \n ' ;
178171 break ;
179172
180173 case SET_RETURN_VALUE:
181- out << " SET RETURN VALUE " << format (instruction. return_value ()) << ' \n ' ;
174+ out << " SET RETURN VALUE " << format (return_value ()) << ' \n ' ;
182175 break ;
183176
184177 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 ' ;
187180 break ;
188181
189182 case DEAD:
190- out << " DEAD " << format (instruction. dead_symbol ()) << ' \n ' ;
183+ out << " DEAD " << format (dead_symbol ()) << ' \n ' ;
191184 break ;
192185
193186 case FUNCTION_CALL:
194187 out << " CALL " ;
195188 {
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 ());
199192 out << ' (' ;
200193 bool first = true ;
201- for (const auto &argument : instruction. call_arguments ())
194+ for (const auto &argument : call_arguments ())
202195 {
203196 if (first)
204197 first = false ;
@@ -212,21 +205,21 @@ std::ostream &goto_programt::output_instruction(
212205 break ;
213206
214207 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 ' ;
217210 break ;
218211
219212 case ASSUME:
220213 case ASSERT:
221- if (instruction. is_assume ())
214+ if (is_assume ())
222215 out << " ASSUME " ;
223216 else
224217 out << " ASSERT " ;
225218
226219 {
227- out << format (instruction. condition ());
220+ out << format (condition ());
228221
229- const irep_idt &comment = instruction. source_location ().get_comment ();
222+ const irep_idt &comment = source_location ().get_comment ();
230223 if (!comment.empty ())
231224 out << " // " << comment;
232225 }
@@ -251,49 +244,48 @@ std::ostream &goto_programt::output_instruction(
251244
252245 {
253246 const irept::subt &exception_list =
254- instruction. code ().find (ID_exception_list).get_sub ();
247+ code ().find (ID_exception_list).get_sub ();
255248
256249 for (const auto &ex : exception_list)
257250 out << " " << ex.id ();
258251 }
259252
260- if (instruction. code ().operands ().size () == 1 )
261- out << " : " << format (instruction. code ().op0 ());
253+ if (code ().operands ().size () == 1 )
254+ out << " : " << format (code ().op0 ());
262255
263256 out << ' \n ' ;
264257 break ;
265258
266259 case CATCH:
267260 {
268- if (instruction. code ().get_statement () == ID_exception_landingpad)
261+ if (code ().get_statement () == ID_exception_landingpad)
269262 {
270- const auto &landingpad = to_code_landingpad (instruction. code ());
263+ const auto &landingpad = to_code_landingpad (code ());
271264 out << " EXCEPTION LANDING PAD (" << format (landingpad.catch_expr ().type ())
272265 << ' ' << format (landingpad.catch_expr ()) << " )" ;
273266 }
274- else if (instruction. code ().get_statement () == ID_push_catch)
267+ else if (code ().get_statement () == ID_push_catch)
275268 {
276269 out << " CATCH-PUSH " ;
277270
278271 unsigned i=0 ;
279272 const irept::subt &exception_list =
280- instruction. code ().find (ID_exception_list).get_sub ();
273+ code ().find (ID_exception_list).get_sub ();
281274 DATA_INVARIANT (
282- instruction. targets .size () == exception_list.size (),
275+ targets.size () == exception_list.size (),
283276 " unexpected discrepancy between sizes of instruction"
284277 " 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 ();
288280 gt_it++, i++)
289281 {
290- if (gt_it!=instruction. targets .begin ())
282+ if (gt_it != targets.begin ())
291283 out << " , " ;
292284 out << exception_list[i].id () << " ->"
293285 << (*gt_it)->target_number ;
294286 }
295287 }
296- else if (instruction. code ().get_statement () == ID_pop_catch)
288+ else if (code ().get_statement () == ID_pop_catch)
297289 {
298290 out << " CATCH-POP" ;
299291 }
@@ -315,9 +307,7 @@ std::ostream &goto_programt::output_instruction(
315307 break ;
316308
317309 case START_THREAD:
318- out << " START THREAD "
319- << instruction.get_target ()->target_number
320- << ' \n ' ;
310+ out << " START THREAD " << get_target ()->target_number << ' \n ' ;
321311 break ;
322312
323313 case END_THREAD:
@@ -638,13 +628,12 @@ void goto_programt::update()
638628
639629std::ostream &goto_programt::output (
640630 const namespacet &ns,
641- const irep_idt &identifier,
642631 std::ostream &out) const
643632{
644633 // output program
645634
646635 for (const auto &instruction : instructions)
647- output_instruction (ns, identifier, out, instruction );
636+ instruction. output (ns, out);
648637
649638 return out;
650639}
0 commit comments