Skip to content

Commit 8f8b83a

Browse files
Move cbmc_solvers as solver_factory to goto-checker module
This is the first step of introducing the goto-checker module which will hold the language-agnostic BMC classes.
1 parent f44baa8 commit 8f8b83a

File tree

1 file changed

+80
-23
lines changed

1 file changed

+80
-23
lines changed

src/goto-checker/solver_factory.h

Lines changed: 80 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -12,16 +12,18 @@ Author: Daniel Kroening, Peter Schrammel
1212
#ifndef CPROVER_GOTO_CHECKER_SOLVER_FACTORY_H
1313
#define CPROVER_GOTO_CHECKER_SOLVER_FACTORY_H
1414

15+
#include <list>
16+
#include <map>
1517
#include <memory>
1618

17-
#include <solvers/smt2/smt2_dec.h>
19+
#include <util/options.h>
1820

19-
class message_handlert;
20-
class namespacet;
21-
class optionst;
22-
class propt;
23-
class prop_convt;
24-
class symbol_tablet;
21+
#include <solvers/prop/prop.h>
22+
#include <solvers/prop/prop_conv.h>
23+
#include <solvers/sat/cnf.h>
24+
#include <solvers/sat/satcheck.h>
25+
#include <solvers/smt2/smt2_dec.h>
26+
#include <goto-symex/symex_target_equation.h>
2527

2628
class solver_factoryt
2729
{
@@ -30,35 +32,90 @@ class solver_factoryt
3032
const optionst &_options,
3133
const symbol_tablet &_symbol_table,
3234
message_handlert &_message_handler,
33-
bool _output_xml_in_refinement);
35+
bool _output_xml_in_refinement)
36+
: options(_options),
37+
symbol_table(_symbol_table),
38+
ns(_symbol_table),
39+
message_handler(_message_handler),
40+
output_xml_in_refinement(_output_xml_in_refinement)
41+
{
42+
}
3443

3544
// The solver class,
3645
// which owns a variety of allocated objects.
3746
class solvert
3847
{
3948
public:
40-
solvert() = default;
41-
explicit solvert(std::unique_ptr<prop_convt> p);
42-
solvert(std::unique_ptr<prop_convt> p1, std::unique_ptr<propt> p2);
43-
solvert(std::unique_ptr<prop_convt> p1, std::unique_ptr<std::ofstream> p2);
44-
45-
prop_convt &prop_conv() const;
46-
propt &prop() const;
47-
48-
void set_prop_conv(std::unique_ptr<prop_convt> p);
49-
void set_prop(std::unique_ptr<propt> p);
50-
void set_ofstream(std::unique_ptr<std::ofstream> p);
49+
solvert()
50+
{
51+
}
52+
53+
explicit solvert(std::unique_ptr<prop_convt> p):prop_conv_ptr(std::move(p))
54+
{
55+
}
56+
57+
solvert(std::unique_ptr<prop_convt> p1, std::unique_ptr<propt> p2):
58+
prop_ptr(std::move(p2)),
59+
prop_conv_ptr(std::move(p1))
60+
{
61+
}
62+
63+
solvert(std::unique_ptr<prop_convt> p1, std::unique_ptr<std::ofstream> p2):
64+
ofstream_ptr(std::move(p2)),
65+
prop_conv_ptr(std::move(p1))
66+
{
67+
}
68+
69+
prop_convt &prop_conv() const
70+
{
71+
PRECONDITION(prop_conv_ptr != nullptr);
72+
return *prop_conv_ptr;
73+
}
74+
75+
propt &prop() const
76+
{
77+
PRECONDITION(prop_ptr != nullptr);
78+
return *prop_ptr;
79+
}
80+
81+
void set_prop_conv(std::unique_ptr<prop_convt> p)
82+
{
83+
prop_conv_ptr=std::move(p);
84+
}
85+
86+
void set_prop(std::unique_ptr<propt> p)
87+
{
88+
prop_ptr=std::move(p);
89+
}
90+
91+
void set_ofstream(std::unique_ptr<std::ofstream> p)
92+
{
93+
ofstream_ptr=std::move(p);
94+
}
5195

5296
// the objects are deleted in the opposite order they appear below
5397
std::unique_ptr<std::ofstream> ofstream_ptr;
5498
std::unique_ptr<propt> prop_ptr;
5599
std::unique_ptr<prop_convt> prop_conv_ptr;
56100
};
57101

58-
/// Returns a solvert object
59-
virtual std::unique_ptr<solvert> get_solver();
60-
61-
virtual ~solver_factoryt() = default;
102+
// returns a solvert object
103+
virtual std::unique_ptr<solvert> get_solver()
104+
{
105+
if(options.get_bool_option("dimacs"))
106+
return get_dimacs();
107+
if(options.get_bool_option("refine"))
108+
return get_bv_refinement();
109+
else if(options.get_bool_option("refine-strings"))
110+
return get_string_refinement();
111+
if(options.get_bool_option("smt2"))
112+
return get_smt2(get_smt2_solver_type());
113+
return get_default();
114+
}
115+
116+
virtual ~solver_factoryt()
117+
{
118+
}
62119

63120
protected:
64121
const optionst &options;

0 commit comments

Comments
 (0)