-
Notifications
You must be signed in to change notification settings - Fork 281
[TG-1157] New class for specialised generic class types. #1606
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -374,4 +374,55 @@ void get_dependencies_from_generic_parameters( | |
const typet &, | ||
std::set<irep_idt> &); | ||
|
||
class java_specialized_generic_class_typet : public java_class_typet | ||
{ | ||
public: | ||
/// Build the specialised version of the specific class, with the specified | ||
/// parameters and name. | ||
/// \param new_tag: The new name for the class (like Generic<java::Float>) | ||
/// \param new_components: The specialised components | ||
/// \return The newly constructed class. | ||
java_specialized_generic_class_typet( | ||
const irep_idt &new_tag, | ||
const struct_typet::componentst &new_components) | ||
{ | ||
set(ID_C_specialized_generic_java_class, true); | ||
// We are specialising the logic - so we don't want to be marked as generic | ||
set(ID_C_java_generics_class_type, false); | ||
set(ID_name, "java::" + id2string(new_tag)); | ||
|
||
set(ID_base_name, id2string(new_tag)); | ||
|
||
components() = new_components; | ||
const std::string &class_tag = id2string(new_tag); | ||
set_tag(class_tag.substr(0, class_tag.find('<'))); | ||
|
||
} | ||
}; | ||
|
||
inline bool is_java_specialized_generic_class_type(const typet &type) | ||
{ | ||
return type.get_bool(ID_C_specialized_generic_java_class); | ||
} | ||
|
||
inline bool is_java_specialized_generic_class_type(typet &type) | ||
{ | ||
return type.get_bool(ID_C_specialized_generic_java_class); | ||
} | ||
|
||
inline java_specialized_generic_class_typet | ||
to_java_specialized_generic_class_type(const typet &type) | ||
{ | ||
INVARIANT( | ||
is_java_specialized_generic_class_type(type), | ||
"Tried to convert a type that was not a specialised generic java class"); | ||
return static_cast<const java_specialized_generic_class_typet &>(type); | ||
} | ||
|
||
inline java_specialized_generic_class_typet | ||
to_java_specialized_generic_class_type(typet &type) | ||
{ | ||
INVARIANT( | ||
is_java_specialized_generic_class_type(type), | ||
"Tried to convert a type that was not a specialised generic java class"); | ||
return static_cast<const java_specialized_generic_class_typet &>(type); | ||
} | ||
|
||
#endif // CPROVER_JAVA_BYTECODE_JAVA_TYPES_H |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor nit (non-blocking): We're getting quite a mix of
specialised
andspecialized
now, e.g. both spellings in the same function signature here. Ideally we'd clean this up, but if you don't clean it up in this PR, please raise a technical debt issue to review all the generics work and cleanup the naming in functions/comments/etc.