CBMC
java_utils.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module:
4 
5 Author: Daniel Kroening, kroening@kroening.com
6 
7 \*******************************************************************/
8 
9 #ifndef CPROVER_JAVA_BYTECODE_JAVA_UTILS_H
10 #define CPROVER_JAVA_BYTECODE_JAVA_UTILS_H
11 
12 #include <unordered_set>
13 
14 #include <util/pointer_expr.h>
15 
17 
18 class java_class_typet;
19 class java_method_typet;
20 class message_handlert;
21 class symbol_table_baset;
22 
29 bool is_java_string_type(const struct_typet &struct_type);
30 
33 {
44 };
45 
49 get_java_primitive_type_info(const typet &maybe_primitive_type);
50 
53 {
59 };
60 
64 get_boxed_type_info_by_name(const irep_idt &type_name);
65 
69 
72 bool is_primitive_wrapper_type_name(const std::string &type_name);
73 
75  const irep_idt &class_name,
76  symbol_table_baset &symbol_table,
77  message_handlert &message_handler,
78  const struct_union_typet::componentst &componentst);
79 
82 unsigned java_local_variable_slots(const typet &t);
83 
87 
88 const std::string java_class_to_package(const std::string &canonical_classname);
89 
100  exprt &expr,
101  const source_locationt &source_location);
102 
103 #define JAVA_STRING_LITERAL_PREFIX "java::java.lang.String.Literal"
104 
107 bool is_java_string_literal_id(const irep_idt &id);
108 
117  const std::string &friendly_name,
118  const symbol_table_baset &symbol_table,
119  std::string &error);
120 
125  const pointer_typet &given_pointer_type,
126  const java_class_typet &replacement_class_type);
127 
131 
137  symbolt &class_symbol,
138  const struct_union_typet::componentst &components_to_add);
139 
141  const std::string &src,
142  size_t position,
143  char open_char,
144  char close_char);
145 
147  const irep_idt &function_name,
148  const exprt::operandst &arguments,
149  const typet &range,
150  symbol_table_baset &symbol_table);
151 
153 
154 std::string pretty_print_java_type(const std::string &fqn_java_type);
155 
156 std::optional<resolve_inherited_componentt::inherited_componentt>
158  const irep_idt &component_class_id,
159  const irep_idt &component_name,
160  const symbol_table_baset &symbol_table,
161  bool include_interfaces);
162 
164 
165 extern const std::unordered_set<std::string> cprover_methods_to_ignore;
166 
168  const typet &type,
169  const std::string &basename_prefix,
170  const source_locationt &source_location,
171  const irep_idt &function_name,
172  symbol_table_baset &symbol_table);
173 
178 std::optional<irep_idt> declaring_class(const symbolt &symbol);
179 
183 
187 [[nodiscard]] std::optional<std::string>
188 class_name_from_method_name(const std::string &method_name);
189 
190 #endif // CPROVER_JAVA_BYTECODE_JAVA_UTILS_H
Operator to dereference a pointer.
Definition: pointer_expr.h:834
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:38
Base class for all expressions.
Definition: expr.h:56
std::vector< exprt > operandst
Definition: expr.h:58
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
Definition: pointer_expr.h:24
Structure type, corresponds to C style structs.
Definition: std_types.h:231
std::vector< componentt > componentst
Definition: std_types.h:140
The symbol table base class interface.
Symbol table entry.
Definition: symbol.h:28
The type of an expression, extends irept.
Definition: type.h:29
bool is_primitive_wrapper_type_name(const std::string &type_name)
Returns true iff the argument is the fully qualified name of a Java primitive wrapper type (for examp...
Definition: java_utils.cpp:114
bool is_java_string_literal_id(const irep_idt &id)
Definition: java_utils.cpp:207
size_t find_closing_delimiter(const std::string &src, size_t position, char open_char, char close_char)
Finds the corresponding closing delimiter to the given opening delimiter.
Definition: java_utils.cpp:302
const java_primitive_type_infot * get_java_primitive_type_info(const typet &maybe_primitive_type)
If primitive_type is a Java primitive type, return information about it, otherwise return null.
Definition: java_utils.cpp:63
const java_boxed_type_infot * get_boxed_type_info_by_name(const irep_idt &type_name)
If type_name is a Java boxed type tag, return information about it, otherwise return null.
Definition: java_utils.cpp:36
void java_add_components_to_class(symbolt &class_symbol, const struct_union_typet::componentst &components_to_add)
Add the components in components_to_add to the class denoted by class symbol.
Definition: java_utils.cpp:341
const std::unordered_set< std::string > cprover_methods_to_ignore
Methods belonging to the class org.cprover.CProver that should be ignored (not converted),...
Definition: java_utils.cpp:529
std::optional< irep_idt > declaring_class(const symbolt &symbol)
Gets the identifier of the class which declared a given symbol.
Definition: java_utils.cpp:568
symbolt & fresh_java_symbol(const typet &type, const std::string &basename_prefix, const source_locationt &source_location, const irep_idt &function_name, symbol_table_baset &symbol_table)
Definition: java_utils.cpp:555
irep_idt resolve_friendly_method_name(const std::string &friendly_name, const symbol_table_baset &symbol_table, std::string &error)
Resolves a user-friendly method name (like packagename.Class.method) into an internal name (like java...
Definition: java_utils.cpp:212
void set_declaring_class(symbolt &symbol, const irep_idt &declaring_class)
Sets the identifier of the class which declared a given symbol to declaring_class.
Definition: java_utils.cpp:574
bool is_primitive_wrapper_type_id(const irep_idt &id)
Returns true iff the argument is the symbol-table identifier of a Java primitive wrapper type (for ex...
Definition: java_utils.cpp:109
void generate_class_stub(const irep_idt &class_name, symbol_table_baset &symbol_table, message_handlert &message_handler, const struct_union_typet::componentst &componentst)
Definition: java_utils.cpp:162
bool is_java_string_type(const struct_typet &struct_type)
Returns true iff the argument represents a string type (CharSequence, StringBuilder,...
Definition: java_utils.cpp:27
unsigned java_method_parameter_slots(const java_method_typet &t)
Returns the the number of JVM local variables (slots) used by the JVM to pass, upon call,...
Definition: java_utils.cpp:147
irep_idt strip_java_namespace_prefix(const irep_idt &to_strip)
Strip java:: prefix from given identifier.
Definition: java_utils.cpp:407
bool is_non_null_library_global(const irep_idt &)
Check if a symbol is a well-known non-null global.
Definition: java_utils.cpp:519
dereference_exprt checked_dereference(const exprt &expr)
Dereference an expression and flag it for a null-pointer check.
Definition: java_utils.cpp:281
exprt make_function_application(const irep_idt &function_name, const exprt::operandst &arguments, const typet &range, symbol_table_baset &symbol_table)
Create a (mathematical) function application expression.
Definition: java_utils.cpp:384
pointer_typet pointer_to_replacement_type(const pointer_typet &given_pointer_type, const java_class_typet &replacement_class_type)
Given a pointer type to a Java class and a type representing a more specific Java class,...
Definition: java_utils.cpp:269
unsigned java_local_variable_slots(const typet &t)
Returns the number of JVM local variables (slots) taken by a local variable that, when translated to ...
Definition: java_utils.cpp:128
std::optional< resolve_inherited_componentt::inherited_componentt > get_inherited_component(const irep_idt &component_class_id, const irep_idt &component_name, const symbol_table_baset &symbol_table, bool include_interfaces)
Finds an inherited component (method or field), taking component visibility into account.
Definition: java_utils.cpp:448
void merge_source_location_rec(exprt &expr, const source_locationt &source_location)
Attaches a source location to an expression and all of its subexpressions.
Definition: java_utils.cpp:198
std::optional< std::string > class_name_from_method_name(const std::string &method_name)
Get JVM type name of the class in which method_name is defined.
Definition: java_utils.cpp:580
const std::string java_class_to_package(const std::string &canonical_classname)
Definition: java_utils.cpp:157
std::string pretty_print_java_type(const std::string &fqn_java_type)
Strip the package name from a java type, for the type to be pretty printed (java::java....
Definition: java_utils.cpp:421
API to expression classes for Pointers.
Given a class and a component (either field or method), find the closest parent that defines that com...
Return type for get_boxed_type_info_by_name.
Definition: java_utils.h:53
const typet corresponding_primitive_type
Primitive type that this boxed type contains.
Definition: java_utils.h:58
const irep_idt unboxing_function_name
Name of the function defined on the boxed type that returns the boxed value.
Definition: java_utils.h:56
Return type for get_java_primitive_type_info.
Definition: java_utils.h:33
const irep_idt unboxing_function_name
Full identifier of the most general boxed-type method that yields this type.
Definition: java_utils.h:43
const irep_idt boxed_type_factory_method
Full identifier of the boxed type's factory method that takes the corresponding primitive as its sole...
Definition: java_utils.h:38
const irep_idt boxed_type_name
Name, including java:: prefix, of the corresponding boxed type.
Definition: java_utils.h:35