Skip to content

Commit 6170e50

Browse files
committed
Factor out create_stub_method_symbol
1 parent 482de57 commit 6170e50

File tree

2 files changed

+47
-17
lines changed

2 files changed

+47
-17
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 38 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,35 @@ static void assign_parameter_names(
9494
}
9595
}
9696

97+
void create_method_stub_symbol(
98+
const irep_idt &identifier,
99+
const irep_idt &base_name,
100+
const irep_idt &pretty_name,
101+
const typet &type,
102+
const irep_idt &declaring_class,
103+
symbol_table_baset &symbol_table,
104+
message_handlert &message_handler)
105+
{
106+
messaget log(message_handler);
107+
108+
symbolt symbol;
109+
symbol.name = identifier;
110+
symbol.base_name = base_name;
111+
symbol.pretty_name = pretty_name;
112+
symbol.type = type;
113+
symbol.type.set(ID_access, ID_private);
114+
to_java_method_type(symbol.type).set_is_final(true);
115+
symbol.value.make_nil();
116+
symbol.mode = ID_java;
117+
assign_parameter_names(
118+
to_java_method_type(symbol.type), symbol.name, symbol_table);
119+
set_declaring_class(symbol, declaring_class);
120+
121+
log.debug() << "Generating codet: new opaque symbol: method '" << symbol.name
122+
<< "'" << messaget::eom;
123+
symbol_table.add(symbol);
124+
}
125+
97126
static bool is_constructor(const irep_idt &method_name)
98127
{
99128
return id2string(method_name).find("<init>") != std::string::npos;
@@ -2185,23 +2214,15 @@ void java_bytecode_convert_methodt::convert_invoke(
21852214
!(is_virtual &&
21862215
is_method_inherited(arg0.get(ID_C_class), arg0.get(ID_component_name))))
21872216
{
2188-
symbolt symbol;
2189-
symbol.name = invoked_method_id;
2190-
symbol.base_name = arg0.get(ID_C_base_name);
2191-
symbol.pretty_name = id2string(arg0.get(ID_C_class)).substr(6) + "." +
2192-
id2string(symbol.base_name) + "()";
2193-
symbol.type = method_type;
2194-
symbol.type.set(ID_access, ID_private);
2195-
to_java_method_type(symbol.type).set_is_final(true);
2196-
symbol.value.make_nil();
2197-
symbol.mode = ID_java;
2198-
assign_parameter_names(
2199-
to_java_method_type(symbol.type), symbol.name, symbol_table);
2200-
set_declaring_class(symbol, arg0.get(ID_C_class));
2201-
2202-
debug() << "Generating codet: new opaque symbol: method '" << symbol.name
2203-
<< "'" << eom;
2204-
symbol_table.add(symbol);
2217+
create_method_stub_symbol(
2218+
invoked_method_id,
2219+
arg0.get(ID_C_base_name),
2220+
id2string(arg0.get(ID_C_class)).substr(6) + "." +
2221+
id2string(arg0.get(ID_C_base_name)) + "()",
2222+
method_type,
2223+
arg0.get(ID_C_class),
2224+
symbol_table,
2225+
get_message_handler());
22052226
}
22062227

22072228
exprt function;

jbmc/src/java_bytecode/java_bytecode_convert_method.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,15 @@ void java_bytecode_convert_method(
3939
const class_hierarchyt &class_hierarchy,
4040
bool threading_support);
4141

42+
void create_method_stub_symbol(
43+
const irep_idt &identifier,
44+
const irep_idt &base_name,
45+
const irep_idt &pretty_name,
46+
const typet &type,
47+
const irep_idt &declaring_class,
48+
symbol_table_baset &symbol_table,
49+
message_handlert &message_handler);
50+
4251
void java_bytecode_convert_method_lazy(
4352
const symbolt &class_symbol,
4453
const irep_idt &method_identifier,

0 commit comments

Comments
 (0)