Skip to content

Commit 99a40dc

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 bafd7e7 commit 99a40dc

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
@@ -250,8 +250,9 @@ void java_add_components_to_class(
250250
/// \param function_name: a name
251251
/// \param type: a type
252252
/// \param symbol_table: symbol table
253-
void declare_function(
254-
irep_idt function_name,
253+
/// \return newly created symbol
254+
static auxiliary_symbolt declare_function(
255+
const irep_idt &function_name,
255256
const typet &type,
256257
symbol_table_baset &symbol_table)
257258
{
@@ -263,6 +264,8 @@ void declare_function(
263264
func_symbol.name=function_name;
264265
func_symbol.type=type;
265266
symbol_table.add(func_symbol);
267+
268+
return func_symbol;
266269
}
267270

268271
/// Create a function application expression.
@@ -278,14 +281,11 @@ exprt make_function_application(
278281
const typet &type,
279282
symbol_table_baset &symbol_table)
280283
{
281-
// Names of function to call
282-
std::string fun_name=id2string(function_name);
283-
284284
// Declaring the function
285-
declare_function(fun_name, type, symbol_table);
285+
const auto symbol = declare_function(function_name, type, symbol_table);
286286

287287
// Function application
288-
return function_application_exprt(symbol_exprt(fun_name), arguments, type);
288+
return function_application_exprt(symbol.symbol_expr(), arguments, type);
289289
}
290290

291291
/// 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)