Skip to content

Commit 263089c

Browse files
committed
Name method handles uniformly
They are method handles not references, and their varieties are kinds not types
1 parent 6cc4d04 commit 263089c

File tree

4 files changed

+36
-36
lines changed

4 files changed

+36
-36
lines changed

jbmc/src/java_bytecode/java_bytecode_parse_tree.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -228,21 +228,21 @@ struct java_bytecode_parse_treet
228228
typedef std::vector<u2> u2_valuest;
229229
struct lambda_method_handlet
230230
{
231-
java_class_typet::method_handle_typet handle_type;
231+
java_class_typet::method_handle_kindt handle_type;
232232
optionalt<class_method_descriptor_exprt> method_descriptor;
233233

234234
/// Construct a lambda method handle with parameters \p params.
235235
lambda_method_handlet(
236236
const class_method_descriptor_exprt &method_descriptor,
237-
java_class_typet::method_handle_typet handle_type)
237+
java_class_typet::method_handle_kindt handle_type)
238238
: handle_type(handle_type), method_descriptor(method_descriptor)
239239
{
240240
PRECONDITION(
241-
handle_type != java_class_typet::method_handle_typet::UNKNOWN_HANDLE);
241+
handle_type != java_class_typet::method_handle_kindt::UNKNOWN_HANDLE);
242242
}
243243

244244
lambda_method_handlet()
245-
: handle_type(java_class_typet::method_handle_typet::UNKNOWN_HANDLE),
245+
: handle_type(java_class_typet::method_handle_kindt::UNKNOWN_HANDLE),
246246
method_descriptor()
247247
{
248248
}
@@ -255,7 +255,7 @@ struct java_bytecode_parse_treet
255255
bool is_unknown_handle() const
256256
{
257257
return handle_type ==
258-
java_class_typet::method_handle_typet::UNKNOWN_HANDLE;
258+
java_class_typet::method_handle_kindt::UNKNOWN_HANDLE;
259259
}
260260

261261
const class_method_descriptor_exprt &get_method_descriptor() const

jbmc/src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class java_bytecode_parsert final : public parsert
5454
using fieldt = java_bytecode_parse_treet::fieldt;
5555
using instructiont = java_bytecode_parse_treet::instructiont;
5656
using annotationt = java_bytecode_parse_treet::annotationt;
57-
using method_handle_typet = java_class_typet::method_handle_typet;
57+
using method_handle_typet = java_class_typet::method_handle_kindt;
5858
using lambda_method_handlet =
5959
java_bytecode_parse_treet::classt::lambda_method_handlet;
6060

