Skip to content

Commit

Permalink
Add name method to builtin functions
Browse files Browse the repository at this point in the history
This is useful to make the dot output more informative.
  • Loading branch information
romainbrenguier committed Mar 13, 2018
1 parent 68855ac commit 66e422e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/solvers/refinement/string_refinement_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -631,7 +631,7 @@ void string_dependenciest::output_dot(std::ostream &stream) const
const auto node_to_string = [&](const nodet &n) { // NOLINT
std::stringstream ostream;
if(n.kind == nodet::BUILTIN)
ostream << "builtin_" << n.index;
ostream << builtin_function_nodes[n.index]->name() << n.index;
else
ostream << '"' << format(string_nodes[n.index].expr) << '"';
return ostream.str();
Expand Down
17 changes: 17 additions & 0 deletions src/solvers/refinement/string_refinement_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,8 @@ class string_builtin_functiont
virtual optionalt<exprt>
eval(const std::function<exprt(const exprt &)> &get_value) const = 0;

virtual std::string name() const = 0;

protected:
string_builtin_functiont() = default;
};
Expand Down Expand Up @@ -212,6 +214,11 @@ class string_concat_char_builtin_functiont
std::vector<mp_integer> eval(
const std::vector<mp_integer> &input_value,
const std::vector<mp_integer> &args_value) const override;

std::string name() const override
{
return "concat_char";
}
};

/// String inserting a string into another one
Expand Down Expand Up @@ -247,6 +254,11 @@ class string_insertion_builtin_functiont : public string_builtin_functiont
optionalt<exprt>
eval(const std::function<exprt(const exprt &)> &get_value) const override;

std::string name() const override
{
return "insert";
}

protected:
string_insertion_builtin_functiont() = default;
};
Expand All @@ -263,6 +275,11 @@ class string_concatenation_builtin_functiont final
const std::vector<mp_integer> &input1_value,
const std::vector<mp_integer> &input2_value,
const std::vector<mp_integer> &args_value) const override;

std::string name() const override
{
return "concat";
}
};

/// String creation from other types
Expand Down

0 comments on commit 66e422e

Please sign in to comment.