Skip to content

Commit e89f5e4

Browse files
[string-preprocess] Refactor java_types_matches_tag
1 parent 2505982 commit e89f5e4

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

src/java_bytecode/java_string_library_preprocess.cpp

+13-11
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,26 @@ Date: April 2017
3030

3131
#include "java_string_library_preprocess.h"
3232

33+
/// \return tag of a struct prefixed by "java::" or symbolic tag
34+
/// empty string if not symbol or struct
35+
irep_idt get_tag(const typet &type)
36+
{
37+
if(type.id() == ID_symbol)
38+
return to_symbol_type(type).get_identifier();
39+
else if(type.id() == ID_struct)
40+
return irep_idt("java::" + id2string(to_struct_type(type).get_tag()));
41+
else
42+
return "";
43+
}
44+
3345
/// \param type: a type
3446
/// \param tag: a string
3547
/// \return Boolean telling whether the type is a struct with the given tag or a
3648
/// symbolic type with the tag prefixed by "java::"
3749
bool java_string_library_preprocesst::java_type_matches_tag(
3850
const typet &type, const std::string &tag)
3951
{
40-
if(type.id()==ID_symbol)
41-
{
42-
irep_idt tag_id=to_symbol_type(type).get_identifier();
43-
return tag_id=="java::"+tag;
44-
}
45-
else if(type.id()==ID_struct)
46-
{
47-
irep_idt tag_id=to_struct_type(type).get_tag();
48-
return tag_id==tag;
49-
}
50-
return false;
52+
return irep_idt("java::" + tag) == get_tag(type);
5153
}
5254

5355
/// \param type: a type

0 commit comments

Comments
 (0)