Skip to content

Commit c69b00d

Browse files
Rename things to better reflect true meaning
1 parent c99c2e4 commit c69b00d

11 files changed

+126
-126
lines changed

src/java_bytecode/ci_lazy_methods.cpp

+34-34
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ ci_lazy_methodst::ci_lazy_methodst(
6161
/// from the main entry point (usually provided with the --function command-
6262
/// line option
6363
/// \param symbol_table: global symbol table
64-
/// \param [out] lazy_methods: map from method names to relevant symbol and
64+
/// \param [out] method_bytecode: map from method names to relevant symbol and
6565
/// parsed-method objects.
6666
/// \param method_converter: Function for converting methods on demand.
6767
/// \return Returns false on success
6868
bool ci_lazy_methodst::operator()(
6969
symbol_tablet &symbol_table,
70-
lazy_methodst &lazy_methods,
70+
method_bytecodet &method_bytecode,
7171
method_convertert method_converter)
7272
{
7373
std::vector<irep_idt> method_worklist1;
@@ -141,8 +141,8 @@ bool ci_lazy_methodst::operator()(
141141
{
142142
if(!methods_already_populated.insert(mname).second)
143143
continue;
144-
auto findit=lazy_methods.find(mname);
145-
if(findit==lazy_methods.end())
144+
auto findit = method_bytecode.find(mname);
145+
if(findit == method_bytecode.end())
146146
{
147147
debug() << "Skip " << mname << eom;
148148
continue;
@@ -191,8 +191,9 @@ bool ci_lazy_methodst::operator()(
191191
{
192192
if(sym.second.is_static_lifetime)
193193
continue;
194-
if(lazy_methods.count(sym.first) &&
195-
!methods_already_populated.count(sym.first))
194+
if(
195+
method_bytecode.count(sym.first) &&
196+
!methods_already_populated.count(sym.first))
196197
{
197198
continue;
198199
}
@@ -263,13 +264,13 @@ void ci_lazy_methodst::resolve_method_names(
263264
/// \param entry_points: list of fully-qualified function names that
264265
/// we should assume are reachable
265266
/// \param ns: global namespace
266-
/// \param [out] lazy_methods: Populated with all Java reference types whose
267-
/// references may be passed, directly or indirectly, to any of the functions
268-
/// in `entry_points`.
267+
/// \param [out] needed_lazy_methods: Populated with all Java reference types
268+
/// whose references may be passed, directly or indirectly, to any of the
269+
/// functions in `entry_points`.
269270
void ci_lazy_methodst::initialize_needed_classes(
270271
const std::vector<irep_idt> &entry_points,
271272
const namespacet &ns,
272-
ci_lazy_methods_neededt &lazy_methods)
273+
ci_lazy_methods_neededt &needed_lazy_methods)
273274
{
274275
for(const auto &mname : entry_points)
275276
{
@@ -281,67 +282,66 @@ void ci_lazy_methodst::initialize_needed_classes(
281282
{
282283
const pointer_typet &original_pointer=to_pointer_type(param.type());
283284
initialize_all_needed_classes_from_pointer(
284-
original_pointer, ns, lazy_methods);
285+
original_pointer, ns, needed_lazy_methods);
285286
}
286287
}
287288
}
288289

289290
// Also add classes whose instances are magically
290291
// created by the JVM and so won't be spotted by
291292
// looking for constructors and calls as usual:
292-
lazy_methods.add_needed_class("java::java.lang.String");
293-
lazy_methods.add_needed_class("java::java.lang.Class");
294-
lazy_methods.add_needed_class("java::java.lang.Object");
293+
needed_lazy_methods.add_needed_class("java::java.lang.String");
294+
needed_lazy_methods.add_needed_class("java::java.lang.Class");
295+
needed_lazy_methods.add_needed_class("java::java.lang.Object");
295296

296297
// As in class_loader, ensure these classes stay available
297298
for(const auto &id : extra_needed_classes)
298-
lazy_methods.add_needed_class("java::" + id2string(id));
299+
needed_lazy_methods.add_needed_class("java::" + id2string(id));
299300
}
300301

301302
/// Build up list of methods for types for a pointer and any types it
302303
/// might be subsituted for. See
303304
/// `initialize_needed_classes` for more details.
304305
/// \param pointer_type: The type to gather methods for.
305306
/// \param ns: global namespace
306-
/// \param [out] lazy_methods: Populated with all Java reference types whose
307-
/// references may be passed, directly or indirectly, to any of the functions
308-
/// in `entry_points
307+
/// \param [out] needed_lazy_methods: Populated with all Java reference types
308+
/// whose references may be passed, directly or indirectly, to any of the
309+
/// functions in `entry_points`
309310
void ci_lazy_methodst::initialize_all_needed_classes_from_pointer(
310311
const pointer_typet &pointer_type,
311312
const namespacet &ns,
312-
ci_lazy_methods_neededt &lazy_methods)
313+
ci_lazy_methods_neededt &needed_lazy_methods)
313314
{
314-
initialize_needed_classes_from_pointer(
315-
pointer_type, ns, lazy_methods);
315+
initialize_needed_classes_from_pointer(pointer_type, ns, needed_lazy_methods);
316316

317317
const pointer_typet &subbed_pointer_type=
318318
pointer_type_selector.convert_pointer_type(pointer_type, ns);
319319

320320
if(subbed_pointer_type!=pointer_type)
321321
{
322322
initialize_needed_classes_from_pointer(
323-
subbed_pointer_type, ns, lazy_methods);
323+
subbed_pointer_type, ns, needed_lazy_methods);
324324
}
325325
}
326326

327327
/// Build up list of methods for types for a specific pointer type. See
328328
/// `initialize_needed_classes` for more details.
329329
/// \param pointer_type: The type to gather methods for.
330330
/// \param ns: global namespace
331-
/// \param [out] lazy_methods: Populated with all Java reference types whose
332-
/// references may be passed, directly or indirectly, to any of the functions
333-
/// in `entry_points
331+
/// \param [out] needed_lazy_methods: Populated with all Java reference types
332+
/// whose references may be passed, directly or indirectly, to any of the
333+
/// functions in `entry_points`
334334
void ci_lazy_methodst::initialize_needed_classes_from_pointer(
335335
const pointer_typet &pointer_type,
336336
const namespacet &ns,
337-
ci_lazy_methods_neededt &lazy_methods)
337+
ci_lazy_methods_neededt &needed_lazy_methods)
338338
{
339339
const symbol_typet &class_type=to_symbol_type(pointer_type.subtype());
340340
const auto &param_classid=class_type.get_identifier();
341341

342-
if(lazy_methods.add_needed_class(param_classid))
342+
if(needed_lazy_methods.add_needed_class(param_classid))
343343
{
344-
gather_field_types(pointer_type.subtype(), ns, lazy_methods);
344+
gather_field_types(pointer_type.subtype(), ns, needed_lazy_methods);
345345
}
346346
}
347347

@@ -462,30 +462,30 @@ void ci_lazy_methodst::gather_needed_globals(
462462
gather_needed_globals(*opit, symbol_table, needed);
463463
}
464464

465-
/// See param lazy_methods
465+
/// See param needed_lazy_methods
466466
/// \param class_type: root of class tree to search
467467
/// \param ns: global namespace
468-
/// \param [out] lazy_methods: Popualted with all Java reference types reachable
469-
/// starting at `class_type`. For example if `class_type` is
468+
/// \param [out] needed_lazy_methods: Popualted with all Java reference types
469+
/// reachable starting at `class_type`. For example if `class_type` is
470470
/// `symbol_typet("java::A")` and A has a B field, then `B` (but not `A`) will
471471
/// noted as a needed class.
472472
void ci_lazy_methodst::gather_field_types(
473473
const typet &class_type,
474474
const namespacet &ns,
475-
ci_lazy_methods_neededt &lazy_methods)
475+
ci_lazy_methods_neededt &needed_lazy_methods)
476476
{
477477
const auto &underlying_type=to_struct_type(ns.follow(class_type));
478478
for(const auto &field : underlying_type.components())
479479
{
480480
if(field.type().id()==ID_struct || field.type().id()==ID_symbol)
481-
gather_field_types(field.type(), ns, lazy_methods);
481+
gather_field_types(field.type(), ns, needed_lazy_methods);
482482
else if(field.type().id()==ID_pointer)
483483
{
484484
// Skip array primitive pointers, for example:
485485
if(field.type().subtype().id()!=ID_symbol)
486486
continue;
487487
initialize_all_needed_classes_from_pointer(
488-
to_pointer_type(field.type()), ns, lazy_methods);
488+
to_pointer_type(field.type()), ns, needed_lazy_methods);
489489
}
490490
}
491491
}

src/java_bytecode/ci_lazy_methods.h

+12-13
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,11 @@
2626

2727
class java_string_library_preprocesst;
2828

29-
typedef std::pair<
30-
const symbolt *,
31-
const java_bytecode_parse_treet::methodt *>
32-
lazy_method_valuet;
33-
34-
typedef std::map<irep_idt, lazy_method_valuet>
35-
lazy_methodst;
29+
// Pair of class id and methodt
30+
typedef std::pair<const symbolt *, 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;
3634

3735
typedef std::function<void(
3836
const symbolt &,
@@ -55,7 +53,7 @@ class ci_lazy_methodst:public messaget
5553
// not const since messaget
5654
bool operator()(
5755
symbol_tablet &symbol_table,
58-
lazy_methodst &lazy_methods,
56+
method_bytecodet &method_bytecode,
5957
method_convertert method_converter);
6058

6159
private:
@@ -66,17 +64,17 @@ class ci_lazy_methodst:public messaget
6664
void initialize_needed_classes(
6765
const std::vector<irep_idt> &entry_points,
6866
const namespacet &ns,
69-
ci_lazy_methods_neededt &lazy_methods);
67+
ci_lazy_methods_neededt &needed_lazy_methods);
7068

7169
void initialize_all_needed_classes_from_pointer(
7270
const pointer_typet &pointer_type,
7371
const namespacet &ns,
74-
ci_lazy_methods_neededt &lazy_methods);
72+
ci_lazy_methods_neededt &needed_lazy_methods);
7573

