Skip to content

Commit 576c4a9

Browse files
author
Matthias Güdemann
committed
Updates to convert_method
1 parent ab17582 commit 576c4a9

File tree

1 file changed

+28
-24
lines changed

1 file changed

+28
-24
lines changed

jbmc/src/java_bytecode/java_bytecode_convert_method.cpp

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2095,15 +2095,15 @@ exprt::operandst &java_bytecode_convert_methodt::convert_const(
20952095
void java_bytecode_convert_methodt::convert_invoke(
20962096
source_locationt location,
20972097
const irep_idt &statement,
2098-
exprt &arg0,
2098+
exprt &invoke_statement,
20992099
codet &c,
21002100
exprt::operandst &results)
21012101
{
21022102
const bool use_this(statement != "invokestatic");
21032103
const bool is_virtual(
21042104
statement == "invokevirtual" || statement == "invokeinterface");
21052105

2106-
code_typet &code_type = to_code_type(arg0.type());
2106+
code_typet &code_type = to_code_type(invoke_statement.type());
21072107
code_typet::parameterst &parameters(code_type.parameters());
21082108

21092109
const std::string full_method_name = id2string(method_id);
@@ -2116,22 +2116,18 @@ void java_bytecode_convert_methodt::convert_invoke(
21162116
std::string class_type_name = calling_class_name.substr(6);
21172117
std::replace(class_type_name.begin(), class_type_name.end(), '.', '/');
21182118
const auto &enum_clone_symbol = symbol_table.lookup_ref(calling_class_name);
2119-
const bool is_enum_values_clone_call =
2120-
enum_clone_symbol.type.get_bool(ID_enumeration) &&
2121-
(full_method_name ==
2122-
(calling_class_name + ".values:()[L" + class_type_name + ";"));
21232119

21242120
if(use_this)
21252121
{
21262122
if(parameters.empty() || !parameters[0].get_this())
21272123
{
2128-
irep_idt classname = arg0.get(ID_C_class);
2124+
irep_idt classname = invoke_statement.get(ID_C_class);
21292125
typet thistype = symbol_typet(classname);
21302126
// Note invokespecial is used for super-method calls as well as
21312127
// constructors.
21322128
if(statement == "invokespecial")
21332129
{
2134-
if(is_constructor(arg0.get(ID_identifier)))
2130+
if(is_constructor(invoke_statement.get(ID_identifier)))
21352131
{
21362132
if(needed_lazy_methods)
21372133
needed_lazy_methods->add_needed_class(classname);
@@ -2194,7 +2190,7 @@ void java_bytecode_convert_methodt::convert_invoke(
21942190
results[0] = promoted;
21952191
}
21962192

2197-
assert(arg0.id() == ID_virtual_function);
2193+
assert(invoke_statement.id() == ID_virtual_function);
21982194

21992195
// If we don't have a definition for the called symbol, and we won't
22002196
// inherit a definition from a super-class, we create a new symbol and
@@ -2212,18 +2208,19 @@ void java_bytecode_convert_methodt::convert_invoke(
22122208
// generate code that may wrongly assume that such a method is
22132209
// accessible if we assume that its access attribute is "more
22142210
// accessible" than it actually is.
2215-
const irep_idt id = arg0.get(ID_identifier);
2211+
const irep_idt &id = invoke_statement.get(ID_identifier);
22162212
if(
22172213
symbol_table.symbols.find(id) == symbol_table.symbols.end() &&
2218-
!(is_virtual &&
2219-
is_method_inherited(arg0.get(ID_C_class), arg0.get(ID_component_name))))
2214+
!(is_virtual && is_method_inherited(
2215+
invoke_statement.get(ID_C_class),
2216+
invoke_statement.get(ID_component_name))))
22202217
{
22212218
symbolt symbol;
22222219
symbol.name = id;
2223-
symbol.base_name = arg0.get(ID_C_base_name);
2224-
symbol.pretty_name = id2string(arg0.get(ID_C_class)).substr(6) + "." +
2225-
id2string(symbol.base_name) + "()";
2226-
symbol.type = arg0.type();
2220+
symbol.base_name = invoke_statement.get(ID_C_base_name);
2221+
symbol.pretty_name = id2string(invoke_statement.get(ID_C_class)).substr(6) +
2222+
"." + id2string(symbol.base_name) + "()";
2223+
symbol.type = invoke_statement.type();
22272224
symbol.type.set(ID_access, ID_public);
22282225
symbol.value.make_nil();
22292226
symbol.mode = ID_java;
@@ -2235,30 +2232,37 @@ void java_bytecode_convert_methodt::convert_invoke(
22352232
symbol_table.add(symbol);
22362233
}
22372234

2235+
const bool is_enum_values_clone_call =
2236+
enum_clone_symbol.type.get_bool(ID_enumeration) &&
2237+
(full_method_name ==
2238+
(calling_class_name + ".values:()[L" + class_type_name + ";"));
2239+
22382240
if(is_enum_values_clone_call)
22392241
{
2240-
const std::string clone_name =
2241-
"java::array[" + calling_class_name + "].clone:()Ljava/lang/Object;";
2242-
call.function() = symbol_exprt(clone_name, arg0.type());
2242+
const irep_idt clone_name =
2243+
"java::array[" + class_type_name + "].clone:()Ljava/lang/Object;";
2244+
call.function() = symbol_exprt(clone_name, invoke_statement.type());
22432245
}
22442246
else if(is_virtual)
22452247
{
22462248
// dynamic binding
22472249
assert(use_this);
22482250
assert(!call.arguments().empty());
2249-
call.function() = arg0;
2251+
call.function() = invoke_statement;
22502252
// Populate needed methods later,
22512253
// once we know what object types can exist.
22522254
}
22532255
else
22542256
{
22552257
// static binding
2256-
call.function() = symbol_exprt(arg0.get(ID_identifier), arg0.type());
2258+
call.function() = symbol_exprt(
2259+
invoke_statement.get(ID_identifier), invoke_statement.type());
22572260
if(needed_lazy_methods)
22582261
{
2259-
needed_lazy_methods->add_needed_method(arg0.get(ID_identifier));
2262+
needed_lazy_methods->add_needed_method(
2263+
invoke_statement.get(ID_identifier));
22602264
// Calling a static method causes static initialization:
2261-
needed_lazy_methods->add_needed_class(arg0.get(ID_C_class));
2265+
needed_lazy_methods->add_needed_class(invoke_statement.get(ID_C_class));
22622266
}
22632267
}
22642268

@@ -2270,7 +2274,7 @@ void java_bytecode_convert_methodt::convert_invoke(
22702274

22712275
if(!use_this)
22722276
{
2273-
codet clinit_call = get_clinit_call(arg0.get(ID_C_class));
2277+
codet clinit_call = get_clinit_call(invoke_statement.get(ID_C_class));
22742278
if(clinit_call.get_statement() != ID_skip)
22752279
{
22762280
code_blockt ret_block;

0 commit comments

Comments
 (0)