@@ -112,6 +112,23 @@ static prefix_filtert get_context(const optionst &options)
112
112
return prefix_filtert (std::move (context_include), std::move (context_exclude));
113
113
}
114
114
115
+ std::unordered_multimap<irep_idt, symbolt> &
116
+ lazy_class_to_declared_symbols_mapt::get (const symbol_tablet &symbol_table)
117
+ {
118
+ if (!initialized)
119
+ {
120
+ map = class_to_declared_symbols (symbol_table);
121
+ initialized = true ;
122
+ }
123
+ return map;
124
+ }
125
+
126
+ void lazy_class_to_declared_symbols_mapt::reinitialize ()
127
+ {
128
+ initialized = false ;
129
+ map.clear ();
130
+ }
131
+
115
132
// / Consume options that are java bytecode specific.
116
133
void java_bytecode_languaget::set_language_options (const optionst &options)
117
134
{
@@ -995,12 +1012,17 @@ bool java_bytecode_languaget::do_ci_lazy_method_conversion(
995
1012
symbol_table_buildert symbol_table_builder =
996
1013
symbol_table_buildert::wrap (symbol_table);
997
1014
1015
+ lazy_class_to_declared_symbols_mapt class_to_declared_symbols;
1016
+
998
1017
const method_convertert method_converter =
999
- [this , &symbol_table_builder](
1018
+ [this , &symbol_table_builder, &class_to_declared_symbols ](
1000
1019
const irep_idt &function_id,
1001
1020
ci_lazy_methods_neededt lazy_methods_needed) {
1002
1021
return convert_single_method (
1003
- function_id, symbol_table_builder, std::move (lazy_methods_needed));
1022
+ function_id,
1023
+ symbol_table_builder,
1024
+ std::move (lazy_methods_needed),
1025
+ class_to_declared_symbols);
1004
1026
};
1005
1027
1006
1028
ci_lazy_methodst method_gather (
@@ -1131,10 +1153,13 @@ static void notify_static_method_calls(
1131
1153
// / \param symbol_table: global symbol table
1132
1154
// / \param needed_lazy_methods: optionally a collection of needed methods to
1133
1155
// / update with any methods touched during the conversion
1156
+ // / \param class_to_declared_symbols: map classes to the symbols that
1157
+ // / they declare.
1134
1158
bool java_bytecode_languaget::convert_single_method (
1135
1159
const irep_idt &function_id,
1136
1160
symbol_table_baset &symbol_table,
1137
- optionalt<ci_lazy_methods_neededt> needed_lazy_methods)
1161
+ optionalt<ci_lazy_methods_neededt> needed_lazy_methods,
1162
+ lazy_class_to_declared_symbols_mapt &class_to_declared_symbols)
1138
1163
{
1139
1164
// Do not convert if method is not in context
1140
1165
if (method_in_context && !(*method_in_context)(id2string (function_id)))
@@ -1212,16 +1237,14 @@ bool java_bytecode_languaget::convert_single_method(
1212
1237
class_name, " user_specified_clinit must be declared by a class." );
1213
1238
INVARIANT (
1214
1239
static_values_json.has_value (), " static-values JSON must be available" );
1215
- const auto class_to_declared_symbols_map =
1216
- class_to_declared_symbols (symbol_table);
1217
1240
writable_symbol.value = get_user_specified_clinit_body (
1218
1241
*class_name,
1219
1242
*static_values_json,
1220
1243
symbol_table,
1221
1244
needed_lazy_methods,
1222
1245
max_user_array_length,
1223
1246
references,
1224
- class_to_declared_symbols_map );
1247
+ class_to_declared_symbols. get (symbol_table) );
1225
1248
break ;
1226
1249
}
1227
1250
case synthetic_method_typet::STUB_CLASS_STATIC_INITIALIZER:
0 commit comments