Skip to content

helper for getting the function type used in function_application_exprt #5737

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

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 11 additions & 11 deletions src/goto-symex/goto_symex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ void goto_symext::constant_propagate_empty_string(
symex_assignt &symex_assign,
const function_application_exprt &f_l1)
{
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down Expand Up @@ -410,7 +410,7 @@ bool goto_symext::constant_propagate_string_concat(
symex_assignt &symex_assign,
const function_application_exprt &f_l1)
{
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down Expand Up @@ -465,7 +465,7 @@ bool goto_symext::constant_propagate_string_substring(
PRECONDITION(num_operands >= 4);
PRECONDITION(num_operands <= 5);

const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down Expand Up @@ -557,7 +557,7 @@ bool goto_symext::constant_propagate_integer_to_string(
PRECONDITION(num_operands >= 3);
PRECONDITION(num_operands <= 4);

const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down Expand Up @@ -633,7 +633,7 @@ bool goto_symext::constant_propagate_delete_char_at(
// - index of char to delete
PRECONDITION(f_l1.arguments().size() == 4);

const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down Expand Up @@ -707,7 +707,7 @@ bool goto_symext::constant_propagate_delete(
// - index of end of substring to delete (exclusive)
PRECONDITION(f_l1.arguments().size() == 5);

const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down Expand Up @@ -800,7 +800,7 @@ bool goto_symext::constant_propagate_set_length(
// - new length of the string
PRECONDITION(f_l1.arguments().size() == 4);

const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down Expand Up @@ -882,7 +882,7 @@ bool goto_symext::constant_propagate_set_char_at(
// - new char
PRECONDITION(f_l1.arguments().size() == 5);

const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down Expand Up @@ -945,7 +945,7 @@ bool goto_symext::constant_propagate_case_change(
const function_application_exprt &f_l1,
bool to_upper)
{
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down Expand Up @@ -1006,7 +1006,7 @@ bool goto_symext::constant_propagate_replace(
symex_assignt &symex_assign,
const function_application_exprt &f_l1)
{
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down Expand Up @@ -1114,7 +1114,7 @@ bool goto_symext::constant_propagate_trim(
symex_assignt &symex_assign,
const function_application_exprt &f_l1)
{
const auto &f_type = to_mathematical_function_type(f_l1.function().type());
const auto &f_type = f_l1.function_type();
const auto &length_type = f_type.domain().at(0);
const auto &char_type = to_pointer_type(f_type.domain().at(1)).subtype();

Expand Down
8 changes: 7 additions & 1 deletion src/util/mathematical_expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ function_application_exprt::function_application_exprt(
tuple_exprt(std::move(_arguments)),
to_mathematical_function_type(_function.type()).codomain())
{
const auto &domain = to_mathematical_function_type(_function.type()).domain();
const auto &domain = function_type().domain();
PRECONDITION(domain.size() == arguments().size());
}

const mathematical_function_typet &
function_application_exprt::function_type() const
{
return to_mathematical_function_type(function().type());
}
7 changes: 7 additions & 0 deletions src/util/mathematical_expr.h
Original file line number Diff line number Diff line change
Expand Up @@ -186,12 +186,16 @@ class tuple_exprt : public multi_ary_exprt
}
};

class mathematical_function_typet;

/// \brief Application of (mathematical) function
class function_application_exprt : public binary_exprt
{
public:
using argumentst = exprt::operandst;

/// \param _function must be known to have \ref mathematical_function_typet type.
/// \param _arguments must match function_type().domain()
function_application_exprt(const exprt &_function, argumentst _arguments);

exprt &function()
Expand All @@ -204,6 +208,9 @@ class function_application_exprt : public binary_exprt
return op0();
}

/// This helper method provides the type of the expression returned by \ref function.
const mathematical_function_typet &function_type() const;

argumentst &arguments()
{
return op1().operands();
Expand Down