Skip to content

Commit 94b7185

Browse files
author
thk123
committed
Implemented generate_start_function for Java
As with the ANSI C version, the Java version undergoes a simmilar refactor: splitting out the start generation from final so that it can be regenerated on demand. 2 The entry function in Java now has some parameters that need to passed to it. Since they are member variables in the java_bytecode_langauge they can just be passed in from the virtual regenerate call.
1 parent cd416bc commit 94b7185

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

src/java_bytecode/java_bytecode_language.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,26 @@ void java_bytecode_languaget::modules_provided(std::set<std::string> &modules)
106106
// modules.insert(translation_unit(parse_path));
107107
}
108108

109+
/// Generate a _start function for a specific function.
110+
/// \param entry_function_symbol: The symbol for the function that should be
111+
/// used as the entry point
112+
/// \param symbol_table: The symbol table for the program. The new _start
113+
/// function symbol will be added to this table
114+
/// \return Returns false if the _start method was generated correctly
115+
bool java_bytecode_languaget::generate_start_function(
116+
const symbolt &entry_function_symbol,
117+
symbol_tablet &symbol_table)
118+
{
119+
return generate_java_start_function(
120+
entry_function_symbol,
121+
symbol_table,
122+
get_message_handler(),
123+
assume_inputs_non_null,
124+
max_nondet_array_length,
125+
max_nondet_tree_depth,
126+
*pointer_type_selector);
127+
}
128+
109129
/// ANSI-C preprocessing
110130
bool java_bytecode_languaget::preprocess(
111131
std::istream &instream,

src/java_bytecode/java_bytecode_language.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ class java_bytecode_languaget:public languaget
137137
virtual void convert_lazy_method(
138138
const irep_idt &id, symbol_tablet &) override;
139139

140+
virtual bool generate_start_function(
141+
const class symbolt &entry_function_symbol,
142+
class symbol_tablet &symbol_table) override;
143+
140144
protected:
141145
bool do_ci_lazy_method_conversion(symbol_tablet &, lazy_methodst &);
142146
const select_pointer_typet &get_pointer_type_selector() const;

src/java_bytecode/java_entry_point.cpp

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,32 @@ bool java_entry_point(
510510
max_nondet_tree_depth,
511511
pointer_type_selector);
512512

513+
return generate_java_start_function(
514+
symbol,
515+
symbol_table,
516+
message_handler,
517+
assume_init_pointers_not_null,
518+
max_nondet_array_length,
519+
max_nondet_tree_depth,
520+
pointer_type_selector);
521+
}
522+
523+
/// Generate a _start function for a specific function
524+
/// \param entry_function_symbol: The symbol for the function that should be
525+
/// used as the entry point
526+
/// \param symbol_table: The symbol table for the program. The new _start
527+
/// function symbol will be added to this table
528+
/// \return Returns false if the _start method was generated correctly
529+
bool generate_java_start_function(
530+
const symbolt &symbol,
531+
symbol_tablet &symbol_table,
532+
message_handlert &message_handler,
533+
bool assume_init_pointers_not_null,
534+
size_t max_nondet_array_length,
535+
size_t max_nondet_tree_depth,
536+
const select_pointer_typet &pointer_type_selector)
537+
{
538+
messaget message(message_handler);
513539
code_blockt init_code;
514540

515541
// build call to initialization function

src/java_bytecode/java_entry_point.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,13 @@ main_function_resultt get_main_symbol(
4040
message_handlert &,
4141
bool allow_no_body=false);
4242

43+
bool generate_java_start_function(
44+
const symbolt &symbol,
45+
class symbol_tablet &symbol_table,
46+
class message_handlert &message_handler,
47+
bool assume_init_pointers_not_null,
48+
size_t max_nondet_array_length,
49+
size_t max_nondet_tree_depth,
50+
const select_pointer_typet &pointer_type_selector);
51+
4352
#endif // CPROVER_JAVA_BYTECODE_JAVA_ENTRY_POINT_H

0 commit comments

Comments
 (0)