|
11 | 11 | /// Find in the parsed class a specific entry within the
|
12 | 12 | /// lambda_method_handle_map with a matching descriptor. Will fail if no
|
13 | 13 | /// matching lambda entry found.
|
14 |
| -/// \param parsed_class: the class to inspect |
15 |
| -/// \param descriptor: the descriptor the lambda method should have |
16 |
| -/// \param entry_index: the number to skip (i.e. if multiple entries with the |
17 |
| -/// same descriptor |
| 14 | +/// \param parsed_class the class to inspect |
| 15 | +/// \param lambda_method_ref the reference/descriptor of the lambda method |
| 16 | +/// to which this lambda entry points to, must be unique |
| 17 | +/// \param method_type the descriptor the lambda method should have |
18 | 18 | /// \return
|
19 | 19 | require_parse_tree::lambda_method_handlet
|
20 | 20 | require_parse_tree::require_lambda_entry_for_descriptor(
|
21 | 21 | const java_bytecode_parse_treet::classt &parsed_class,
|
22 |
| - const std::string &descriptor, |
23 |
| - const size_t entry_index) |
| 22 | + const std::string &lambda_method_ref, |
| 23 | + const std::string &method_type) |
24 | 24 | {
|
25 |
| - REQUIRE(entry_index < parsed_class.lambda_method_handle_map.size()); |
26 | 25 | typedef java_bytecode_parse_treet::classt::lambda_method_handle_mapt::
|
27 | 26 | value_type lambda_method_entryt;
|
28 | 27 |
|
29 |
| - size_t matches_found = 0; |
30 |
| - |
31 |
| - const auto matching_lambda_entry = std::find_if( |
| 28 | + INFO( |
| 29 | + "Looking for entry with lambda_method_ref: " << lambda_method_ref |
| 30 | + << " and method_type: " |
| 31 | + << method_type); |
| 32 | + std::vector<lambda_method_entryt> matches; |
| 33 | + std::copy_if( |
32 | 34 | parsed_class.lambda_method_handle_map.begin(),
|
33 | 35 | parsed_class.lambda_method_handle_map.end(),
|
34 |
| - [&descriptor, &matches_found, &entry_index]( |
35 |
| - const lambda_method_entryt &entry) { |
36 |
| - if(entry.second.method_type == descriptor) |
37 |
| - { |
38 |
| - ++matches_found; |
39 |
| - return matches_found == entry_index + 1; |
40 |
| - } |
41 |
| - return false; |
| 36 | + back_inserter(matches), |
| 37 | + [&method_type, |
| 38 | + &lambda_method_ref](const lambda_method_entryt &entry) { //NOLINT |
| 39 | + return ( |
| 40 | + entry.second.method_type == method_type && |
| 41 | + entry.second.lambda_method_ref == lambda_method_ref); |
42 | 42 | });
|
43 |
| - |
44 |
| - INFO("Looking for descriptor: " << descriptor); |
45 |
| - std::ostringstream found_entries; |
46 |
| - for(const auto entry : parsed_class.lambda_method_handle_map) |
47 |
| - { |
48 |
| - found_entries << id2string(entry.first.first) << ": " |
49 |
| - << id2string(entry.second.method_type) << std::endl; |
50 |
| - } |
51 |
| - INFO("Found descriptors:\n" << found_entries.str()); |
52 |
| - |
53 |
| - REQUIRE(matching_lambda_entry != parsed_class.lambda_method_handle_map.end()); |
54 |
| - |
55 |
| - return matching_lambda_entry->second; |
| 43 | + INFO("Number of matching lambda method entries: " << matches.size()); |
| 44 | + REQUIRE(matches.size() == 1); |
| 45 | + return matches.at(0).second; |
56 | 46 | }
|
57 | 47 |
|
58 | 48 | /// Finds a specific method in the parsed class with a matching name.
|
|
0 commit comments