-
Notifications
You must be signed in to change notification settings - Fork 273
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TG-634 Functional style for string refinement #1404
Changes from all commits
f99c8ff
c5fa708
bf47f81
317c1c6
150bab1
9fff116
2b2a841
8e69d6d
cfb47db
01b8301
bcd6111
666c146
2eed573
65ad3db
e5e1ff4
a4c8cf5
918297c
78303df
229568a
7f11ccf
f5c1b29
1531f0e
d03866d
bee20f1
9b8a025
b544a4b
751e8f5
05d5a9b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,11 +20,9 @@ Author: Daniel Kroening, [email protected] | |
|
||
class bv_refinementt:public bv_pointerst | ||
{ | ||
public: | ||
struct infot | ||
private: | ||
struct configt | ||
{ | ||
const namespacet *ns=nullptr; | ||
propt *prop=nullptr; | ||
ui_message_handlert::uit ui=ui_message_handlert::uit::PLAIN; | ||
/// Max number of times we refine a formula node | ||
unsigned max_node_refinement=5; | ||
|
@@ -33,6 +31,12 @@ class bv_refinementt:public bv_pointerst | |
/// Enable arithmetic refinement | ||
bool refine_arithmetic=true; | ||
}; | ||
public: | ||
struct infot:public configt | ||
{ | ||
const namespacet *ns=nullptr; | ||
propt *prop=nullptr; | ||
}; | ||
|
||
explicit bv_refinementt(const infot &info); | ||
|
||
|
@@ -103,18 +107,12 @@ class bv_refinementt:public bv_pointerst | |
|
||
// MEMBERS | ||
|
||
// Maximum number of times we refine a formula node | ||
const unsigned max_node_refinement; | ||
// Refinement toggles | ||
const bool do_array_refinement; | ||
const bool do_arithmetic_refinement; | ||
bool progress; | ||
std::vector<approximationt> approximations; | ||
bvt parent_assumptions; | ||
|
||
protected: | ||
// use gui format | ||
ui_message_handlert::uit ui; | ||
configt config_; | ||
}; | ||
|
||
#endif // CPROVER_SOLVERS_REFINEMENT_BV_REFINEMENT_H |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,11 +14,8 @@ Author: Daniel Kroening, [email protected] | |
|
||
bv_refinementt::bv_refinementt(const infot &info): | ||
bv_pointerst(*info.ns, *info.prop), | ||
max_node_refinement(info.max_node_refinement), | ||
do_array_refinement(info.refine_arrays), | ||
do_arithmetic_refinement(info.refine_arithmetic), | ||
progress(false), | ||
ui(info.ui) | ||
config_(info) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The underscore seems unnecessary. |
||
{ | ||
// check features we need | ||
PRECONDITION(prop.has_set_assumptions()); | ||
|
@@ -44,11 +41,11 @@ decision_proceduret::resultt bv_refinementt::dec_solve() | |
status() << "BV-Refinement: iteration " << iteration << eom; | ||
|
||
// output the very same information in a structured fashion | ||
if(ui==ui_message_handlert::uit::XML_UI) | ||
if(config_.ui==ui_message_handlert::uit::XML_UI) | ||
{ | ||
xmlt xml("refinement-iteration"); | ||
xml.data=std::to_string(iteration); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (improvement) replace cout by There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replaced. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does this not require a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think it's relevant, there was no preprocessing before. |
||
std::cout << xml << '\n'; | ||
status() << xml << '\n'; | ||
} | ||
|
||
switch(prop_solve()) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,10 +28,10 @@ Author: Romain Brenguier, [email protected] | |
#include <util/ssa_expr.h> | ||
|
||
string_constraint_generatort::string_constraint_generatort( | ||
const string_constraint_generatort::infot& info): | ||
const string_constraint_generatort::infot& info, const namespacet& ns): | ||
max_string_length(info.string_max_length), | ||
m_force_printable_characters(info.string_printable), | ||
m_ns(*info.ns) { } | ||
m_ns(ns) { } | ||
|
||
const std::vector<exprt> &string_constraint_generatort::get_axioms() const | ||
{ | ||
|
@@ -628,3 +628,19 @@ exprt string_constraint_generatort::add_axioms_for_to_char_array( | |
string_exprt str=get_string_expr(args(f, 1)[0]); | ||
return str.content(); | ||
} | ||
|
||
exprt string_constraint_generatort::substitute_function_applications( | ||
const exprt &expr) | ||
{ | ||
exprt copy=expr; | ||
for(exprt &operand : copy.operands()) | ||
operand=substitute_function_applications(exprt(operand)); | ||
|
||
if(copy.id()==ID_function_application) | ||
{ | ||
function_application_exprt f=to_function_application_expr(copy); | ||
return this->add_axioms_for_function_application(f); | ||
} | ||
|
||
return copy; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Making this hold a reference would be better instead of reintroducing pointers...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the solution to the problem of functions requiring too many arguments. Either we'd use this (essence pattern) or the builder pattern. Both of which use null pointers to hold the default value for a reference (but builder is more verbose, restricted to constructors only and not composable).
The only solution that allows usage of both arguments and references at the same time, are C++20 named arguments.