@@ -302,7 +302,7 @@ class base_ref_infot : public structured_pool_entryt
302302
class method_handle_infot : public structured_pool_entryt
303303
{
304304
public:
305-
/// Correspond to the different valid values for field reference_kind From
305+
/// Correspond to the different valid values for field handle_kind From
306306
/// Java 8 spec 4.4.8
307307
/// (https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html)
308308
enum class method_handle_kindt
@@ -323,21 +323,21 @@ class method_handle_infot : public structured_pool_entryt
323323
{
324324
PRECONDITION(entry.tag == CONSTANT_MethodHandle);
325325
PRECONDITION(entry.ref1 > 0 && entry.ref1 < 10); // Java 8 spec 4.4.8
326-
reference_kind = static_cast<method_handle_kindt>(entry.ref1);
326+
handle_kind = static_cast<method_handle_kindt>(entry.ref1);
327327
reference_index = entry.ref2;
328328
}
329329

330-
method_handle_kindt get_reference_kind() const
330+
method_handle_kindt get_handle_kind() const
331331
{
332-
return reference_kind;
332+
return handle_kind;
333333
}
334334

335335
base_ref_infot get_reference(const pool_entry_lookupt &pool_entry) const
336336
{
337337
const base_ref_infot ref_entry{pool_entry(reference_index)};
338338

339339
// validate the correctness of the constant pool entry
340-
switch(reference_kind)
340+
switch(handle_kind)
341341
{
342342
case method_handle_kindt::REF_getField:
343343
case method_handle_kindt::REF_getStatic:
@@ -373,7 +373,7 @@ class method_handle_infot : public structured_pool_entryt
373373
}
374374

375375
private:
376-
method_handle_kindt reference_kind;
376+
method_handle_kindt handle_kind;
377377
u2 reference_index;
378378
};
379379

@@ -1887,25 +1887,25 @@ void java_bytecode_parsert::parse_local_variable_type_table(methodt &method)
18871887
/// newinvokespecial translates into a special instantiate-and-construct
18881888
/// sequence. The field-manipulation reference kinds appear never to happen in
18891889
/// reality and don't have syntax in the Java language.
1890-
static java_class_typet::method_handle_typet get_method_handle_type(
1890+
static java_class_typet::method_handle_kindt get_method_handle_type(
18911891
method_handle_infot::method_handle_kindt java_handle_kind)
18921892
{
18931893
switch(java_handle_kind)
18941894
{
18951895
case method_handle_infot::method_handle_kindt::REF_newInvokeSpecial:
1896-
return java_class_typet::method_handle_typet::LAMBDA_CONSTRUCTOR_HANDLE;
1896+
return java_class_typet::method_handle_kindt::LAMBDA_CONSTRUCTOR_HANDLE;
18971897
case method_handle_infot::method_handle_kindt::REF_invokeInterface:
18981898
case method_handle_infot::method_handle_kindt::REF_invokeVirtual:
1899-
return java_class_typet::method_handle_typet::LAMBDA_VIRTUAL_METHOD_HANDLE;
1899+
return java_class_typet::method_handle_kindt::LAMBDA_VIRTUAL_METHOD_HANDLE;
19001900
case method_handle_infot::method_handle_kindt::REF_invokeStatic:
19011901
case method_handle_infot::method_handle_kindt::REF_invokeSpecial:
1902-
return java_class_typet::method_handle_typet::LAMBDA_STATIC_METHOD_HANDLE;
1902+
return java_class_typet::method_handle_kindt::LAMBDA_STATIC_METHOD_HANDLE;
19031903
case method_handle_infot::method_handle_kindt::REF_getField:
19041904
case method_handle_infot::method_handle_kindt::REF_getStatic:
19051905
case method_handle_infot::method_handle_kindt::REF_putField:
19061906
case method_handle_infot::method_handle_kindt::REF_putStatic:
19071907
default:
1908-
return java_class_typet::method_handle_typet::UNKNOWN_HANDLE;
1908+
return java_class_typet::method_handle_kindt::UNKNOWN_HANDLE;
19091909
}
19101910
}
19111911

@@ -1937,13 +1937,13 @@ java_bytecode_parsert::parse_method_handle(const method_handle_infot &entry)
19371937
// they ever turn up this is where to fix them.
19381938

19391939
if(
1940-
entry.get_reference_kind() ==
1940+
entry.get_handle_kind() ==
19411941
method_handle_infot::method_handle_kindt::REF_getField ||
1942-
entry.get_reference_kind() ==
1942+
entry.get_handle_kind() ==
19431943
method_handle_infot::method_handle_kindt::REF_putField ||
1944-
entry.get_reference_kind() ==
1944+
entry.get_handle_kind() ==
19451945
method_handle_infot::method_handle_kindt::REF_getStatic ||
1946-
entry.get_reference_kind() ==
1946+
entry.get_handle_kind() ==
19471947
method_handle_infot::method_handle_kindt::REF_putStatic)
19481948
{
19491949
return {};
@@ -1958,7 +1958,7 @@ java_bytecode_parsert::parse_method_handle(const method_handle_infot &entry)
19581958
typet method_type = *java_type_from_string(descriptor);
19591959

19601960
method_handle_typet handle_type =
1961-
get_method_handle_type(entry.get_reference_kind());
1961+
get_method_handle_type(entry.get_handle_kind());
19621962

19631963
class_method_descriptor_exprt method_descriptor{
19641964
method_type, mangled_method_name, class_name, method_name};

jbmc/src/java_bytecode/java_types.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ class java_class_typet:public class_typet
451451
}
452452

453453
/// Indicates what sort of code should be synthesised for a lambda call:
454-
enum class method_handle_typet
454+
enum class method_handle_kindt
455455
{
456456
/// Direct call to the given method
457457
LAMBDA_STATIC_METHOD_HANDLE,
@@ -466,23 +466,23 @@ class java_class_typet:public class_typet
466466
/// Represents a lambda call to a method. We store the method being called in
467467
/// the same class_method_descriptor_exprt as java_bytecode_convert_method
468468
/// uses to translate virtual method calls to denote the method targeted, and
469-
/// use method_handle_typet above to indicate what kind of dispatch should be
469+
/// use method_handle_kindt above to indicate what kind of dispatch should be
470470
/// used.
471471
class java_lambda_method_handlet : public irept
472472
{
473473
public:
474474
java_lambda_method_handlet(
475475
const class_method_descriptor_exprt &method_descriptor,
476-
method_handle_typet handle_type)
476+
method_handle_kindt handle_kind)
477477
{
478478
set(ID_object_descriptor, method_descriptor);
479-
set(ID_handle_type, static_cast<int>(handle_type));
479+
set(ID_handle_type, static_cast<int>(handle_kind));
480480
}
481481

482482
java_lambda_method_handlet()
483483
{
484484
set(
485-
ID_handle_type, static_cast<int>(method_handle_typet::UNKNOWN_HANDLE));
485+
ID_handle_type, static_cast<int>(method_handle_kindt::UNKNOWN_HANDLE));
486486
}
487487

488488
const class_method_descriptor_exprt &get_lambda_method_descriptor() const
@@ -496,9 +496,9 @@ class java_class_typet:public class_typet
496496
return get_lambda_method_descriptor().get_identifier();
497497
}
498498

499-
method_handle_typet get_handle_type() const
499+
method_handle_kindt get_handle_kind() const
500500
{
501-
return (method_handle_typet)get_int(ID_handle_type);
501+
return (method_handle_kindt)get_int(ID_handle_type);
502502
}
503503
};
504504

