-
Notifications
You must be signed in to change notification settings - Fork 273
cleanup of java_types.h #1480
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
cleanup of java_types.h #1480
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ Author: Daniel Kroening, [email protected] | |
|
||
\*******************************************************************/ | ||
|
||
|
||
#ifndef CPROVER_JAVA_BYTECODE_JAVA_TYPES_H | ||
#define CPROVER_JAVA_BYTECODE_JAVA_TYPES_H | ||
|
||
|
@@ -16,7 +15,6 @@ Author: Daniel Kroening, [email protected] | |
#include <util/type.h> | ||
#include <util/std_types.h> | ||
#include <util/c_types.h> | ||
#include <util/config.h> | ||
#include <util/optional.h> | ||
|
||
class java_class_typet:public class_typet | ||
|
@@ -83,10 +81,8 @@ std::vector<typet> java_generic_type_from_string( | |
typet java_bytecode_promotion(const typet &); | ||
exprt java_bytecode_promotion(const exprt &); | ||
|
||
bool is_java_array_tag(const irep_idt& tag); | ||
|
||
bool is_valid_java_array(const struct_typet &type); | ||
|
||
bool is_java_array_tag(const irep_idt &tag); | ||
bool is_valid_java_array(const struct_typet &); | ||
|
||
/// class to hold a Java generic type | ||
/// upper bound can specify type requirements | ||
|
@@ -96,14 +92,12 @@ class java_generic_parametert:public reference_typet | |
typedef symbol_typet type_variablet; | ||
typedef std::vector<type_variablet> type_variablest; | ||
|
||
java_generic_parametert(const irep_idt &_type_var_name, const typet &_bound) : | ||
// the reference_typet now needs a pointer width, here it uses the one | ||
// defined in the reference_type function from c_types.cpp | ||
reference_typet(_bound, config.ansi_c.pointer_width) | ||
java_generic_parametert( | ||
const irep_idt &_type_var_name, | ||
const symbol_typet &_bound): | ||
reference_typet(java_reference_type(_bound)) | ||
{ | ||
PRECONDITION(_bound.id()==ID_symbol); | ||
set(ID_C_java_generic_parameter, true); | ||
// bound must be symbol type | ||
type_variables().push_back(symbol_typet(_type_var_name)); | ||
} | ||
|
||
|
@@ -156,7 +150,7 @@ class java_generic_inst_parametert:public java_generic_parametert | |
public: | ||
// uses empty name for base type variable java_generic_parametert as real name | ||
// is not known here | ||
explicit java_generic_inst_parametert(const typet &type) : | ||
explicit java_generic_inst_parametert(const symbol_typet &type): | ||
java_generic_parametert(irep_idt(), type) | ||
{ | ||
set(ID_C_java_generic_inst_parameter, true); | ||
|
@@ -205,27 +199,27 @@ class java_generic_typet:public reference_typet | |
public: | ||
typedef std::vector<java_generic_parametert> generic_type_variablest; | ||
|
||
explicit java_generic_typet(const typet &_type) : | ||
reference_typet(_type, config.ansi_c.pointer_width) | ||
explicit java_generic_typet(const typet &_type): | ||
reference_typet(java_reference_type(_type)) | ||
{ | ||
set(ID_C_java_generic_type, true); | ||
} | ||
|
||
|
||
/// \return vector of type variables | ||
const generic_type_variablest &generic_type_variables() const | ||
{ | ||
return (const generic_type_variablest &)(find(ID_type_variables).get_sub()); | ||
return (const generic_type_variablest &)( | ||
find(ID_type_variables).get_sub()); | ||
} | ||
|
||
/// \return vector of type variables | ||
generic_type_variablest &generic_type_variables() | ||
{ | ||
return (generic_type_variablest &)(add(ID_type_variables).get_sub()); | ||
return (generic_type_variablest &)( | ||
add(ID_type_variables).get_sub()); | ||
} | ||
}; | ||
|
||
|
||
/// \param type: the type to check | ||
/// \return true if type is java type containing with generics, e.g., List<T> | ||
inline bool is_java_generic_type(const typet &type) | ||
|
@@ -353,7 +347,6 @@ inline const typet &java_generics_class_type_bound( | |
return gen_type.subtype(); | ||
} | ||
|
||
|
||
/// An exception that is raised for unsupported class signature. | ||
/// Currently we do not parse multiple bounds. | ||
class unsupported_java_class_signature_exceptiont:public std::logic_error | ||
|
@@ -375,7 +368,7 @@ inline typet java_type_from_string_with_exception( | |
{ | ||
return java_type_from_string(signature.value(), class_name); | ||
} | ||
catch (unsupported_java_class_signature_exceptiont &e) | ||
catch(unsupported_java_class_signature_exceptiont &) | ||
{ | ||
return java_type_from_string(descriptor, class_name); | ||
} | ||
|
@@ -389,7 +382,8 @@ inline const optionalt<size_t> java_generics_get_index_for_subtype( | |
const java_generics_class_typet &t, | ||
const irep_idt &identifier) | ||
{ | ||
const std::vector<java_generic_parametert> &gen_types=t.generic_types(); | ||
const std::vector<java_generic_parametert> &gen_types= | ||
t.generic_types(); | ||
|
||
const auto iter = std::find_if( | ||
gen_types.cbegin(), | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Just out of curiosity - is there a reason why the parameter name was removed from this (type) but not from the the line above (tag)?
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.
This one is borderline. The question is whether you can tell what the parameter is from the name of the function and the type of the parameter. The problem with irep_idt is that there are many uses of it; a struct_type is less ambiguous.