Skip to content

Commit 21b2641

Browse files
Move make_function_application to java_utils
1 parent 3ee3b25 commit 21b2641

File tree

4 files changed

+55
-48
lines changed

4 files changed

+55
-48
lines changed

src/java_bytecode/java_string_library_preprocess.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -248,25 +248,6 @@ symbol_exprt java_string_library_preprocesst::fresh_array(
248248
return array_symbol.symbol_expr();
249249
}
250250

251-
/// declare a function with the given name and type
252-
/// \param function_name: a name
253-
/// \param type: a type
254-
/// \param symbol_table: symbol table
255-
static void declare_function(
256-
irep_idt function_name,
257-
const typet &type,
258-
symbol_tablet &symbol_table)
259-
{
260-
auxiliary_symbolt func_symbol;
261-
func_symbol.base_name=function_name;
262-
func_symbol.pretty_name=function_name;
263-
func_symbol.is_static_lifetime=false;
264-
func_symbol.mode=ID_java;
265-
func_symbol.name=function_name;
266-
func_symbol.type=type;
267-
symbol_table.add(func_symbol);
268-
}
269-
270251
/// calls string_refine_preprocesst::process_operands with a list of parameters.
271252
/// \param params: a list of function parameters
272253
/// \param loc: location in the source
@@ -593,29 +574,6 @@ exprt java_string_library_preprocesst::allocate_fresh_array(
593574
return array;
594575
}
595576

596-
/// \param function_name: the name of the function
597-
/// \param arguments: a list of arguments
598-
/// \param type: return type of the function
599-
/// \param symbol_table: a symbol table
600-
/// \return a function application representing: `function_name(arguments)`
601-
exprt make_function_application(
602-
const irep_idt &function_name,
603-
const exprt::operandst &arguments,
604-
const typet &type,
605-
symbol_tablet &symbol_table)
606-
{
607-
// Names of function to call
608-
std::string fun_name=id2string(function_name);
609-
610-
// Declaring the function
611-
declare_function(fun_name, type, symbol_table);
612-
613-
// Function application
614-
function_application_exprt call(symbol_exprt(fun_name), type);
615-
call.arguments()=arguments;
616-
return call;
617-
}
618-
619577
/// assign the result of a function call
620578
/// \param lhs: an expression
621579
/// \param function_name: the name of the function

src/java_bytecode/java_string_library_preprocess.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -330,12 +330,6 @@ class java_string_library_preprocesst:public messaget
330330
symbol_tablet &symbol_table);
331331
};
332332

333-
exprt make_function_application(
334-
const irep_idt &function_name,
335-
const exprt::operandst &arguments,
336-
const typet &type,
337-
symbol_tablet &symbol_table);
338-
339333
exprt make_nondet_infinite_char_array(
340334
symbol_tablet &symbol_table,
341335
const source_locationt &loc,

src/java_bytecode/java_utils.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,3 +251,47 @@ void java_add_components_to_class(
251251
components.push_back(component);
252252
}
253253
}
254+
255+
/// Declare a function with the given name and type.
256+
/// \param function_name: a name
257+
/// \param type: a type
258+
/// \param symbol_table: symbol table
259+
void declare_function(
260+
irep_idt function_name,
261+
const typet &type,
262+
symbol_tablet &symbol_table)
263+
{
264+
auxiliary_symbolt func_symbol;
265+
func_symbol.base_name=function_name;
266+
func_symbol.pretty_name=function_name;
267+
func_symbol.is_static_lifetime=false;
268+
func_symbol.mode=ID_java;
269+
func_symbol.name=function_name;
270+
func_symbol.type=type;
271+
symbol_table.add(func_symbol);
272+
}
273+
274+
/// Create a function application expression.
275+
/// \param function_name: the name of the function
276+
/// \param arguments: a list of arguments
277+
/// \param type: return type of the function
278+
/// \param symbol_table: a symbol table
279+
/// \return a function application expression representing:
280+
/// `function_name(arguments)`
281+
exprt make_function_application(
282+
const irep_idt &function_name,
283+
const exprt::operandst &arguments,
284+
const typet &type,
285+
symbol_tablet &symbol_table)
286+
{
287+
// Names of function to call
288+
std::string fun_name=id2string(function_name);
289+
290+
// Declaring the function
291+
declare_function(fun_name, type, symbol_table);
292+
293+
// Function application
294+
function_application_exprt call(symbol_exprt(fun_name), type);
295+
call.arguments()=arguments;
296+
return call;
297+
}

src/java_bytecode/java_utils.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,4 +81,15 @@ size_t find_closing_delimiter(
8181
char open_char,
8282
char close_char);
8383

84+
void declare_function(
85+
irep_idt function_name,
86+
const typet &type,
87+
symbol_tablet &symbol_table);
88+
89+
exprt make_function_application(
90+
const irep_idt &function_name,
91+
const exprt::operandst &arguments,
92+
const typet &type,
93+
symbol_tablet &symbol_table);
94+
8495
#endif // CPROVER_JAVA_BYTECODE_JAVA_UTILS_H

0 commit comments

Comments
 (0)