cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
java_root_class.cpp
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module:
4
5
Author: Daniel Kroening, kroening@kroening.com
6
7
\*******************************************************************/
8
9
#include "
java_root_class.h
"
10
11
#include <
goto-programs/class_identifier.h
>
12
#include <
util/arith_tools.h
>
13
#include <
util/symbol.h
>
14
20
void
java_root_class
(
symbolt
&class_symbol)
21
{
22
struct_typet
&struct_type=
to_struct_type
(class_symbol.
type
);
23
struct_typet::componentst
&components=struct_type.
components
();
24
25
{
26
// the class identifier is used for stuff such as 'instanceof'
27
struct_typet::componentt
component
(
28
JAVA_CLASS_IDENTIFIER_FIELD_NAME
,
string_typet
());
29
component
.set_pretty_name(
JAVA_CLASS_IDENTIFIER_FIELD_NAME
);
30
31
// add at the beginning
32
components.insert(components.begin(),
component
);
33
}
34
}
35
41
void
java_root_class_init
(
42
struct_exprt
&jlo,
43
const
struct_typet
&root_type,
44
const
irep_idt
&class_identifier)
45
{
46
jlo.
operands
().resize(root_type.
components
().size());
47
48
const
std::size_t clsid_nb =
49
root_type.
component_number
(
JAVA_CLASS_IDENTIFIER_FIELD_NAME
);
50
const
typet
&clsid_type=root_type.
components
()[clsid_nb].type();
51
constant_exprt
clsid(class_identifier, clsid_type);
52
jlo.
operands
()[clsid_nb]=clsid;
53
54
// Check if the 'cproverMonitorCount' component exists and initialize it.
55
// This field is only present when the java core models are embedded. It is
56
// used to implement a critical section, which is necessary to support
57
// concurrency.
58
if
(root_type.
has_component
(
"cproverMonitorCount"
))
59
{
60
const
std::size_t count_nb =
61
root_type.
component_number
(
"cproverMonitorCount"
);
62
const
typet
&count_type = root_type.
components
()[count_nb].type();
63
jlo.
operands
()[count_nb] =
from_integer
(0, count_type);
64
}
65
}
from_integer
constant_exprt from_integer(const mp_integer &int_value, const typet &type)
Definition
arith_tools.cpp:99
arith_tools.h
class_identifier.h
Extract class identifier.
JAVA_CLASS_IDENTIFIER_FIELD_NAME
#define JAVA_CLASS_IDENTIFIER_FIELD_NAME
Definition
class_identifier.h:20
constant_exprt
A constant literal expression.
Definition
std_expr.h:2997
exprt::operands
operandst & operands()
Definition
expr.h:95
string_typet
String type.
Definition
std_types.h:966
struct_exprt
Struct constructor from list of elements.
Definition
std_expr.h:1810
struct_typet
Structure type, corresponds to C style structs.
Definition
std_types.h:231
struct_union_typet::componentt
Definition
std_types.h:69
struct_union_typet::components
const componentst & components() const
Definition
std_types.h:147
struct_union_typet::has_component
bool has_component(const irep_idt &component_name) const
Definition
std_types.h:157
struct_union_typet::component_number
std::size_t component_number(const irep_idt &component_name) const
Return the sequence number of the component with given name.
Definition
std_types.cpp:47
struct_union_typet::componentst
std::vector< componentt > componentst
Definition
std_types.h:140
symbolt
Symbol table entry.
Definition
symbol.h:28
symbolt::type
typet type
Type of symbol.
Definition
symbol.h:31
typet
The type of an expression, extends irept.
Definition
type.h:29
java_root_class
void java_root_class(symbolt &class_symbol)
Create components to an object of the root class (usually java.lang.Object) Specifically,...
Definition
java_root_class.cpp:20
java_root_class_init
void java_root_class_init(struct_exprt &jlo, const struct_typet &root_type, const irep_idt &class_identifier)
Adds members for an object of the root class (usually java.lang.Object).
Definition
java_root_class.cpp:41
java_root_class.h
component
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
Definition
std_expr.cpp:291
to_struct_type
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Definition
std_types.h:308
symbol.h
Symbol table entry.
irep_idt
dstringt irep_idt
Definition
verification_result.h:16
jbmc
src
java_bytecode
java_root_class.cpp
Generated by
1.17.0