@@ -519,10 +519,10 @@ class java_class_typet:public class_typet
519519

520520
void add_lambda_method_handle(
521521
const class_method_descriptor_exprt &method_descriptor,
522-
method_handle_typet handle_type)
522+
method_handle_kindt handle_kind)
523523
{
524524
// creates a symbol_exprt for the identifier and pushes it in the vector
525-
lambda_method_handles().emplace_back(method_descriptor, handle_type);
525+
lambda_method_handles().emplace_back(method_descriptor, handle_kind);
526526
}
527527
void add_unknown_lambda_method_handle()
528528
{

jbmc/src/java_bytecode/lambda_synthesis.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,8 @@ get_lambda_method_handle(
6767
// If the lambda method handle has an unknown type, it does not refer to
6868
// any symbol (it has an empty identifier)
6969
if(
70-
lambda_method_handle.get_handle_type() !=
71-
java_class_typet::method_handle_typet::UNKNOWN_HANDLE)
70+
lambda_method_handle.get_handle_kind() !=
71+
java_class_typet::method_handle_kindt::UNKNOWN_HANDLE)
7272
return lambda_method_handle;
7373
return {};
7474
}
@@ -656,13 +656,13 @@ codet invokedynamic_synthetic_method(
656656

657657
const auto &lambda_method_symbol =
658658
ns.lookup(lambda_method_handle.get_lambda_method_identifier());
659-
const auto handle_type = lambda_method_handle.get_handle_type();
659+
const auto handle_type = lambda_method_handle.get_handle_kind();
660660
const auto is_constructor_lambda =
661661
handle_type ==
662-
java_class_typet::method_handle_typet::LAMBDA_CONSTRUCTOR_HANDLE;
662+
java_class_typet::method_handle_kindt::LAMBDA_CONSTRUCTOR_HANDLE;
663663
const auto use_virtual_dispatch =
664664
handle_type ==
665-
java_class_typet::method_handle_typet::LAMBDA_VIRTUAL_METHOD_HANDLE;
665+
java_class_typet::method_handle_kindt::LAMBDA_VIRTUAL_METHOD_HANDLE;
666666

667667
if(is_constructor_lambda)
668668
{

0 commit comments

Comments
 (0)