7674
void initialize_needed_classes_from_pointer(
7775
const pointer_typet &pointer_type,
7876
const namespacet &ns,
79-
ci_lazy_methods_neededt &lazy_methods);
77+
ci_lazy_methods_neededt &needed_lazy_methods);
8078

8179
void gather_virtual_callsites(
8280
const exprt &e,
@@ -93,9 +91,10 @@ class ci_lazy_methodst:public messaget
9391
const symbol_tablet &symbol_table,
9492
symbol_tablet &needed);
9593

96-
void gather_field_types(const typet &class_type,
94+
void gather_field_types(
95+
const typet &class_type,
9796
const namespacet &ns,
98-
ci_lazy_methods_neededt &lazy_methods);
97+
ci_lazy_methods_neededt &needed_lazy_methods);
9998

10099
irep_idt get_virtual_method_target(
101100
const std::set<irep_idt> &needed_classes,

src/java_bytecode/java_bytecode_convert_class.cpp

+12-12
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ class java_bytecode_convert_classt:public messaget
3535
symbol_tablet &_symbol_table,
3636
message_handlert &_message_handler,
3737
size_t _max_array_length,
38-
lazy_methodst& _lazy_methods,
38+
method_bytecodet &method_bytecode,
3939
lazy_methods_modet _lazy_methods_mode,
40-
java_string_library_preprocesst &_string_preprocess):
41-
messaget(_message_handler),
42-
symbol_table(_symbol_table),
43-
max_array_length(_max_array_length),
44-
lazy_methods(_lazy_methods),
45-
lazy_methods_mode(_lazy_methods_mode),
46-
string_preprocess(_string_preprocess)
40+
java_string_library_preprocesst &_string_preprocess)
41+
: messaget(_message_handler),
42+
symbol_table(_symbol_table),
43+
max_array_length(_max_array_length),
44+
method_bytecode(method_bytecode),
45+
lazy_methods_mode(_lazy_methods_mode),
46+
string_preprocess(_string_preprocess)
4747
{
4848
}
4949

