CBMC
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
java_root_class.cpp
Go to the documentation of this file.
1/*******************************************************************\
2
3Module:
4
5Author: Daniel Kroening, kroening@kroening.com
6
7\*******************************************************************/
8
9#include "java_root_class.h"
10
12#include <util/arith_tools.h>
13#include <util/symbol.h>
14
21{
23 struct_typet::componentst &components=struct_type.components();
24
25 {
26 // the class identifier is used for stuff such as 'instanceof'
30
31 // add at the beginning
32 components.insert(components.begin(), component);
33 }
34}
35
44 const irep_idt &class_identifier)
45{
46 jlo.operands().resize(root_type.components().size());
47
48 const std::size_t clsid_nb =
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}
constant_exprt from_integer(const mp_integer &int_value, const typet &type)
Extract class identifier.
#define JAVA_CLASS_IDENTIFIER_FIELD_NAME
ait supplies three of the four components needed: an abstract interpreter (in this case handling func...
Definition ai.h:562
A constant literal expression.
Definition std_expr.h:3117
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition dstring.h:38
String type.
Definition std_types.h:966
Struct constructor from list of elements.
Definition std_expr.h:1877
Structure type, corresponds to C style structs.
Definition std_types.h:231
std::vector< componentt > componentst
Definition std_types.h:140
Symbol table entry.
Definition symbol.h:28
The type of an expression, extends irept.
Definition type.h:29
void java_root_class(symbolt &class_symbol)
Create components to an object of the root class (usually java.lang.Object) Specifically,...
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).
auto component(T &struct_expr, const irep_idt &name, const namespacet &ns) -> decltype(struct_expr.op0())
Definition std_expr.cpp:97
const struct_typet & to_struct_type(const typet &type)
Cast a typet to a struct_typet.
Definition std_types.h:308
Symbol table entry.