|
CBMC
|
#include <cctype>#include <iterator>#include <util/prefix.h>#include <util/c_types.h>#include <util/std_expr.h>#include <util/ieee_float.h>#include <util/invariant.h>#include "java_types.h"#include "java_utils.h"
Include dependency graph for java_types.cpp:Go to the source code of this file.
Functions | |
| std::vector< typet > | parse_list_types (const std::string src, const std::string class_name_prefix, const char opening_bracket, const char closing_bracket) |
| Given a substring of a descriptor or signature that contains one or more types parse out the individual types. More... | |
| signedbv_typet | java_int_type () |
| empty_typet | java_void_type () |
| signedbv_typet | java_long_type () |
| signedbv_typet | java_short_type () |
| signedbv_typet | java_byte_type () |
| unsignedbv_typet | java_char_type () |
| floatbv_typet | java_float_type () |
| floatbv_typet | java_double_type () |
| c_bool_typet | java_boolean_type () |
| reference_typet | java_reference_type (const typet &subtype) |
| java_reference_typet | java_reference_type (const struct_tag_typet &subtype) |
| java_reference_typet | java_lang_object_type () |
| java_reference_typet | java_array_type (const char subtype) |
| Construct an array pointer type. More... | |
| const typet & | java_array_element_type (const struct_tag_typet &array_symbol) |
| Return a const reference to the element type of a given java array type. More... | |
| typet & | java_array_element_type (struct_tag_typet &array_symbol) |
| Return a non-const reference to the element type of a given java array type. More... | |
| bool | is_java_array_type (const typet &type) |
| Checks whether the given type is an array pointer type. More... | |
| bool | is_multidim_java_array_type (const typet &type) |
| Checks whether the given type is a multi-dimensional array pointer type, i.e., a pointer to an array type with element type also being a pointer to an array type. More... | |
| std::pair< typet, std::size_t > | java_array_dimension_and_element_type (const struct_tag_typet &type) |
Returns the underlying element type and array dimensionality of Java struct type. More... | |
| exprt | get_array_dimension_field (const exprt &pointer) |
| exprt | get_array_element_type_field (const exprt &pointer) |
| bool | is_java_array_tag (const irep_idt &tag) |
| See above. More... | |
| typet | java_type_from_char (char t) |
| Constructs a type indicated by the given character: More... | |
| typet | java_bytecode_promotion (const typet &type) |
| Java does not support byte/short return types. These are always promoted. More... | |
| exprt | java_bytecode_promotion (const exprt &expr) |
| Java does not support byte/short return types. These are always promoted. More... | |
| void | add_generic_type_information (java_generic_typet &generic_type, const std::string &type_arguments, const std::string &class_name_prefix) |
| Take a list of generic type arguments and parse them into the generic type. More... | |
| std::string | erase_type_arguments (const std::string &src) |
| Take a signature string and remove everything in angle brackets allowing for the type to be parsed normally. More... | |
| std::string | gather_full_class_name (const std::string &src) |
| Returns the full class name, skipping over the generics. More... | |
| std::vector< std::string > | parse_raw_list_types (const std::string src, const char opening_bracket, const char closing_bracket) |
| Given a substring of a descriptor or signature that contains one or more types parse out the individual type strings. More... | |
| reference_typet | build_class_name (const std::string &src, const std::string &class_name_prefix) |
| For parsing a class type reference. More... | |
| size_t | find_closing_semi_colon_for_reference_type (const std::string src, size_t starting_point) |
Finds the closing semi-colon ending a ClassTypeSignature that starts at starting_point. More... | |
| java_reference_typet | java_reference_array_type (const struct_tag_typet &subtype) |
| optionalt< typet > | java_type_from_string (const std::string &src, const std::string &class_name_prefix) |
| Transforms a string representation of a Java type into an internal type representation thereof. More... | |
| char | java_char_from_type (const typet &type) |
| std::vector< typet > | java_generic_type_from_string (const std::string &class_name, const std::string &src) |
| Converts the content of a generic class type into a vector of Java types, that is each type variable of the class has one entry in the returned vector. More... | |
| static std::string | slash_to_dot (const std::string &src) |
| struct_tag_typet | java_classname (const std::string &id) |
| bool | is_valid_java_array (const struct_typet &type) |
| Programmatic documentation of the structure of a Java array (of either primitives or references) type. More... | |
| bool | equal_java_types (const typet &type1, const typet &type2) |
| Compares the types, including checking element types if both types are arrays. More... | |
| std::vector< java_generic_parametert > | get_all_generic_parameters (const typet &type) |
| void | get_dependencies_from_generic_parameters_rec (const typet &t, std::set< irep_idt > &refs) |
| void | get_dependencies_from_generic_parameters (const std::string &signature, std::set< irep_idt > &refs) |
| Collect information about generic type parameters from a given signature. More... | |
| void | get_dependencies_from_generic_parameters (const typet &t, std::set< irep_idt > &refs) |
| Collect information about generic type parameters from a given type. More... | |
| std::string | pretty_java_type (const typet &type) |
| std::string | pretty_signature (const java_method_typet &method_type) |
| void add_generic_type_information | ( | java_generic_typet & | generic_type, |
| const std::string & | type_arguments, | ||
| const std::string & | class_name_prefix | ||
| ) |
Take a list of generic type arguments and parse them into the generic type.
| [out] | generic_type | The existing generic type to add the information to |
| type_arguments | The string representing the generic type arguments for a signature. For example <TT;Ljava/lang/Foo;LList<LInteger;>;> (including the wrapping angle brackets). | |
| class_name_prefix | The name of the class to use to prefix any found generic types |
Definition at line 299 of file java_types.cpp.
| reference_typet build_class_name | ( | const std::string & | src, |
| const std::string & | class_name_prefix | ||
| ) |
For parsing a class type reference.
| src | The input string Either a signature: "Lpackage/class<TT;>.innerclass<Ljava/lang/Foo;>; Or a descriptor: "Lpackage.class$inner; |
| class_name_prefix | The name of the class to use to prefix any found generic types |
Definition at line 472 of file java_types.cpp.
Compares the types, including checking element types if both types are arrays.
| type1 | First type to compare |
| type2 | Second type to compare |
Definition at line 895 of file java_types.cpp.
| std::string erase_type_arguments | ( | const std::string & | src | ) |
Take a signature string and remove everything in angle brackets allowing for the type to be parsed normally.
Take a signature string and remove everything in angle brackets allowing for the type to be parsed normally, for example java.util.HashSet<java.lang.Integer> will be turned into java.util.HashSet
| src | The input string |
Definition at line 334 of file java_types.cpp.
| size_t find_closing_semi_colon_for_reference_type | ( | const std::string | src, |
| size_t | starting_point | ||
| ) |
Finds the closing semi-colon ending a ClassTypeSignature that starts at starting_point.
| src | The input string to work on. |
| starting_point | The string position where the opening 'L' we want to find the closing ';' for. |
Definition at line 516 of file java_types.cpp.
| std::string gather_full_class_name | ( | const std::string & | src | ) |
Returns the full class name, skipping over the generics.
| src | a type descriptor or signature
|
Definition at line 365 of file java_types.cpp.
| std::vector<java_generic_parametert> get_all_generic_parameters | ( | const typet & | type | ) |
| type | Source type |
Definition at line 924 of file java_types.cpp.
| pointer | pointer to an array[reference] object |
Definition at line 206 of file java_types.cpp.
| pointer | pointer to an array[reference] object |
Definition at line 218 of file java_types.cpp.
| void get_dependencies_from_generic_parameters | ( | const std::string & | signature, |
| std::set< irep_idt > & | refs | ||
| ) |
Collect information about generic type parameters from a given signature.
This is used to get information about class dependencies that must be loaded but only appear as generic type argument, not as a field reference.
| signature | the string representation of the signature to analyze | |
| [out] | refs | the set to insert the names of the found dependencies |
Definition at line 996 of file java_types.cpp.
Collect information about generic type parameters from a given type.
This is used to get information about class dependencies that must be loaded but only appear as generic type argument, not as a field reference.
| t | the type to analyze | |
| [out] | refs | the set to insert the names of the found dependencies |
Definition at line 1032 of file java_types.cpp.
Definition at line 948 of file java_types.cpp.
| bool is_java_array_tag | ( | const irep_idt & | tag | ) |
See above.
| tag | Tag of a struct |
Definition at line 233 of file java_types.cpp.
| bool is_java_array_type | ( | const typet & | type | ) |
Checks whether the given type is an array pointer type.
Definition at line 163 of file java_types.cpp.
| bool is_multidim_java_array_type | ( | const typet & | type | ) |
Checks whether the given type is a multi-dimensional array pointer type, i.e., a pointer to an array type with element type also being a pointer to an array type.
Definition at line 179 of file java_types.cpp.
| bool is_valid_java_array | ( | const struct_typet & | type | ) |
Programmatic documentation of the structure of a Java array (of either primitives or references) type.
A Java array is represented in GOTO in the following way: A struct component with a tag like java::array[type] where type is either a primitive like int, or reference. The struct has precisely three components:
| type | A type that might represent a Java array |
Definition at line 838 of file java_types.cpp.
| std::pair<typet, std::size_t> java_array_dimension_and_element_type | ( | const struct_tag_typet & | type | ) |
Returns the underlying element type and array dimensionality of Java struct type.
If this is not an array type the return value will be {type, 0}.
Definition at line 189 of file java_types.cpp.
| const typet& java_array_element_type | ( | const struct_tag_typet & | array_symbol | ) |
Return a const reference to the element type of a given java array type.
| array_symbol | The java array type |
Definition at line 144 of file java_types.cpp.
| typet& java_array_element_type | ( | struct_tag_typet & | array_symbol | ) |
Return a non-const reference to the element type of a given java array type.
| array_symbol | The java array type |
Definition at line 154 of file java_types.cpp.
| java_reference_typet java_array_type | ( | const char | subtype | ) |
Construct an array pointer type.
It is a pointer to a symbol with identifier java::array[]. Its ID_element_type is set to the corresponding primitive type, or void* for arrays of references.
| subtype | Character indicating the type of array |
Definition at line 109 of file java_types.cpp.
| c_bool_typet java_boolean_type | ( | ) |
Definition at line 79 of file java_types.cpp.
| signedbv_typet java_byte_type | ( | ) |
Definition at line 55 of file java_types.cpp.
Java does not support byte/short return types. These are always promoted.
Definition at line 281 of file java_types.cpp.
Java does not support byte/short return types. These are always promoted.
Definition at line 269 of file java_types.cpp.
| char java_char_from_type | ( | const typet & | type | ) |
Definition at line 708 of file java_types.cpp.
| unsignedbv_typet java_char_type | ( | ) |
Definition at line 61 of file java_types.cpp.
| struct_tag_typet java_classname | ( | const std::string & | id | ) |
Definition at line 809 of file java_types.cpp.
| floatbv_typet java_double_type | ( | ) |
Definition at line 73 of file java_types.cpp.
| floatbv_typet java_float_type | ( | ) |
Definition at line 67 of file java_types.cpp.
| std::vector<typet> java_generic_type_from_string | ( | const std::string & | class_name, |
| const std::string & | src | ||
| ) |
Converts the content of a generic class type into a vector of Java types, that is each type variable of the class has one entry in the returned vector.
This also supports parsing of bounds in the form of <T:CBound> for classes or <T::IBound> for interfaces.
For example for HashMap<K, V> a vector with two elements would be returned
the class signature is of the form <TX:Bound_X;:BoundZ;TY:Bound_Y;> or of the form <TX::Bound_X;:BoundZ;TY:Bound_Y;> if Bound_X is an interface
Definition at line 749 of file java_types.cpp.
| signedbv_typet java_int_type | ( | ) |
Definition at line 31 of file java_types.cpp.
| java_reference_typet java_lang_object_type | ( | ) |
Definition at line 98 of file java_types.cpp.
| signedbv_typet java_long_type | ( | ) |
Definition at line 43 of file java_types.cpp.
| java_reference_typet java_reference_array_type | ( | const struct_tag_typet & | subtype | ) |
Definition at line 541 of file java_types.cpp.
| java_reference_typet java_reference_type | ( | const struct_tag_typet & | subtype | ) |
Definition at line 93 of file java_types.cpp.
| reference_typet java_reference_type | ( | const typet & | subtype | ) |
Definition at line 88 of file java_types.cpp.
| signedbv_typet java_short_type | ( | ) |
Definition at line 49 of file java_types.cpp.
| typet java_type_from_char | ( | char | t | ) |
Constructs a type indicated by the given character:
Definition at line 248 of file java_types.cpp.
| optionalt<typet> java_type_from_string | ( | const std::string & | src, |
| const std::string & | class_name_prefix | ||
| ) |
Transforms a string representation of a Java type into an internal type representation thereof.
Example use are object types like "Ljava/lang/Integer;", type variables/parameters like "TE;" which require a non-empty class_name_prefix or generic types like "Ljava/util/List<TE;>;" or "Ljava/util/List<Ljava/lang/Integer;>;" also requiring class_name_prefix.
| src | the string representation as used in the class file |
| class_name_prefix | name of class to append to generic type variables/parameters |
Definition at line 561 of file java_types.cpp.
| empty_typet java_void_type | ( | ) |
Definition at line 37 of file java_types.cpp.
| std::vector< typet > parse_list_types | ( | const std::string | src, |
| const std::string | class_name_prefix, | ||
| const char | opening_bracket, | ||
| const char | closing_bracket | ||
| ) |
Given a substring of a descriptor or signature that contains one or more types parse out the individual types.
This is used for parsing the parameters of a function or the generic type variables/parameters or arguments contained within angle brackets.
| src | The input string that is wrapped in either ( ) or < > |
| class_name_prefix | The name of the class to use to prefix any found generic types |
| opening_bracket | For checking string is passed in as expected, the opening bracket (i.e. '(' or '<'). |
| closing_bracket | For checking string is passed in as expected, the closing bracket (i.e. ')' or '>'). |
Definition at line 392 of file java_types.cpp.
| std::vector<std::string> parse_raw_list_types | ( | const std::string | src, |
| const char | opening_bracket, | ||
| const char | closing_bracket | ||
| ) |
Given a substring of a descriptor or signature that contains one or more types parse out the individual type strings.
| src | The input string that is wrapped in either ( ) or < > |
| opening_bracket | For checking string is passed in as expected, the opening bracket (i.e. '(' or '<'). |
| closing_bracket | For checking string is passed in as expected, the closing bracket (i.e. ')' or '>'). |
Definition at line 419 of file java_types.cpp.
| std::string pretty_java_type | ( | const typet & | type | ) |
Definition at line 1089 of file java_types.cpp.
| std::string pretty_signature | ( | const java_method_typet & | method_type | ) |
Definition at line 1131 of file java_types.cpp.
|
static |
Definition at line 800 of file java_types.cpp.