Skip to content

Commit

Permalink
Correct insert builtin function construction
Browse files Browse the repository at this point in the history
The arguments were not in the right order.
We also need to seperate construction of concatenation since it was
using insertion.
  • Loading branch information
romainbrenguier committed Mar 14, 2018
1 parent d0a8868 commit cb72bb7
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
16 changes: 15 additions & 1 deletion src/solvers/refinement/string_refinement_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,21 @@ string_insertion_builtin_functiont::string_insertion_builtin_functiont(
const std::vector<exprt> &fun_args,
array_poolt &array_pool)
{
PRECONDITION(fun_args.size() > 3);
PRECONDITION(fun_args.size() > 4);
const auto arg1 = expr_checked_cast<struct_exprt>(fun_args[2]);
input1 = array_pool.find(arg1.op1(), arg1.op0());
const auto arg2 = expr_checked_cast<struct_exprt>(fun_args[4]);
input2 = array_pool.find(arg2.op1(), arg2.op0());
result = array_pool.find(fun_args[1], fun_args[0]);
args.push_back(fun_args[3]);
args.insert(args.end(), fun_args.begin() + 5, fun_args.end());
}

string_concatenation_builtin_functiont::string_concatenation_builtin_functiont(
const std::vector<exprt> &fun_args,
array_poolt &array_pool)
{
PRECONDITION(fun_args.size() >= 4 && fun_args.size() <= 6);
const auto arg1 = expr_checked_cast<struct_exprt>(fun_args[2]);
input1 = array_pool.find(arg1.op1(), arg1.op0());
const auto arg2 = expr_checked_cast<struct_exprt>(fun_args[3]);
Expand Down
8 changes: 4 additions & 4 deletions src/solvers/refinement/string_refinement_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,9 @@ class string_insertion_builtin_functiont : public string_builtin_functiont

optionalt<exprt>
eval(const std::function<exprt(const exprt &)> &get_value) const override;

protected:
string_insertion_builtin_functiont() = default;
};

class string_concatenation_builtin_functiont final
Expand All @@ -254,10 +257,7 @@ class string_concatenation_builtin_functiont final
public:
string_concatenation_builtin_functiont(
const std::vector<exprt> &fun_args,
array_poolt &array_pool)
: string_insertion_builtin_functiont(fun_args, array_pool)
{
}
array_poolt &array_pool);

std::vector<mp_integer> eval(
const std::vector<mp_integer> &input1_value,
Expand Down

0 comments on commit cb72bb7

Please sign in to comment.