Skip to content

Commit 249d8cf

Browse files
committed
Hide declare_function and set type in symbol_exprt
declare_function is used exactly once and has very limited utility. Make it return the created symbol so that we can afterwards generate a type-consistent expression.
1 parent 3957f80 commit 249d8cf

File tree

2 files changed

+7
-12
lines changed

2 files changed

+7
-12
lines changed

jbmc/src/java_bytecode/java_utils.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,9 @@ void java_add_components_to_class(
247247
/// \param function_name: a name
248248
/// \param type: a type
249249
/// \param symbol_table: symbol table
250-
void declare_function(
251-
irep_idt function_name,
250+
/// \return newly created symbol
251+
static auxiliary_symbolt declare_function(
252+
const irep_idt &function_name,
252253
const typet &type,
253254
symbol_table_baset &symbol_table)
254255
{
@@ -260,6 +261,8 @@ void declare_function(
260261
func_symbol.name=function_name;
261262
func_symbol.type=type;
262263
symbol_table.add(func_symbol);
264+
265+
return func_symbol;
263266
}
264267

265268
/// Create a function application expression.
@@ -275,14 +278,11 @@ exprt make_function_application(
275278
const typet &type,
276279
symbol_table_baset &symbol_table)
277280
{
278-
// Names of function to call
279-
std::string fun_name=id2string(function_name);
280-
281281
// Declaring the function
282-
declare_function(fun_name, type, symbol_table);
282+
const auto symbol = declare_function(function_name, type, symbol_table);
283283

284284
// Function application
285-
return function_application_exprt(symbol_exprt(fun_name), arguments, type);
285+
return function_application_exprt(symbol.symbol_expr(), arguments, type);
286286
}
287287

288288
/// Strip java:: prefix from given identifier

jbmc/src/java_bytecode/java_utils.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,6 @@ size_t find_closing_delimiter(
8787
char open_char,
8888
char close_char);
8989

90-
void declare_function(
91-
irep_idt function_name,
92-
const typet &type,
93-
symbol_table_baset &symbol_table);
94-
9590
exprt make_function_application(
9691
const irep_idt &function_name,
9792
const exprt::operandst &arguments,

0 commit comments

Comments
 (0)