@@ -73,7 +73,7 @@ class java_bytecode_convert_classt:public messaget
7373
protected:
7474
symbol_tablet &symbol_table;
7575
const size_t max_array_length;
76-
lazy_methodst &lazy_methods;
76+
method_bytecodet &method_bytecode;
7777
lazy_methods_modet lazy_methods_mode;
7878
java_string_library_preprocesst &string_preprocess;
7979

@@ -205,7 +205,7 @@ void java_bytecode_convert_classt::convert(const classt &c)
205205
method,
206206
symbol_table,
207207
get_message_handler());
208-
lazy_methods[method_identifier]=std::make_pair(class_symbol, &method);
208+
method_bytecode[method_identifier] = std::make_pair(class_symbol, &method);
209209
}
210210

211211
// is this a root class?
@@ -483,15 +483,15 @@ bool java_bytecode_convert_class(
483483
symbol_tablet &symbol_table,
484484
message_handlert &message_handler,
485485
size_t max_array_length,
486-
lazy_methodst &lazy_methods,
486+
method_bytecodet &method_bytecode,
487487
lazy_methods_modet lazy_methods_mode,
488488
java_string_library_preprocesst &string_preprocess)
489489
{
490490
java_bytecode_convert_classt java_bytecode_convert_class(
491491
symbol_table,
492492
message_handler,
493493
max_array_length,
494-
lazy_methods,
494+
method_bytecode,
495495
lazy_methods_mode,
496496
string_preprocess);
497497

src/java_bytecode/java_bytecode_convert_class.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ bool java_bytecode_convert_class(
2424
symbol_tablet &symbol_table,
2525
message_handlert &message_handler,
2626
size_t max_array_length,
27-
lazy_methodst &,
27+
method_bytecodet &,
2828
lazy_methods_modet,
2929
java_string_library_preprocesst &string_preprocess);
3030

src/java_bytecode/java_bytecode_convert_method.cpp

+13-13
Original file line numberDiff line numberDiff line change
@@ -1429,8 +1429,8 @@ codet java_bytecode_convert_methodt::convert_instructions(
14291429
if(as_string(arg0.get(ID_identifier))
14301430
.find("<init>")!=std::string::npos)
14311431
{
1432-
if(lazy_methods)
1433-
lazy_methods->add_needed_class(classname);
1432+
if(needed_lazy_methods)
1433+
needed_lazy_methods->add_needed_class(classname);
14341434
code_type.set(ID_constructor, true);
14351435
}
14361436
else
@@ -1548,11 +1548,11 @@ codet java_bytecode_convert_methodt::convert_instructions(
15481548
{
15491549
// static binding
15501550
call.function()=symbol_exprt(arg0.get(ID_identifier), arg0.type());
1551-
if(lazy_methods)
1551+
if(needed_lazy_methods)
15521552
{
1553-
lazy_methods->add_needed_method(arg0.get(ID_identifier));
1553+
needed_lazy_methods->add_needed_method(arg0.get(ID_identifier));
15541554
// Calling a static method causes static initialization:
1555-
lazy_methods->add_needed_class(arg0.get(ID_C_class));
1555+
needed_lazy_methods->add_needed_class(arg0.get(ID_C_class));
15561556
}
15571557
}
15581558

@@ -2180,25 +2180,25 @@ codet java_bytecode_convert_methodt::convert_instructions(
21802180
// If external, create a symbol table entry for this static field:
21812181
check_static_field_stub(symbol_expr, field_name);
21822182

2183-
if(lazy_methods)
2183+
if(needed_lazy_methods)
21842184
{
21852185
if(arg0.type().id()==ID_symbol)
21862186
{
2187-
lazy_methods->add_needed_class(
2187+
needed_lazy_methods->add_needed_class(
21882188
to_symbol_type(arg0.type()).get_identifier());
21892189
}
21902190
else if(arg0.type().id()==ID_pointer)
21912191
{
21922192
const auto &pointer_type=to_pointer_type(arg0.type());
21932193
if(pointer_type.subtype().id()==ID_symbol)
21942194
{
2195-
lazy_methods->add_needed_class(
2195+
needed_lazy_methods->add_needed_class(
21962196
to_symbol_type(pointer_type.subtype()).get_identifier());
21972197
}
21982198
}
21992199
else if(is_assertions_disabled_field)
22002200
{
2201-
lazy_methods->add_needed_class(arg0.get_string(ID_class));
2201+
needed_lazy_methods->add_needed_class(arg0.get_string(ID_class));
22022202
}
22032203
}
22042204
results[0]=java_bytecode_promotion(symbol_expr);
@@ -2235,9 +2235,9 @@ codet java_bytecode_convert_methodt::convert_instructions(
22352235
// If external, create a symbol table entry for this static field:
22362236
check_static_field_stub(symbol_expr, field_name);
22372237

2238-
if(lazy_methods && arg0.type().id()==ID_symbol)
2238+
if(needed_lazy_methods && arg0.type().id() == ID_symbol)
22392239
{
2240-
lazy_methods->add_needed_class(
2240+
needed_lazy_methods->add_needed_class(
22412241
to_symbol_type(arg0.type()).get_identifier());
22422242
}
22432243

@@ -2850,7 +2850,7 @@ void java_bytecode_convert_method(
28502850
symbol_tablet &symbol_table,
28512851
message_handlert &message_handler,
28522852
size_t max_array_length,
2853-
safe_pointer<ci_lazy_methods_neededt> lazy_methods,
2853+
safe_pointer<ci_lazy_methods_neededt> needed_lazy_methods,
28542854
java_string_library_preprocesst &string_preprocess)
28552855
{
28562856
static const std::unordered_set<std::string> methods_to_ignore
@@ -2881,7 +2881,7 @@ void java_bytecode_convert_method(
28812881
symbol_table,
28822882
message_handler,
28832883
max_array_length,
2884-
lazy_methods,
2884+
needed_lazy_methods,
28852885
string_preprocess);
28862886

28872887
java_bytecode_convert_method(class_symbol, method);

0 commit comments

Comments
 (0)