Skip to content

Commit 8a7e7f3

Browse files
committed
signature of show_trans* family of functions
The show_trans* family of functions now 1. gets the transition system as argument, as opposed to using ebmc_baset to create it; 2. gets the output stream as argument, as opposed to creating it itself.
1 parent 2728d52 commit 8a7e7f3

File tree

3 files changed

+70
-119
lines changed

3 files changed

+70
-119
lines changed

src/ebmc/ebmc_parse_options.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -202,17 +202,30 @@ int ebmc_parse_optionst::doit()
202202
// return do_two_phase_induction();
203203
}
204204

205+
// get the transition system
206+
auto transition_system = get_transition_system(cmdline, ui_message_handler);
207+
205208
if(cmdline.isset("show-trans"))
206-
return show_trans(cmdline, ui_message_handler);
209+
{
210+
auto filename = cmdline.value_opt("outfile").value_or("-");
211+
output_filet output_file{filename};
212+
return show_trans(transition_system, output_file.stream());
213+
}
207214

208215
if(cmdline.isset("verilog-rtl"))
209-
return show_trans_verilog_rtl(cmdline, ui_message_handler);
216+
{
217+
auto filename = cmdline.value_opt("outfile").value_or("-");
218+
output_filet output_file{filename};
219+
return show_trans_verilog_rtl(transition_system, output_file.stream());
220+
}
210221

211222
if(cmdline.isset("verilog-netlist"))
212-
return show_trans_verilog_netlist(cmdline, ui_message_handler);
213-
214-
// get the transition system
215-
auto transition_system = get_transition_system(cmdline, ui_message_handler);
223+
{
224+
auto filename = cmdline.value_opt("outfile").value_or("-");
225+
output_filet output_file{filename};
226+
return show_trans_verilog_netlist(
227+
transition_system, output_file.stream());
228+
}
216229

217230
// get the properties
218231
auto properties = ebmc_propertiest::from_command_line(

src/ebmc/show_trans.cpp

Lines changed: 45 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ Author: Daniel Kroening, [email protected]
88

99
#include "show_trans.h"
1010

11+
#include <util/cout_message.h>
12+
1113
#include <verilog/expr2verilog.h>
1214

1315
#include "ebmc_base.h"
@@ -25,23 +27,21 @@ Author: Daniel Kroening, [email protected]
2527
2628
\*******************************************************************/
2729

28-
class show_transt:public ebmc_baset
30+
class show_transt
2931
{
3032
public:
31-
show_transt(
32-
const cmdlinet &cmdline,
33-
ui_message_handlert &ui_message_handler):
34-
ebmc_baset(cmdline, ui_message_handler)
33+
explicit show_transt(const transition_systemt &_transition_system)
34+
: transition_system(_transition_system)
3535
{
3636
}
3737

38-
int show_trans_verilog_rtl();
39-
int show_trans_verilog_netlist();
40-
int show_trans();
38+
int show_trans_verilog_rtl(std::ostream &);
39+
int show_trans_verilog_netlist(std::ostream &);
40+
int show_trans(std::ostream &);
4141

4242
protected:
43-
int show_trans_verilog_rtl(std::ostream &out);
44-
int show_trans_verilog_netlist(std::ostream &out);
43+
const transition_systemt &transition_system;
44+
4545
void verilog_header(std::ostream &out, const std::string &desc);
4646
void
4747
print_verilog_constraints(const exprt &, const namespacet &, std::ostream &);
@@ -60,11 +60,11 @@ Function: show_trans_verilog_netlist
6060
\*******************************************************************/
6161

6262
int show_trans_verilog_netlist(
63-
const cmdlinet &cmdline,
64-
ui_message_handlert &ui_message_handler)
63+
const transition_systemt &transition_system,
64+
std::ostream &out)
6565
{
66-
show_transt show_trans(cmdline, ui_message_handler);
67-
return show_trans.show_trans_verilog_netlist();
66+
show_transt show_trans(transition_system);
67+
return show_trans.show_trans_verilog_netlist(out);
6868
}
6969

7070
/*******************************************************************\
@@ -80,11 +80,11 @@ Function: show_trans_verilog_rtl
8080
\*******************************************************************/
8181

8282
int show_trans_verilog_rtl(
83-
const cmdlinet &cmdline,
84-
ui_message_handlert &ui_message_handler)
83+
const transition_systemt &transition_system,
84+
std::ostream &out)
8585
{
86-
show_transt show_trans(cmdline, ui_message_handler);
87-
return show_trans.show_trans_verilog_rtl();
86+
show_transt show_trans(transition_system);
87+
return show_trans.show_trans_verilog_rtl(out);
8888
}
8989

