Skip to content

Commit 8c43a92

Browse files
committed
use ebmc_languaget API in ebmc_parse_optionst
This replaces the direct call to get_transition_system(...) by a call to an implementation of ebmc_languaget, which wraps get_transition_system.
1 parent 0937478 commit 8c43a92

File tree

2 files changed

+60
-23
lines changed

2 files changed

+60
-23
lines changed

src/ebmc/ebmc_language.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ Author: Daniel Kroening, [email protected]
1313
#define EBMC_LANGUAGE_H
1414

1515
#include <iosfwd>
16+
#include <optional>
1617

1718
class cmdlinet;
1819
class message_handlert;
@@ -29,11 +30,9 @@ class ebmc_languaget
2930

3031
virtual ~ebmc_languaget();
3132

32-
/// produce diagnostic output as specified on the command line
33-
virtual void diagnostics() = 0;
34-
35-
/// produce the transition system, and return it
36-
virtual transition_systemt transition_system() = 0;
33+
/// Produce the transition system, and return it;
34+
/// returns {} when diagnostic output was produced instead.
35+
virtual std::optional<transition_systemt> transition_system() = 0;
3736

3837
protected:
3938
cmdlinet &cmdline;

src/ebmc/ebmc_parse_options.cpp

Lines changed: 56 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Author: Daniel Kroening, [email protected]
1818
#include "diatest.h"
1919
#include "ebmc_base.h"
2020
#include "ebmc_error.h"
21+
#include "ebmc_language.h"
2122
#include "ebmc_version.h"
2223
#include "format_hooks.h"
2324
#include "instrument_buechi.h"
@@ -46,6 +47,52 @@ Author: Daniel Kroening, [email protected]
4647
#include "coverage/coverage.h"
4748
#endif
4849

50+
class ebmc_languagest : public ebmc_languaget
51+
{
52+
public:
53+
ebmc_languagest(cmdlinet &_cmdline, message_handlert &_message_handler)
54+
: ebmc_languaget{_cmdline, _message_handler}
55+
{
56+
}
57+
58+
std::optional<transition_systemt> transition_system() override
59+
{
60+
if(cmdline.isset("preprocess"))
61+
{
62+
preprocess(cmdline, message_handler);
63+
return {};
64+
}
65+
66+
if(cmdline.isset("show-parse"))
67+
{
68+
show_parse(cmdline, message_handler);
69+
return {};
70+
}
71+
72+
if(
73+
cmdline.isset("show-modules") || cmdline.isset("modules-xml") ||
74+
cmdline.isset("json-modules"))
75+
{
76+
show_modules(cmdline, message_handler);
77+
return {};
78+
}
79+
80+
if(cmdline.isset("show-module-hierarchy"))
81+
{
82+
show_module_hierarchy(cmdline, message_handler);
83+
return {};
84+
}
85+
86+
if(cmdline.isset("show-symbol-table"))
87+
{
88+
show_symbol_table(cmdline, message_handler);
89+
return {};
90+
}
91+
92+
return get_transition_system(cmdline, message_handler);
93+
}
94+
};
95+
4996
/*******************************************************************\
5097
5198
Function: ebmc_parse_optionst::doit
@@ -107,23 +154,6 @@ int ebmc_parse_optionst::doit()
107154
return 0;
108155
}
109156

110-
if(cmdline.isset("preprocess"))
111-
return preprocess(cmdline, ui_message_handler);
112-
113-
if(cmdline.isset("show-parse"))
114-
return show_parse(cmdline, ui_message_handler);
115-
116-
if(
117-
cmdline.isset("show-modules") || cmdline.isset("modules-xml") ||
118-
cmdline.isset("json-modules"))
119-
return show_modules(cmdline, ui_message_handler);
120-
121-
if(cmdline.isset("show-module-hierarchy"))
122-
return show_module_hierarchy(cmdline, ui_message_handler);
123-
124-
if(cmdline.isset("show-symbol-table"))
125-
return show_symbol_table(cmdline, ui_message_handler);
126-
127157
if(cmdline.isset("coverage"))
128158
{
129159
throw ebmc_errort() << "This option is currently disabled";
@@ -207,7 +237,15 @@ int ebmc_parse_optionst::doit()
207237
}
208238

209239
// get the transition system
210-
auto transition_system = get_transition_system(cmdline, ui_message_handler);
240+
ebmc_languagest ebmc_languages{cmdline, ui_message_handler};
241+
242+
auto transition_system_opt = ebmc_languages.transition_system();
243+
244+
// Did we produce diagnostics instead?
245+
if(!transition_system_opt.has_value())
246+
return 0;
247+
248+
auto &transition_system = transition_system_opt.value();
211249

212250
// get the properties
213251
auto properties = ebmc_propertiest::from_command_line(

0 commit comments

Comments
 (0)