Skip to content

Add support for recording and propagating class access flags #1000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion src/java_bytecode/java_bytecode_convert_class.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ void java_bytecode_convert_classt::convert(const classt &c)
return;
}

class_typet class_type;
java_class_typet class_type;

class_type.set_tag(c.name);
class_type.set(ID_base_name, c.name);
Expand All @@ -98,6 +98,15 @@ void java_bytecode_convert_classt::convert(const classt &c)
class_type.set(ID_enumeration, true);
}

if(c.is_public)
class_type.set_access(ID_public);
else if(c.is_protected)
class_type.set_access(ID_protected);
else if(c.is_private)
class_type.set_access(ID_private);
else
class_type.set_access(ID_default);

if(!c.extends.empty())
{
symbol_typet base("java::"+id2string(c.extends));
Expand Down
3 changes: 3 additions & 0 deletions src/java_bytecode/java_bytecode_parse_tree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ void java_bytecode_parse_treet::classt::swap(
std::swap(other.is_enum, is_enum);
std::swap(other.enum_elements, enum_elements);
std::swap(other.is_abstract, is_abstract);
std::swap(other.is_public, is_public);
std::swap(other.is_protected, is_protected);
std::swap(other.is_private, is_private);
other.implements.swap(implements);
other.fields.swap(fields);
other.methods.swap(methods);
Expand Down
1 change: 1 addition & 0 deletions src/java_bytecode/java_bytecode_parse_tree.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class java_bytecode_parse_treet
irep_idt name, extends;
bool is_abstract=false;
bool is_enum=false;
bool is_public=false, is_protected=false, is_private=false;
size_t enum_elements=0;

typedef std::list<irep_idt> implementst;
Expand Down
3 changes: 3 additions & 0 deletions src/java_bytecode/java_bytecode_parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ void java_bytecode_parsert::rClassFile()

parsed_class.is_abstract=(access_flags&ACC_ABSTRACT)!=0;
parsed_class.is_enum=(access_flags&ACC_ENUM)!=0;
parsed_class.is_public=(access_flags&ACC_PUBLIC)!=0;
parsed_class.is_protected=(access_flags&ACC_PROTECTED)!=0;
parsed_class.is_private=(access_flags&ACC_PRIVATE)!=0;
parsed_class.name=
constant(this_class).type().get(ID_C_base_name);

Expand Down
26 changes: 26 additions & 0 deletions src/java_bytecode/java_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,32 @@ Author: Daniel Kroening, [email protected]
#include <util/type.h>
#include <util/std_types.h>

class java_class_typet:public class_typet
{
public:
const irep_idt &get_access() const
{
return get(ID_access);
}

void set_access(const irep_idt &access)
{
return set(ID_access, access);
}
};

inline const java_class_typet &to_java_class_type(const typet &type)
{
assert(type.id()==ID_struct);
return static_cast<const java_class_typet &>(type);
}

inline java_class_typet &to_java_class_type(typet &type)
{
assert(type.id()==ID_struct);
return static_cast<java_class_typet &>(type);
}

typet java_int_type();
typet java_long_type();
typet java_short_type();
Expand Down