Skip to content

Commit cc98932

Browse files
Simplification
Moved pool_entryt typedef earlier to use it in two more places Use existing functions is_java_array_tag and java_array_element_type Changed control flow to remove redundant check
1 parent fab409d commit cc98932

File tree

1 file changed

+11
-18
lines changed

1 file changed

+11
-18
lines changed

jbmc/src/java_bytecode/java_bytecode_parser.cpp

Lines changed: 11 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,10 @@ class java_bytecode_parsert final : public parsert
182182
class structured_pool_entryt
183183
{
184184
public:
185-
explicit structured_pool_entryt(java_bytecode_parsert::pool_entryt entry)
186-
: tag(entry.tag)
185+
using pool_entryt = java_bytecode_parsert::pool_entryt;
186+
using pool_entry_lookupt = std::function<pool_entryt &(u2)>;
187+
188+
explicit structured_pool_entryt(pool_entryt entry) : tag(entry.tag)
187189
{
188190
}
189191

@@ -192,10 +194,6 @@ class structured_pool_entryt
192194
return tag;
193195
}
194196

195-
using pool_entry_lookupt =
196-
std::function<java_bytecode_parsert::pool_entryt &(u2)>;
197-
using pool_entryt = java_bytecode_parsert::pool_entryt;
198-
199197
protected:
200198
static std::string read_utf8_constant(const pool_entryt &entry)
201199
{
@@ -234,7 +232,7 @@ class class_infot : public structured_pool_entryt
234232
class name_and_type_infot : public structured_pool_entryt
235233
{
236234
public:
237-
explicit name_and_type_infot(java_bytecode_parsert::pool_entryt entry)
235+
explicit name_and_type_infot(pool_entryt entry)
238236
: structured_pool_entryt(entry)
239237
{
240238
PRECONDITION(entry.tag == CONSTANT_NameAndType);
@@ -323,7 +321,7 @@ class method_handle_infot : public structured_pool_entryt
323321
REF_invokeInterface = 9
324322
};
325323

326-
explicit method_handle_infot(java_bytecode_parsert::pool_entryt entry)
324+
explicit method_handle_infot(pool_entryt entry)
327325
: structured_pool_entryt(entry)
328326
{
329327
PRECONDITION(entry.tag == CONSTANT_MethodHandle);
@@ -588,15 +586,11 @@ void java_bytecode_parsert::get_class_refs_rec(const typet &src)
588586
}
589587
else if(src.id() == ID_struct_tag)
590588
{
591-
irep_idt name=src.get(ID_C_base_name);
592-
if(has_prefix(id2string(name), "array["))
593-
{
594-
const typet &element_type =
595-
static_cast<const typet &>(src.find(ID_element_type));
596-
get_class_refs_rec(element_type);
597-
}
589+
const struct_tag_typet &struct_tag_type = to_struct_tag_type(src);
590+
if(is_java_array_tag(struct_tag_type.get_identifier()))
591+
get_class_refs_rec(java_array_element_type(struct_tag_type));
598592
else
599-
parse_tree.class_refs.insert(name);
593+
parse_tree.class_refs.insert(src.get(ID_C_base_name));
600594
}
601595
else if(src.id()==ID_struct)
602596
{
@@ -1643,10 +1637,9 @@ void java_bytecode_parsert::rinner_classes_attribute(
16431637
// access information and mark it as an inner class.
16441638
bool is_inner_class = remove_separator_char(id2string(parsed_class.name), '.') ==
16451639
remove_separator_char(inner_class_info_name, '/');
1646-
if(is_inner_class)
1647-
parsed_class.is_inner_class = is_inner_class;
16481640
if(!is_inner_class)
16491641
continue;
1642+
parsed_class.is_inner_class = is_inner_class;
16501643
parsed_class.is_static_class = is_static;
16511644
// This is a marker that a class is anonymous.
16521645
if(inner_name_index == 0)

0 commit comments

Comments
 (0)