cprover
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 "java_types.h"
13 
14 #include <unordered_set>
15 
16 #include <util/message.h>
17 #include <util/nodiscard.h>
18 #include <util/optional.h>
19 #include <util/std_expr.h>
20 #include <util/symbol_table.h>
21 
23 
24 DEPRECATED(SINCE(2019, 6, 10, "use is_java_array_type instead"))
25 bool java_is_array_type(const typet &type);
26 
33 bool is_java_string_type(const struct_typet &struct_type);
34 
37 bool is_primitive_wrapper_type_name(const std::string &type_name);
38 
40  const irep_idt &class_name,
41  symbol_table_baset &symbol_table,
42  message_handlert &message_handler,
43  const struct_union_typet::componentst &componentst);
44 
47 unsigned java_local_variable_slots(const typet &t);
48 
52 
53 const std::string java_class_to_package(const std::string &canonical_classname);
54 
65  exprt &expr,
66  const source_locationt &source_location);
67 
68 #define JAVA_STRING_LITERAL_PREFIX "java::java.lang.String.Literal"
69 
72 bool is_java_string_literal_id(const irep_idt &id);
73 
82  const std::string &friendly_name,
83  const symbol_table_baset &symbol_table,
84  std::string &error);
85 
90  const pointer_typet &given_pointer_type,
91  const java_class_typet &replacement_class_type);
92 
96 
102  symbolt &class_symbol,
103  const struct_union_typet::componentst &components_to_add);
104 
106  const std::string &src,
107  size_t position,
108  char open_char,
109  char close_char);
110 
112  const irep_idt &function_name,
113  const exprt::operandst &arguments,
114  const typet &range,
115  symbol_table_baset &symbol_table);
116 
118 
119 std::string pretty_print_java_type(const std::string &fqn_java_type);
120 
123  const irep_idt &component_class_id,
124  const irep_idt &component_name,
125  const symbol_tablet &symbol_table,
126  bool include_interfaces);
127 
129 
130 extern const std::unordered_set<std::string> cprover_methods_to_ignore;
131 
133  const typet &type,
134  const std::string &basename_prefix,
135  const source_locationt &source_location,
136  const irep_idt &function_name,
137  symbol_table_baset &symbol_table);
138 
144 
148 
153 class_name_from_method_name(const std::string &method_name);
154 
155 #endif // CPROVER_JAVA_BYTECODE_JAVA_UTILS_H
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:37
symbol_tablet
The symbol table.
Definition: symbol_table.h:20
NODISCARD
#define NODISCARD
Definition: nodiscard.h:22
java_local_variable_slots
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:55
typet
The type of an expression, extends irept.
Definition: type.h:29
struct_union_typet
Base type for structs and unions.
Definition: std_types.h:57
optional.h
is_java_string_literal_id
bool is_java_string_literal_id(const irep_idt &id)
Definition: java_utils.cpp:137
dereference_exprt
Operator to dereference a pointer.
Definition: std_expr.h:2917
find_closing_delimiter
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:233
declaring_class
optionalt< irep_idt > declaring_class(const symbolt &symbol)
Gets the identifier of the class which declared a given symbol.
Definition: java_utils.cpp:500
nodiscard.h
checked_dereference
dereference_exprt checked_dereference(const exprt &expr)
Dereference an expression and flag it for a null-pointer check.
Definition: java_utils.cpp:212
exprt
Base class for all expressions.
Definition: expr.h:53
struct_union_typet::componentst
std::vector< componentt > componentst
Definition: std_types.h:135
java_method_parameter_slots
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:74
set_declaring_class
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:506
resolve_inherited_component.h
java_class_typet
Definition: java_types.h:199
resolve_friendly_method_name
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:142
java_add_components_to_class
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:272
pretty_print_java_type
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:352
symbol_table_baset
The symbol table base class interface.
Definition: symbol_table_base.h:22
java_is_array_type
bool java_is_array_type(const typet &type)
Definition: java_utils.cpp:26
class_name_from_method_name
NODISCARD optionalt< 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:512
java_class_to_package
const std::string java_class_to_package(const std::string &canonical_classname)
Definition: java_utils.cpp:84
message_handlert
Definition: message.h:27
exprt::operandst
std::vector< exprt > operandst
Definition: expr.h:55
strip_java_namespace_prefix
irep_idt strip_java_namespace_prefix(const irep_idt &to_strip)
Strip java:: prefix from given identifier.
Definition: java_utils.cpp:338
merge_source_location_rec
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:128
get_inherited_component
optionalt< resolve_inherited_componentt::inherited_componentt > get_inherited_component(const irep_idt &component_class_id, const irep_idt &component_name, const symbol_tablet &symbol_table, bool include_interfaces)
Finds an inherited component (method or field), taking component visibility into account.
Definition: java_utils.cpp:379
SINCE
#define SINCE(year, month, day, msg)
Definition: deprecate.h:26
optionalt
nonstd::optional< T > optionalt
Definition: optional.h:35
is_primitive_wrapper_type_name
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.
Definition: java_utils.cpp:41
source_locationt
Definition: source_location.h:20
struct_typet
Structure type, corresponds to C style structs.
Definition: std_types.h:226
DEPRECATED
#define DEPRECATED(msg)
Definition: deprecate.h:23
symbolt
Symbol table entry.
Definition: symbol.h:28
make_function_application
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:315
is_java_string_type
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:33
java_types.h
cprover_methods_to_ignore
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:461
symbol_table.h
Author: Diffblue Ltd.
pointer_typet
The pointer type These are both 'bitvector_typet' (they have a width) and 'type_with_subtypet' (they ...
Definition: std_types.h:1488
message.h
std_expr.h
generate_class_stub
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:89
java_method_typet
Definition: java_types.h:103
pointer_to_replacement_type
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:200
is_non_null_library_global
bool is_non_null_library_global(const irep_idt &)
Check if a symbol is a well-known non-null global.
Definition: java_utils.cpp:450
fresh_java_symbol
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:487