9090
/*******************************************************************\
@@ -101,8 +101,10 @@ Function: show_transt::show_trans_verilog_netlist
101101

102102
int show_transt::show_trans_verilog_netlist(std::ostream &out)
103103
{
104+
console_message_handlert message_handler;
105+
104106
output_verilog_netlistt output_verilog(
105-
transition_system.symbol_table, out, message.get_message_handler());
107+
transition_system.symbol_table, out, message_handler);
106108

107109
try
108110
{
@@ -145,8 +147,10 @@ Function: show_transt::show_trans_verilog_rtl
145147

146148
int show_transt::show_trans_verilog_rtl(std::ostream &out)
147149
{
150+
console_message_handlert message_handler;
151+
148152
output_verilog_rtlt output_verilog(
149-
transition_system.symbol_table, out, message.get_message_handler());
153+
transition_system.symbol_table, out, message_handler);
150154

151155
try
152156
{
@@ -177,6 +181,24 @@ int show_transt::show_trans_verilog_rtl(std::ostream &out)
177181

178182
/*******************************************************************\
179183
184+
Function: show_transt::show_trans
185+
186+
Inputs:
187+
188+
Outputs:
189+
190+
Purpose:
191+
192+
\*******************************************************************/
193+
194+
int show_transt::show_trans(std::ostream &out)
195+
{
196+
transition_system.output(out);
197+
return 0;
198+
}
199+
200+
/*******************************************************************\
201+
180202
Function: show_transt::verilog_header
181203
182204
Inputs:
@@ -226,86 +248,6 @@ void show_transt::print_verilog_constraints(
226248

227249
/*******************************************************************\
228250
229-
Function: show_transt::show_trans
230-
231-
Inputs:
232-
233-
Outputs:
234-
235-
Purpose:
236-
237-
\*******************************************************************/
238-
239-
int show_transt::show_trans()
240-
{
241-
transition_system =
242-
get_transition_system(cmdline, message.get_message_handler());
243-
244-
transition_system.output(std::cout);
245-
246-
return 0;
247-
}
248-
249-
/*******************************************************************\
250-
251-
Function: show_transt::show_trans_verilog_rtl
252-
253-
Inputs:
254-
255-
Outputs:
256-
257-
Purpose:
258-
259-
\*******************************************************************/
260-
261-
int show_transt::show_trans_verilog_rtl()
262-
{
263-
transition_system =
264-
get_transition_system(cmdline, message.get_message_handler());
265-
266-
if(cmdline.isset("outfile"))
267-
{
268-
const std::string filename=cmdline.get_value("outfile");
269-
auto outfile = output_filet{filename};
270-
show_trans_verilog_rtl(outfile.stream());
271-
}
272-
else
273-
show_trans_verilog_rtl(std::cout);
274-
275-
return 0;
276-
}
277-
278-
/*******************************************************************\
279-
280-
Function: show_transt::show_trans_verilog_netlist
281-
282-
Inputs:
283-
284-
Outputs:
285-
286-
Purpose:
287-
288-
\*******************************************************************/
289-
290-
int show_transt::show_trans_verilog_netlist()
291-
{
292-
transition_system =
293-
get_transition_system(cmdline, message.get_message_handler());
294-
295-
if(cmdline.isset("outfile"))
296-
{
297-
const std::string filename=cmdline.get_value("outfile");
298-
auto outfile = output_filet{filename};
299-
show_trans_verilog_netlist(outfile.stream());
300-
}
301-
else
302-
show_trans_verilog_netlist(std::cout);
303-
304-
return 0;
305-
}
306-
307-
/*******************************************************************\
308-
309251
Function: show_trans
310252
311253
Inputs:
@@ -316,11 +258,8 @@ Function: show_trans
316258
317259
\*******************************************************************/
318260

319-
int show_trans(
320-
const cmdlinet &cmdline,
321-
ui_message_handlert &ui_message_handler)
261+
int show_trans(const transition_systemt &transition_system, std::ostream &out)
322262
{
323-
show_transt show_trans(cmdline, ui_message_handler);
324-
return show_trans.show_trans();
263+
show_transt show_trans(transition_system);
264+
return show_trans.show_trans(out);
325265
}
326-

src/ebmc/show_trans.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@ Author: Daniel Kroening, [email protected]
99
#ifndef CPROVER_EBMC_SHOW_TRANS_H
1010
#define CPROVER_EBMC_SHOW_TRANS_H
1111

12-
#include <util/cmdline.h>
13-
#include <util/ui_message.h>
12+
#include "transition_system.h"
1413

15-
int show_trans_verilog_rtl(const cmdlinet &, ui_message_handlert &);
16-
int show_trans_verilog_netlist(const cmdlinet &, ui_message_handlert &);
17-
int show_trans_smv_netlist(const cmdlinet &, ui_message_handlert &);
18-
int show_trans(const cmdlinet &, ui_message_handlert &);
14+
int show_trans_verilog_rtl(const transition_systemt &, std::ostream &);
15+
int show_trans_verilog_netlist(const transition_systemt &, std::ostream &);
16+
int show_trans_smv_netlist(const transition_systemt &, std::ostream &);
17+
int show_trans(const transition_systemt &, std::ostream &);
1918

20-
#endif
19+
#endif // CPROVER_EBMC_SHOW_TRANS_H

0 commit comments

Comments
 (0)