|
26 | 26 |
|
27 | 27 | class java_string_library_preprocesst;
|
28 | 28 |
|
29 |
| -// Pair of class id and methodt |
30 |
| -typedef std::pair<irep_idt, const java_bytecode_parse_treet::methodt *> |
31 |
| - class_and_bytecodet; |
32 |
| -// Map from method id to class_and_bytecodet |
33 |
| -typedef std::map<irep_idt, class_and_bytecodet> method_bytecodet; |
| 29 | +// Map from method id to class_method_and_bytecodet |
| 30 | +class method_bytecodet |
| 31 | +{ |
| 32 | +public: |
| 33 | + /// Pair of class id and methodt |
| 34 | + struct class_method_and_bytecodet |
| 35 | + { |
| 36 | + irep_idt class_id; |
| 37 | + irep_idt method_id; |
| 38 | + const java_bytecode_parse_treet::methodt &method; |
| 39 | + }; |
| 40 | + |
| 41 | + typedef optionalt<std::reference_wrapper<const class_method_and_bytecodet>> |
| 42 | + opt_reft; |
| 43 | + |
| 44 | +private: |
| 45 | + typedef std::map<irep_idt, class_method_and_bytecodet> mapt; |
| 46 | + mapt map; |
| 47 | + |
| 48 | +public: |
| 49 | + bool contains_method(const irep_idt &method_id) const |
| 50 | + { |
| 51 | + return map.count(method_id) != 0; |
| 52 | + } |
| 53 | + |
| 54 | + void add(const class_method_and_bytecodet &method_class_and_bytecode) |
| 55 | + { |
| 56 | + map.emplace( |
| 57 | + std::make_pair( |
| 58 | + method_class_and_bytecode.method_id, method_class_and_bytecode)); |
| 59 | + } |
| 60 | + |
| 61 | + void add( |
| 62 | + const irep_idt &class_id, |
| 63 | + const irep_idt &method_id, |
| 64 | + const java_bytecode_parse_treet::methodt &method) |
| 65 | + { |
| 66 | + add(class_method_and_bytecodet{class_id, method_id, method}); |
| 67 | + } |
| 68 | + |
| 69 | + mapt::const_iterator begin() const |
| 70 | + { |
| 71 | + return map.begin(); |
| 72 | + } |
| 73 | + mapt::const_iterator end() const |
| 74 | + { |
| 75 | + return map.end(); |
| 76 | + } |
| 77 | + |
| 78 | + opt_reft get(const irep_idt &method_id) |
| 79 | + { |
| 80 | + const auto it = map.find(method_id); |
| 81 | + if(it == map.end()) |
| 82 | + return opt_reft(); |
| 83 | + return std::cref(it->second); |
| 84 | + } |
| 85 | +}; |
34 | 86 |
|
35 | 87 | typedef std::function<void(
|
36 | 88 | const symbolt &,
|
|
0 commit comments