Skip to content

Commit 20b9e60

Browse files
committed
Factor out create_stub_method_symbol
1 parent e2fbcde commit 20b9e60

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;
@@ -2235,23 +2264,15 @@ void java_bytecode_convert_methodt::convert_invoke(
22352264
!(is_virtual &&
22362265
is_method_inherited(arg0.get(ID_C_class), arg0.get(ID_component_name))))
22372266
{
2238-
symbolt symbol;
2239-
symbol.name = invoked_method_id;
2240-
symbol.base_name = arg0.get(ID_C_base_name);
2241-
symbol.pretty_name = id2string(arg0.get(ID_C_class)).substr(6) + "." +
2242-
id2string(symbol.base_name) + "()";
2243-
symbol.type = method_type;
2244-
symbol.type.set(ID_access, ID_private);
2245-
to_java_method_type(symbol.type).set_is_final(true);
2246-
symbol.value.make_nil();
2247-
symbol.mode = ID_java;
2248-
assign_parameter_names(
2249-
to_java_method_type(symbol.type), symbol.name, symbol_table);
2250-
set_declaring_class(symbol, arg0.get(ID_C_class));
2251-
2252-
debug() << "Generating codet: new opaque symbol: method '" << symbol.name
2253-
<< "'" << eom;
2254-
symbol_table.add(symbol);
2267+
create_method_stub_symbol(
2268+
invoked_method_id,
2269+
arg0.get(ID_C_base_name),
2270+
id2string(arg0.get(ID_C_class)).substr(6) + "." +
2271+
id2string(arg0.get(ID_C_base_name)) + "()",
2272+
method_type,
2273+
arg0.get(ID_C_class),
2274+
symbol_table,
2275+
get_message_handler());
22552276
}
22562277

22572278
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)