@@ -29,11 +29,6 @@ Author: Daniel Kroening, kroening@kroening.com
2929
3030#include < langapi/language_util.h>
3131
32- std::ostream &goto_programt::output (std::ostream &out) const
33- {
34- return output (namespacet (symbol_tablet ()), irep_idt (), out);
35- }
36-
3732goto_programt::instructiont goto_programt::make_incomplete_goto (
3833 const code_gotot &_code,
3934 const source_locationt &l)
@@ -48,67 +43,57 @@ goto_programt::instructiont goto_programt::make_incomplete_goto(
4843// / // Labels: {list-of-labels}
4944// / {representation of the instruction}
5045// / ```
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
5446// / \param out: the stream to write the goto string to
55- // / \param instruction: the instruction to convert
5647// / \return Appends to out a two line representation of the instruction
57- std::ostream &goto_programt::output_instruction (
58- const namespacet &ns,
59- const irep_idt &identifier,
60- std::ostream &out,
61- const instructiont &instruction) const
48+ std::ostream &goto_programt::instructiont::output (std::ostream &out) const
6249{
63- out << " // " << instruction. location_number << " " ;
50+ out << " // " << location_number << " " ;
6451
65- if (!instruction. source_location ().is_nil ())
66- out << instruction. source_location ().as_string ();
52+ if (!source_location ().is_nil ())
53+ out << source_location ().as_string ();
6754 else
6855 out << " no location" ;
6956
7057 out << " \n " ;
7158
72- if (!instruction. labels .empty ())
59+ if (!labels.empty ())
7360 {
7461 out << " // Labels:" ;
75- for (const auto &label : instruction. labels )
62+ for (const auto &label : labels)
7663 out << " " << label;
7764
7865 out << ' \n ' ;
7966 }
8067
81- if (instruction. is_target ())
82- out << std::setw (6 ) << instruction. target_number << " : " ;
68+ if (is_target ())
69+ out << std::setw (6 ) << target_number << " : " ;
8370 else
8471 out << " " ;
8572
86- switch (instruction. type ())
73+ switch (type ())
8774 {
8875 case NO_INSTRUCTION_TYPE:
8976 out << " NO INSTRUCTION TYPE SET" << ' \n ' ;
9077 break ;
9178
9279 case GOTO:
9380 case INCOMPLETE_GOTO:
94- if (!instruction. condition ().is_true ())
81+ if (!condition ().is_true ())
9582 {
96- out << " IF " << format (instruction. condition ()) << " THEN " ;
83+ out << " IF " << format (condition ()) << " THEN " ;
9784 }
9885
9986 out << " GOTO " ;
10087
101- if (instruction. is_incomplete_goto ())
88+ if (is_incomplete_goto ())
10289 {
10390 out << " (incomplete)" ;
10491 }
10592 else
10693 {
107- for (auto gt_it = instruction.targets .begin ();
108- gt_it != instruction.targets .end ();
109- gt_it++)
94+ for (auto gt_it = targets.begin (); gt_it != targets.end (); gt_it++)
11095 {
111- if (gt_it != instruction. targets .begin ())
96+ if (gt_it != targets.begin ())
11297 out << " , " ;
11398 out << (*gt_it)->target_number ;
11499 }
@@ -118,9 +103,9 @@ std::ostream &goto_programt::output_instruction(
118103 break ;
119104
120105 case OTHER:
121- if (instruction. get_other ().id () == ID_code)
106+ if (get_other ().id () == ID_code)
122107 {
123- const auto &code = instruction. get_other ();
108+ const auto &code = get_other ();
124109 if (code.get_statement () == ID_array_copy)
125110 {
126111 out << " ARRAY_COPY " << format (code.op0 ()) << ' ' << format (code.op1 ())
@@ -174,31 +159,31 @@ std::ostream &goto_programt::output_instruction(
174159 // fallthrough
175160 }
176161
177- out << " OTHER " << format (instruction. get_other ()) << ' \n ' ;
162+ out << " OTHER " << format (get_other ()) << ' \n ' ;
178163 break ;
179164
180165 case SET_RETURN_VALUE:
181- out << " SET RETURN VALUE " << format (instruction. return_value ()) << ' \n ' ;
166+ out << " SET RETURN VALUE " << format (return_value ()) << ' \n ' ;
182167 break ;
183168
184169 case DECL:
185- out << " DECL " << format (instruction. decl_symbol ()) << " : "
186- << format (instruction. decl_symbol ().type ()) << ' \n ' ;
170+ out << " DECL " << format (decl_symbol ()) << " : "
171+ << format (decl_symbol ().type ()) << ' \n ' ;
187172 break ;
188173
189174 case DEAD:
190- out << " DEAD " << format (instruction. dead_symbol ()) << ' \n ' ;
175+ out << " DEAD " << format (dead_symbol ()) << ' \n ' ;
191176 break ;
192177
193178 case FUNCTION_CALL:
194179 out << " CALL " ;
195180 {
196- if (instruction. call_lhs ().is_not_nil ())
197- out << format (instruction. call_lhs ()) << " := " ;
198- out << format (instruction. call_function ());
181+ if (call_lhs ().is_not_nil ())
182+ out << format (call_lhs ()) << " := " ;
183+ out << format (call_function ());
199184 out << ' (' ;
200185 bool first = true ;
201- for (const auto &argument : instruction. call_arguments ())
186+ for (const auto &argument : call_arguments ())
202187 {
203188 if (first)
204189 first = false ;
@@ -212,21 +197,21 @@ std::ostream &goto_programt::output_instruction(
212197 break ;
213198
214199 case ASSIGN:
215- out << " ASSIGN " << format (instruction. assign_lhs ())
216- << " := " << format (instruction. assign_rhs ()) << ' \n ' ;
200+ out << " ASSIGN " << format (assign_lhs ()) << " := " << format ( assign_rhs ())
201+ << ' \n ' ;
217202 break ;
218203
219204 case ASSUME:
220205 case ASSERT:
221- if (instruction. is_assume ())
206+ if (is_assume ())
222207 out << " ASSUME " ;
223208 else
224209 out << " ASSERT " ;
225210
226211 {
227- out << format (instruction. condition ());
212+ out << format (condition ());
228213
229- const irep_idt &comment = instruction. source_location ().get_comment ();
214+ const irep_idt &comment = source_location ().get_comment ();
230215 if (!comment.empty ())
231216 out << " // " << comment;
232217 }
@@ -251,49 +236,48 @@ std::ostream &goto_programt::output_instruction(
251236
252237 {
253238 const irept::subt &exception_list =
254- instruction. code ().find (ID_exception_list).get_sub ();
239+ code ().find (ID_exception_list).get_sub ();
255240
256241 for (const auto &ex : exception_list)
257242 out << " " << ex.id ();
258243 }
259244
260- if (instruction. code ().operands ().size () == 1 )
261- out << " : " << format (instruction. code ().op0 ());
245+ if (code ().operands ().size () == 1 )
246+ out << " : " << format (code ().op0 ());
262247
263248 out << ' \n ' ;
264249 break ;
265250
266251 case CATCH:
267252 {
268- if (instruction. code ().get_statement () == ID_exception_landingpad)
253+ if (code ().get_statement () == ID_exception_landingpad)
269254 {
270- const auto &landingpad = to_code_landingpad (instruction. code ());
255+ const auto &landingpad = to_code_landingpad (code ());
271256 out << " EXCEPTION LANDING PAD (" << format (landingpad.catch_expr ().type ())
272257 << ' ' << format (landingpad.catch_expr ()) << " )" ;
273258 }
274- else if (instruction. code ().get_statement () == ID_push_catch)
259+ else if (code ().get_statement () == ID_push_catch)
275260 {
276261 out << " CATCH-PUSH " ;
277262
278263 unsigned i=0 ;
279264 const irept::subt &exception_list =
280- instruction. code ().find (ID_exception_list).get_sub ();
265+ code ().find (ID_exception_list).get_sub ();
281266 DATA_INVARIANT (
282- instruction. targets .size () == exception_list.size (),
267+ targets.size () == exception_list.size (),
283268 " unexpected discrepancy between sizes of instruction"
284269 " targets and exception list" );
285- for (instructiont::targetst::const_iterator
286- gt_it=instruction.targets .begin ();
287- gt_it!=instruction.targets .end ();
270+ for (instructiont::targetst::const_iterator gt_it = targets.begin ();
271+ gt_it != targets.end ();
288272 gt_it++, i++)
289273 {
290- if (gt_it!=instruction. targets .begin ())
274+ if (gt_it != targets.begin ())
291275 out << " , " ;
292276 out << exception_list[i].id () << " ->"
293277 << (*gt_it)->target_number ;
294278 }
295279 }
296- else if (instruction. code ().get_statement () == ID_pop_catch)
280+ else if (code ().get_statement () == ID_pop_catch)
297281 {
298282 out << " CATCH-POP" ;
299283 }
@@ -315,9 +299,7 @@ std::ostream &goto_programt::output_instruction(
315299 break ;
316300
317301 case START_THREAD:
318- out << " START THREAD "
319- << instruction.get_target ()->target_number
320- << ' \n ' ;
302+ out << " START THREAD " << get_target ()->target_number << ' \n ' ;
321303 break ;
322304
323305 case END_THREAD:
@@ -636,15 +618,12 @@ void goto_programt::update()
636618 compute_loop_numbers ();
637619}
638620
639- std::ostream &goto_programt::output (
640- const namespacet &ns,
641- const irep_idt &identifier,
642- std::ostream &out) const
621+ std::ostream &goto_programt::output (std::ostream &out) const
643622{
644- // output program
623+ // output the program
645624
646625 for (const auto &instruction : instructions)
647- output_instruction (ns, identifier, out, instruction );
626+ instruction. output ( out);
648627
649628 return out;
650629}
0 commit comments