13
13
#include < util/fresh_symbol.h>
14
14
#include < util/invariant.h>
15
15
#include < util/mathematical_expr.h>
16
+ #include < util/mathematical_types.h>
16
17
#include < util/message.h>
17
18
#include < util/prefix.h>
18
19
#include < util/std_types.h>
@@ -252,13 +253,14 @@ void java_add_components_to_class(
252
253
// / \return newly created symbol
253
254
static auxiliary_symbolt declare_function (
254
255
const irep_idt &function_name,
255
- const typet &type,
256
+ const mathematical_function_typet &type,
256
257
symbol_table_baset &symbol_table)
257
258
{
258
259
auxiliary_symbolt func_symbol;
259
260
func_symbol.base_name =function_name;
260
261
func_symbol.pretty_name =function_name;
261
262
func_symbol.is_static_lifetime =false ;
263
+ func_symbol.is_state_var = false ;
262
264
func_symbol.mode =ID_java;
263
265
func_symbol.name =function_name;
264
266
func_symbol.type =type;
@@ -267,24 +269,32 @@ static auxiliary_symbolt declare_function(
267
269
return func_symbol;
268
270
}
269
271
270
- // / Create a function application expression.
272
+ // / Create a (mathematical) function application expression.
273
+ // / The application has the type of the codomain (range) of the function.
271
274
// / \param function_name: the name of the function
272
- // / \param arguments: a list of arguments
273
- // / \param type : return type of the function
275
+ // / \param arguments: a list of arguments (an element of the domain)
276
+ // / \param range : return type (codomain) of the function
274
277
// / \param symbol_table: a symbol table
275
278
// / \return a function application expression representing:
276
279
// / `function_name(arguments)`
277
280
exprt make_function_application (
278
281
const irep_idt &function_name,
279
282
const exprt::operandst &arguments,
280
- const typet &type ,
283
+ const typet &range ,
281
284
symbol_table_baset &symbol_table)
282
285
{
286
+ std::vector<typet> argument_types;
287
+ for (const auto &arg : arguments)
288
+ argument_types.push_back (arg.type ());
289
+
283
290
// Declaring the function
284
- const auto symbol = declare_function (function_name, type, symbol_table);
291
+ const auto symbol = declare_function (
292
+ function_name,
293
+ mathematical_function_typet (std::move (argument_types), range),
294
+ symbol_table);
285
295
286
296
// Function application
287
- return function_application_exprt (symbol.symbol_expr (), arguments, type );
297
+ return function_application_exprt (symbol.symbol_expr (), arguments, range );
288
298
}
289
299
290
300
// / Strip java:: prefix from given identifier
0 commit comments