Skip to content

Commit 91a0307

Browse files
author
Daniel Kroening
committed
new constructor for function_application_exprt
The new constructor 1) moves the arguments 2) enforces the type of the function to be mathematical_function 3) automatically sets the type of the application to be the codomain of the function. 4) checks that the right number of arguments is given. Note that the function symbol can't be moved during construction as its type is needed. The types of the arguments are not checked.
1 parent f3300d6 commit 91a0307

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

src/solvers/smt2/smt2_parser.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -818,10 +818,7 @@ exprt smt2_parsert::function_application()
818818
if(id_it->second.type.id()==ID_mathematical_function)
819819
{
820820
return function_application_exprt(
821-
symbol_exprt(final_id, id_it->second.type),
822-
op,
823-
to_mathematical_function_type(
824-
id_it->second.type).codomain());
821+
symbol_exprt(final_id, id_it->second.type), op);
825822
}
826823
else
827824
return symbol_exprt(final_id, id_it->second.type);

src/util/mathematical_expr.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,17 @@ Author: Daniel Kroening, [email protected]
77
\*******************************************************************/
88

99
#include "mathematical_expr.h"
10+
#include "mathematical_types.h"
11+
12+
function_application_exprt::function_application_exprt(
13+
const symbol_exprt &_function,
14+
argumentst _arguments)
15+
: binary_exprt(
16+
_function,
17+
ID_function_application,
18+
multi_ary_exprt(irep_idt(), std::move(_arguments), typet()),
19+
to_mathematical_function_type(_function.type()).codomain())
20+
{
21+
const auto &domain = to_mathematical_function_type(_function.type()).domain();
22+
PRECONDITION(domain.size() == arguments().size());
23+
}

src/util/mathematical_expr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,6 +192,7 @@ class function_application_exprt : public binary_exprt
192192
public:
193193
using argumentst = exprt::operandst;
194194

195+
DEPRECATED("use function_application_exprt(fkt, arg) instead")
195196
function_application_exprt(
196197
const symbol_exprt &_function,
197198
const argumentst &_arguments,
@@ -201,6 +202,10 @@ class function_application_exprt : public binary_exprt
201202
arguments() = _arguments;
202203
}
203204

205+
function_application_exprt(
206+
const symbol_exprt &_function,
207+
argumentst _arguments);
208+
204209
symbol_exprt &function()
205210
{
206211
return static_cast<symbol_exprt &>(op0());

0 commit comments

Comments
 (0)