9 #ifndef CPROVER_JAVA_BYTECODE_JAVA_TYPES_H
10 #define CPROVER_JAVA_BYTECODE_JAVA_TYPES_H
49 return static_cast<const typet &
>(
find(ID_type));
55 return reinterpret_cast<const std::vector<valuet> &
>(
get_sub());
61 return reinterpret_cast<std::vector<valuet> &
>(
get_sub());
71 return reinterpret_cast<const std::vector<java_annotationt> &
>(
78 return reinterpret_cast<std::vector<java_annotationt> &
>(
109 :
code_typet(std::move(_parameters), std::move(_return_type))
111 set(ID_C_java_method_type,
true);
118 :
code_typet(std::move(_parameters), _return_type)
120 set(ID_C_java_method_type,
true);
125 std::vector<irep_idt> exceptions;
126 for(
const auto &e :
find(ID_exceptions_thrown_list).
get_sub())
127 exceptions.push_back(e.id());
143 set(ID_final, is_final);
148 return get_bool(ID_is_native_method);
153 set(ID_is_native_method, is_native);
158 return get_bool(ID_is_varargs_method);
163 set(ID_is_varargs_method, is_varargs);
180 return type.
id() == ID_code && type.
get_bool(ID_C_java_method_type);
217 set(ID_final, is_final);
252 class_typet::methodt::type());
269 set(ID_final, is_final);
275 return get_bool(ID_is_native_method);
281 set(ID_is_native_method, is_native);
287 return get(ID_object_descriptor);
293 set(ID_object_descriptor,
id);
324 return get(ID_access);
329 return set(ID_access, access);
339 return set(ID_is_inner_class, is_inner_class);
344 return get(ID_outer_class);
349 return set(ID_outer_class, outer_class);
354 return get(ID_super_class);
359 return set(ID_super_class, super_class);
369 return set(ID_is_static, is_static_class);
379 return set(ID_is_anonymous, is_anonymous_class);
389 set(ID_final, is_final);
394 set(ID_incomplete_class, is_stub);
399 return get_bool(ID_incomplete_class);
411 set(ID_enumeration, is_enumeration);
423 set(ID_abstract,
abstract);
435 set(ID_synthetic, synthetic);
447 set(ID_is_annotation, is_annotation);
459 set(ID_interface, interface);
487 set(ID_object_descriptor, method_descriptor);
488 set(ID_handle_type,
static_cast<int>(handle_kind));
500 find(ID_object_descriptor));
519 ID_java_lambda_method_handles)
550 return type_checked_cast<annotated_typet>(
551 static_cast<typet &
>(*
this)).get_annotations();
571 return get(ID_inner_name);
577 set(ID_inner_name, name);
625 return type.
id() == ID_pointer &&
655 #define JAVA_REFERENCE_ARRAY_CLASSID "java::array[reference]"
665 std::pair<typet, std::size_t>
668 #define JAVA_ARRAY_DIMENSION_FIELD_NAME "@array_dimensions"
670 #define JAVA_ARRAY_ELEMENT_CLASSID_FIELD_NAME "@element_class_identifier"
676 const std::string &class_name_prefix =
"");
680 const std::string &);
685 const std::string src,
686 size_t starting_point = 0);
690 char opening_bracket,
691 char closing_bracket);
711 set(ID_C_java_generic_parameter,
true);
752 return type.
get_bool(ID_C_java_generic_parameter);
864 set(ID_C_java_generic_symbol,
true);
869 const std::string &base_ref,
870 const std::string &class_name_prefix);
882 std::optional<size_t>
890 return type.
get_bool(ID_C_java_generic_symbol);
978 set(ID_C_java_generics_class_type,
true);
996 return type.
get_bool(ID_C_java_generics_class_type);
1025 const std::vector<reference_typet> &type_arguments =
1028 return type_arguments[index];
1038 const std::vector<java_generic_parametert> &gen_types=type.
generic_types();
1055 const std::vector<java_generic_parametert> &gen_types=type.
generic_types();
1076 set(ID_C_java_implicitly_generic_class_type,
true);
1077 for(
const auto &type : generic_types)
1101 return type.
get_bool(ID_C_java_implicitly_generic_class_type);
1125 std::vector<java_generic_parametert>
1135 "Unsupported class signature: "+type)
1141 const std::string &descriptor,
1142 const std::optional<std::string> &signature,
1143 const std::string &class_name)
1160 const std::vector<java_generic_parametert> &gen_types,
1163 const auto iter = std::find_if(
1168 return ref.type_variable().get_identifier() == identifier;
1171 if(iter == gen_types.cend())
1176 return narrow_cast<size_t>(std::distance(gen_types.cbegin(), iter));
1180 const std::string &,
1181 std::set<irep_idt> &);
1184 std::set<irep_idt> &);
const std::vector< java_annotationt > & get_annotations() const
std::vector< java_annotationt > & get_annotations()
An expression describing a method on a class.
const irep_idt & get_identifier() const
A unique identifier of the combination of class and method overload to which this expression refers.
componentst static_memberst
componentt static_membert
const static_memberst & static_members() const
std::vector< parametert > parameterst
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Base class for all expressions.
Fixed-width bit-vector with IEEE floating-point interpretation.
There are a large number of kinds of tree structured or tree-like data in CPROVER.
bool get_bool(const irep_idt &name) const
const irept & find(const irep_idt &name) const
const irep_idt & get(const irep_idt &name) const
void set(const irep_idt &name, const irep_idt &value)
const irep_idt & id() const
signed int get_int(const irep_idt &name) const
irept & add(const irep_idt &name)
valuet(irep_idt name, const exprt &value)
const exprt & get_value() const
const irep_idt & get_name() const
std::vector< valuet > & get_values()
const std::vector< valuet > & get_values() const
const typet & get_type() const
java_annotationt(const typet &type)
void set_is_final(const bool is_final)
is a field 'final'?
componentt(const irep_idt &_name, typet _type)
bool get_is_final() const
is a field 'final'?
Represents a lambda call to a method.
method_handle_kindt get_handle_kind() const
java_lambda_method_handlet()
java_lambda_method_handlet(const class_method_descriptor_exprt &method_descriptor, method_handle_kindt handle_kind)
const class_method_descriptor_exprt & get_lambda_method_descriptor() const
const irep_idt & get_lambda_method_identifier() const
const irep_idt & get_descriptor() const
Gets the method's descriptor – the mangled form of its type.
bool get_is_final() const
is a method 'final'?
void set_is_native(const bool is_native)
marks a method as 'native'
const java_method_typet & type() const
bool get_is_native() const
is a method 'native'?
void set_is_final(const bool is_final)
is a method 'final'?
java_method_typet & type()
void set_descriptor(const irep_idt &id)
Sets the method's descriptor – the mangled form of its type.
methodt(const irep_idt &_name, java_method_typet _type)
void set_is_annotation(bool is_annotation)
marks class an annotation
static_memberst & static_members()
bool get_interface() const
is class an interface?
componentst & components()
const irep_idt & get_inner_name() const
Get the name of a java inner class.
void set_is_stub(bool is_stub)
const componentt & get_component(const irep_idt &component_name) const
void set_inner_name(const irep_idt &name)
Set the name of a java inner class.
void add_unknown_lambda_method_handle()
void set_final(bool is_final)
bool get_abstract() const
is class abstract?
const java_lambda_method_handlest & lambda_method_handles() const
bool get_is_static_class() const
void set_is_anonymous_class(const bool &is_anonymous_class)
bool get_is_inner_class() const
void add_lambda_method_handle(const class_method_descriptor_exprt &method_descriptor, method_handle_kindt handle_kind)
const irep_idt & get_outer_class() const
java_lambda_method_handlest & lambda_method_handles()
const std::vector< java_annotationt > & get_annotations() const
void set_abstract(bool abstract)
marks class abstract
void set_super_class(const irep_idt &super_class)
void set_synthetic(bool synthetic)
marks class synthetic
bool get_is_enumeration() const
is class an enumeration?
const irep_idt & get_access() const
bool get_synthetic() const
is class synthetic?
void set_is_inner_class(const bool &is_inner_class)
void set_is_static_class(const bool &is_static_class)
void set_is_enumeration(const bool is_enumeration)
marks class as an enumeration
void set_name(const irep_idt &name)
Set the name of the struct, which can be used to look up its symbol in the symbol table.
bool get_is_anonymous_class() const
bool get_is_annotation() const
is class an annotation?
std::vector< java_annotationt > & get_annotations()
void set_access(const irep_idt &access)
const componentst & components() const
std::vector< java_lambda_method_handlet > java_lambda_method_handlest
void set_interface(bool interface)
marks class an interface
method_handle_kindt
Indicates what sort of code should be synthesised for a lambda call:
@ LAMBDA_STATIC_METHOD_HANDLE
Direct call to the given method.
@ LAMBDA_VIRTUAL_METHOD_HANDLE
Virtual call to the given interface or method.
@ UNKNOWN_HANDLE
Can't be called.
@ LAMBDA_CONSTRUCTOR_HANDLE
Instantiate the needed type then call a constructor.
const irep_idt & get_super_class() const
const methodst & methods() const
const static_memberst & static_members() const
const irep_idt & get_name() const
Get the name of the struct, which can be used to look up its symbol in the symbol table.
void set_outer_class(const irep_idt &outer_class)
Class to hold a class with generics, extends the java class type with a vector of java generic type p...
std::vector< java_generic_parametert > generic_typest
generic_typest & generic_types()
const generic_typest & generic_types() const
java_generic_class_typet()
Class to hold a Java generic type parameter (also called type variable), e.g., T in List<T>.
const type_variablet & type_variable() const
type_variablet & type_variable_ref()
java_generic_parameter_tagt(const irep_idt &_type_var_name, const struct_tag_typet &_bound)
struct_tag_typet type_variablet
const type_variablest & type_variables() const
std::vector< type_variablet > type_variablest
type_variablest & type_variables()
const irep_idt get_name() const
Reference that points to a java_generic_parameter_tagt.
struct_tag_typet type_variablet
java_generic_parametert(const irep_idt &_type_var_name, const struct_tag_typet &_bound)
type_variablet & type_variable_ref()
const type_variablet & type_variable() const
const irep_idt get_name() const
Class to hold type with generic type arguments, for example java.util.List in either a reference of t...
std::vector< reference_typet > generic_typest
java_generic_struct_tag_typet(const struct_tag_typet &type)
const generic_typest & generic_types() const
generic_typest & generic_types()
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.
generic_type_argumentst & generic_type_arguments()
const generic_type_argumentst & generic_type_arguments() const
java_generic_typet(const typet &_type)
java_generic_struct_tag_typet::generic_typest generic_type_argumentst
Type to hold a Java class that is implicitly generic, e.g., an inner class of a generic outer class o...
const implicit_generic_typest & implicit_generic_types() const
implicit_generic_typest & implicit_generic_types()
java_implicitly_generic_class_typet(const java_class_typet &class_type, const implicit_generic_typest &generic_types)
std::vector< java_generic_parametert > implicit_generic_typest
void add_throws_exception(irep_idt exception)
bool is_synthetic() const
const std::vector< irep_idt > throws_exceptions() const
java_method_typet(parameterst &&_parameters, const typet &_return_type)
Constructs a new code type, i.e.
bool get_is_final() const
java_method_typet(parameterst &&_parameters, typet &&_return_type)
Constructs a new code type, i.e.
bool get_is_varargs() const
void set_is_varargs(bool is_varargs)
void set_is_synthetic(bool is_synthetic)
void set_is_final(bool is_final)
void set_native(bool is_native)
This is a specialization of reference_typet.
java_reference_typet(const struct_tag_typet &_subtype, std::size_t _width)
const struct_tag_typet & subtype() const
struct_tag_typet & subtype()
const typet & subtype() const
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.
struct_tag_typet(const irep_idt &identifier)
Structure type, corresponds to C style structs.
const componentt & get_component(const irep_idt &component_name) const
Get the reference to a component with given name.
std::vector< componentt > componentst
const irep_idt & get_identifier() const
const typet & subtype() const
The type of an expression, extends irept.
Fixed-width bit-vector with unsigned binary interpretation.
An exception that is raised for unsupported class signature.
unsupported_java_class_signature_exceptiont(std::string type)
signedbv_typet java_int_type()
bool is_java_array_type(const typet &type)
Checks whether the given type is an array pointer type.
std::vector< typet > java_generic_type_from_string(const std::string &, const std::string &)
Converts the content of a generic class type into a vector of Java types, that is each type variable ...
typet java_type_from_char(char t)
Constructs a type indicated by the given character:
empty_typet java_void_type()
const java_class_typet & to_java_class_type(const typet &type)
char java_char_from_type(const typet &type)
bool can_cast_type< java_generic_parametert >(const typet &base)
Check whether a reference to a typet is a Java generic parameter/variable, e.g., T in List<T>.
std::vector< std::string > parse_raw_list_types(std::string src, char opening_bracket, char closing_bracket)
Given a substring of a descriptor or signature that contains one or more types parse out the individu...
const java_reference_typet & to_java_reference_type(const typet &type)
std::string pretty_java_type(const typet &)
java_reference_typet java_reference_type(const struct_tag_typet &subtype)
struct_tag_typet java_classname(const std::string &)
bool equal_java_types(const typet &type1, const typet &type2)
Compares the types, including checking element types if both types are arrays.
bool is_java_generic_type(const typet &type)
std::string gather_full_class_name(const std::string &)
Returns the full class name, skipping over the generics.
const annotated_typet & to_annotated_type(const typet &type)
const java_method_typet & to_java_method_type(const typet &type)
bool is_java_generic_parameter(const typet &type)
Checks whether the type is a java generic parameter/variable, e.g., T in List<T>.
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.
signedbv_typet java_byte_type()
bool can_cast_type< java_method_typet >(const typet &type)
void get_dependencies_from_generic_parameters(const std::string &, std::set< irep_idt > &)
Collect information about generic type parameters from a given signature.
bool can_cast_type< java_generic_typet >(const typet &type)
java_reference_typet java_array_type(const char subtype)
Construct an array pointer type.
typet java_bytecode_promotion(const typet &)
Java does not support byte/short return types. These are always promoted.
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.
signedbv_typet java_short_type()
const irep_idt & java_generic_class_type_var(size_t index, const java_generic_class_typet &type)
Access information of type variables of a generic java class type.
const java_generic_parameter_tagt & to_java_generic_parameter_tag(const typet &type)
const typet & java_generic_get_inst_type(size_t index, const java_generic_typet &type)
Access information of type arguments of java instantiated 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.
std::optional< typet > java_type_from_string_with_exception(const std::string &descriptor, const std::optional< std::string > &signature, const std::string &class_name)
const java_generic_class_typet & to_java_generic_class_type(const java_class_typet &type)
bool can_cast_type< java_class_typet >(const typet &type)
java_reference_typet java_reference_array_type(const struct_tag_typet &element_type)
floatbv_typet java_double_type()
bool is_java_generic_struct_tag_type(const typet &type)
bool is_java_generic_class_type(const typet &type)
bool is_java_implicitly_generic_class_type(const typet &type)
floatbv_typet java_float_type()
bool can_cast_type< java_reference_typet >(const typet &type)
std::vector< java_generic_parametert > get_all_generic_parameters(const typet &type)
const java_generic_typet & to_java_generic_type(const typet &type)
c_bool_typet java_boolean_type()
unsignedbv_typet java_char_type()
exprt get_array_element_type_field(const exprt &pointer)
const java_generic_parametert & to_java_generic_parameter(const typet &type)
std::string pretty_signature(const java_method_typet &)
size_t find_closing_semi_colon_for_reference_type(const std::string src, size_t starting_point=0)
Finds the closing semi-colon ending a ClassTypeSignature that starts at starting_point.
bool is_valid_java_array(const struct_typet &)
Programmatic documentation of the structure of a Java array (of either primitives or references) type...
const java_generic_struct_tag_typet & to_java_generic_struct_tag_type(const typet &type)
bool can_cast_type< annotated_typet >(const typet &)
bool is_java_array_tag(const irep_idt &tag)
See above.
const typet & java_generic_class_type_bound(size_t index, const typet &t)
Access information of the type bound of a generic java class type.
const std::optional< size_t > java_generics_get_index_for_subtype(const std::vector< java_generic_parametert > &gen_types, const irep_idt &identifier)
Get the index in the subtypes array for a given component.
signedbv_typet java_long_type()
std::string erase_type_arguments(const std::string &)
Take a signature string and remove everything in angle brackets allowing for the type to be parsed no...
bool is_java_generic_parameter_tag(const typet &type)
Checks whether the type is a java generic parameter/variable, e.g., T in List<T>.
exprt get_array_dimension_field(const exprt &pointer)
java_reference_typet java_lang_object_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_implicitly_generic_class_typet & to_java_implicitly_generic_class_type(const java_class_typet &type)
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.
#define PRECONDITION(CONDITION)
API to expression classes.
bool can_cast_type< class_typet >(const typet &type)
Check whether a reference to a typet is a class_typet.
const struct_tag_typet & to_struct_tag_type(const typet &type)
Cast a typet to a struct_tag_typet.
const type_with_subtypet & to_type_with_subtype(const typet &type)