Skip to content

Commit 42065ec

Browse files
thk123Matthias Güdemann
thk123
authored and
Matthias Güdemann
committed
Adjust the interface of the bootstrap methods map
Added a todo to make private (needs adjustments to the test)
1 parent dcd680f commit 42065ec

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/java_bytecode/java_bytecode_parse_tree.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ class java_bytecode_parse_treet
205205
}
206206
};
207207

208+
209+
// TODO(tkiley): This map shouldn't be interacted with directly (instead
210+
// TODO(tkiley): using add_method_handle and get_method_handle and instead
211+
// TODO(tkiley): should be made private. TG-2785
208212
typedef std::map<std::pair<irep_idt, size_t>, lambda_method_handlet>
209213
lambda_method_handle_mapt;
210214
lambda_method_handle_mapt lambda_method_handle_map;
@@ -230,6 +234,16 @@ class java_bytecode_parse_treet
230234
return methods.back();
231235
}
232236

237+
void add_method_handle(size_t bootstrap_index, lambda_method_handlet handle)
238+
{
239+
lambda_method_handle_map[{name, bootstrap_index}] = handle;
240+
}
241+
242+
const lambda_method_handlet &get_method_handle(size_t bootstrap_index) const
243+
{
244+
return lambda_method_handle_map.at({name, bootstrap_index});
245+
}
246+
233247
void output(std::ostream &out) const;
234248

235249
void swap(classt &other);

src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ class java_bytecode_parsert:public parsert
5252
method_handle_typet;
5353
typedef java_bytecode_parse_treet::classt::lambda_method_handlet
5454
lambda_method_handlet;
55-
typedef java_bytecode_parse_treet::classt::lambda_method_handle_mapt
56-
lambda_method_handle_mapt;
5755
typedef java_bytecode_parse_treet::classt::u2_valuest u2_valuest;
5856

5957
java_bytecode_parse_treet parse_tree;
@@ -1941,14 +1939,14 @@ void java_bytecode_parsert::read_bootstrapmethods_entry(classt &parsed_class)
19411939
<< "\n method type is "
19421940
<< id2string(pool_entry(method_type_argument.ref1).s)
19431941
<< eom;
1944-
parsed_class.lambda_method_handle_map[{parsed_class.name, bootstrap_method_index}] =
1945-
*lambda_method_handle;
1942+
parsed_class.add_method_handle(
1943+
bootstrap_method_index, *lambda_method_handle);
19461944
}
19471945
}
19481946

19491947
/// Creates an unknown method handle and puts it into the parsed_class
19501948
/// \param parsed_class: The class whose bootstrap method handles we are using
1951-
/// \param bootstrap_method_index: The current index in the boostrap entry table
1949+
/// \param bootstrap_method_index: The current index in the bootstrap entry table
19521950
/// \param u2_values: The indices of the arguments for the call
19531951
void java_bytecode_parsert::store_unknown_method_handle(
19541952
java_bytecode_parsert::classt &parsed_class,
@@ -1957,7 +1955,6 @@ void java_bytecode_parsert::store_unknown_method_handle(
19571955
{
19581956
const lambda_method_handlet lambda_method_handle =
19591957
lambda_method_handlet::create_unknown_handle(move(u2_values));
1960-
parsed_class
1961-
.lambda_method_handle_map[{parsed_class.name, bootstrap_method_index}] =
1962-
lambda_method_handle;
1958+
parsed_class.add_method_handle(
1959+
bootstrap_method_index, lambda_method_handle);
19631960
}

0 commit comments

Comments
 (0)