Skip to content

Java class typet methodt #4618

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 2 commits into from
May 7, 2019
Merged
Changes from 1 commit
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
72 changes: 59 additions & 13 deletions jbmc/src/java_bytecode/java_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,65 @@ class java_class_typet:public class_typet
{
}

/// is a method or field 'final'?
/// is a field 'final'?
bool get_is_final() const
{
return get_bool(ID_final);
}

/// is a method or field 'final'?
/// is a field 'final'?
void set_is_final(const bool is_final)
{
set(ID_final, is_final);
}
};

using componentst = std::vector<componentt>;

const componentst &components() const
{
return (const componentst &)(find(ID_components).get_sub());
}

componentst &components()
{
return (componentst &)(add(ID_components).get_sub());
}

const componentt &get_component(const irep_idt &component_name) const
{
return static_cast<const componentt &>(
class_typet::get_component(component_name));
}

class methodt : public class_typet::methodt
{
public:
methodt() = delete;

methodt(const irep_idt &_name, java_method_typet _type)
: class_typet::methodt(_name, std::move(_type))
{
}

const java_method_typet &type() const
{
return static_cast<const java_method_typet &>(
class_typet::methodt::type());
}

java_method_typet &type()
{
return static_cast<java_method_typet &>(class_typet::methodt::type());
}

/// is a method 'final'?
bool get_is_final() const
{
return get_bool(ID_final);
}

/// is a method 'final'?
void set_is_final(const bool is_final)
{
set(ID_final, is_final);
Expand All @@ -233,22 +285,16 @@ class java_class_typet:public class_typet
}
};

using componentst = std::vector<componentt>;
using methodst = std::vector<methodt>;

const componentst &components() const
const methodst &methods() const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are there any users for this? It'd be good to include at least some in this PR so doesn't get deleted Perhaps a unit test for checking that a java class when loaded has the methods set?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coming!

{
return (const componentst &)(find(ID_components).get_sub());
return (const methodst &)(find(ID_methods).get_sub());
}

componentst &components()
methodst &methods()
{
return (componentst &)(add(ID_components).get_sub());
}

const componentt &get_component(const irep_idt &component_name) const
{
return static_cast<const componentt &>(
class_typet::get_component(component_name));
return (methodst &)(add(ID_methods).get_sub());
}

using static_membert = componentt;
Expand Down