26 const std::string src,
100 static const auto result =
128 std::cout <<
"Unrecognised subtype str: " << subtype << std::endl;
148 "Symbol should have array tag");
158 "Symbol should have array tag");
188std::pair<typet, std::size_t>
192 typet underlying_type;
321 std::back_inserter(
generic_type.generic_type_arguments()),
325 is_reference(type),
"All generic type arguments should be references");
326 return to_reference_type(type);
336 std::string class_name = src;
337 std::size_t
f_pos = class_name.find(
'<', 1);
339 while(
f_pos != std::string::npos)
342 if(
e_pos == std::string::npos)
345 "Failed to find generic signature closing delimiter (or recursive "
371 std::string class_name = src.substr(1, src.size() - 2);
375 std::replace(class_name.begin(), class_name.end(),
'.',
'$');
376 std::replace(class_name.begin(), class_name.end(),
'/',
'.');
393 const std::string src,
420 const std::string src,
431 for(std::size_t i = 1; i < src.size() - 1; i++)
434 while(i < src.size())
444 else if(src[i] ==
'[')
448 else if(src[i] ==
'T')
449 i = src.find(
';', i);
458 std::string
sub_str = src.substr(start, i - start + 1);
484 std::size_t
f_pos = src.find(
'<', 1);
485 if(
f_pos != std::string::npos)
492 if(
e_pos == std::string::npos)
494 "Parsing type with unmatched generic bracket: " + src);
501 }
while(
f_pos != std::string::npos);
502 return std::move(result);
517 const std::string src,
524 "There must be a semi-colon somewhere in the input");
532 end_bracket != std::string::npos,
"Must find matching angle bracket");
562 const std::string &src,
596 "Failed to find generic signature closing delimiter");
607 "Cannot currently parse bounds on generic types");
619 "This should correspond to method signatures only");
625 std::size_t
e_pos=src.rfind(
')');
626 if(
e_pos==std::string::npos)
640 std::back_inserter(parameters),
641 [](
const typet &type) { return java_method_typet::parametert(type); });
681 INVARIANT(src[src.size()-1]==
';',
"Generic type name must end on ';'.");
750 const std::string &class_name,
751 const std::string &src)
758 "Class signature has unexpected format");
761 if(signature.find(
";:")!=std::string::npos)
766 std::vector<typet>
types;
767 size_t var_sep=signature.find(
';');
768 while(
var_sep!=std::string::npos)
778 signature[
bound_sep + 2] !=
':',
"Unknown bound for type variable.");
783 "java::"+class_name+
"::"+signature.substr(0,
bound_sep));
793 signature=signature.substr(
var_sep+1, std::string::npos);
802 std::string result=src;
803 for(std::string::iterator it=result.begin(); it!=result.end(); it++)
811 if(!
id.empty() &&
id[0]==
'[')
815 std::string class_name=id;
818 irep_idt identifier=
"java::"+class_name;
923std::vector<java_generic_parametert>
950 std::set<irep_idt> &
refs)
971 for(
const auto &
param :
c.parameters())
997 const std::string &signature,
998 std::set<irep_idt> &
refs)
1003 if(signature[0] ==
'<')
1008 for(
const auto &t :
types)
1013 else if(signature.find(
'*') == std::string::npos)
1034 std::set<irep_idt> &
refs)
1061 "identifier of " + type.
pretty() +
"\n and identifier of type " +
1063 "\ncreated by java_type_from_string for " +
base_ref +
1064 " should be equal");
1078 const auto &type_variable = type.
get_name();
1080 for(std::size_t i = 0; i <
generics.size(); ++i)
1083 if(
param &&
param->get_name() == type_variable)
1133 std::ostringstream result;
1151 return result.str();
const floatbv_typet & to_floatbv_type(const typet &type)
Cast a typet to a floatbv_typet.
const signedbv_typet & to_signedbv_type(const typet &type)
Cast a typet to a signedbv_typet.
reference_typet reference_type(const typet &subtype)
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Operator to dereference a pointer.
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
bool starts_with(const char *s) const
equivalent of as_string().starts_with(s)
Base class for all expressions.
typet & type()
Return the type of the expression.
Fixed-width bit-vector with IEEE floating-point interpretation.
static ieee_float_spect single_precision()
static ieee_float_spect double_precision()
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
Class to hold a class with generics, extends the java class type with a vector of java generic type p...
Reference that points to a java_generic_parameter_tagt.
const irep_idt get_name() const
java_generic_struct_tag_typet(const struct_tag_typet &type)
const generic_typest & generic_types() const
std::optional< size_t > generic_type_index(const java_generic_parametert &type) const
Check if this symbol has the given generic type.
Reference that points to a java_generic_struct_tag_typet.
Type to hold a Java class that is implicitly generic, e.g., an inner class of a generic outer class o...
std::vector< parametert > parameterst
This is a specialization of reference_typet.
Extract member of struct or union.
const typet & base_type() const
The type of the data what we point to.
Fixed-width bit-vector with two's complement interpretation.
A struct tag type, i.e., struct_typet with an identifier.
Structure type, corresponds to C style structs.
const componentst & components() const
const irep_idt & get_identifier() const
Semantic type conversion.
static exprt conditional_cast(const exprt &expr, const typet &type)
The type of an expression, extends irept.
typet & add_type(const irep_idt &name)
const typet & find_type(const irep_idt &name) const
Fixed-width bit-vector with unsigned binary interpretation.
An exception that is raised for unsupported class signature.
const std::string & id2string(const irep_idt &d)
signedbv_typet java_int_type()
bool is_java_array_type(const typet &type)
Checks whether the given type is an array pointer type.
bool is_valid_java_array(const struct_typet &type)
Programmatic documentation of the structure of a Java array (of either primitives or references) type...
typet java_type_from_char(char t)
Constructs a type indicated by the given character:
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.
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 no...
java_reference_typet java_reference_array_type(const struct_tag_typet &subtype)
empty_typet java_void_type()
std::string pretty_java_type(const typet &type)
char java_char_from_type(const typet &type)
bool equal_java_types(const typet &type1, const typet &type2)
Compares the types, including checking element types if both types are arrays.
void get_dependencies_from_generic_parameters_rec(const typet &t, std::set< irep_idt > &refs)
struct_tag_typet java_classname(const std::string &id)
signedbv_typet java_byte_type()
std::string pretty_signature(const java_method_typet &method_type)
std::vector< java_generic_parametert > get_all_generic_parameters(const typet &type)
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 individu...
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.
typet java_bytecode_promotion(const typet &type)
Java does not support byte/short return types. These are always promoted.
java_reference_typet java_array_type(const char subtype)
Construct an array pointer type.
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.
signedbv_typet java_short_type()
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 individu...
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 ...
std::optional< 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.
static std::string slash_to_dot(const std::string &src)
floatbv_typet java_double_type()
reference_typet java_reference_type(const typet &subtype)
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.
floatbv_typet java_float_type()
c_bool_typet java_boolean_type()
unsignedbv_typet java_char_type()
exprt get_array_element_type_field(const exprt &pointer)
std::string gather_full_class_name(const std::string &src)
Returns the full class name, skipping over the generics.
bool is_java_array_tag(const irep_idt &tag)
See above.
signedbv_typet java_long_type()
reference_typet build_class_name(const std::string &src, const std::string &class_name_prefix)
For parsing a class type reference.
exprt get_array_dimension_field(const exprt &pointer)
java_reference_typet java_lang_object_type()
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.
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 ...
const java_method_typet & to_java_method_type(const typet &type)
const java_reference_typet & to_java_reference_type(const typet &type)
const java_generic_typet & to_java_generic_type(const typet &type)
#define JAVA_REFERENCE_ARRAY_CLASSID
const java_class_typet & to_java_class_type(const typet &type)
bool is_java_generic_type(const typet &type)
const java_implicitly_generic_class_typet & to_java_implicitly_generic_class_type(const java_class_typet &type)
std::optional< typet > java_type_from_string(const std::string &, const std::string &class_name_prefix="")
Transforms a string representation of a Java type into an internal type representation thereof.
bool is_java_generic_class_type(const typet &type)
bool is_java_implicitly_generic_class_type(const typet &type)
#define JAVA_ARRAY_ELEMENT_CLASSID_FIELD_NAME
#define JAVA_ARRAY_DIMENSION_FIELD_NAME
const java_generic_class_typet & to_java_generic_class_type(const java_class_typet &type)
size_t find_closing_delimiter(const std::string &src, size_t open_pos, char open_char, char close_char)
Finds the corresponding closing delimiter to the given opening delimiter.
irep_idt strip_java_namespace_prefix(const irep_idt &to_strip)
Strip java:: prefix from given identifier.
bool is_reference(const typet &type)
Returns true if the type is a reference.
const reference_typet & to_reference_type(const typet &type)
Cast a typet to a reference_typet.
const pointer_typet & to_pointer_type(const typet &type)
Cast a typet to a pointer_typet.
#define CHECK_RETURN(CONDITION)
#define UNREACHABLE
This should be used to mark dead code.
#define DATA_INVARIANT(CONDITION, REASON)
This condition should be used to document that assumptions that are made on goto_functions,...
#define PRECONDITION(CONDITION)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
API to expression classes.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.