cprover
Toggle main menu visibility
Loading...
Searching...
No Matches
code_with_references.h
Go to the documentation of this file.
1
/*******************************************************************\
2
3
Module: Java bytecode
4
5
Author: Romain Brenguier, romain.brenguier@diffblue.com
6
7
\*******************************************************************/
8
9
#ifndef CPROVER_JAVA_BYTECODE_CODE_WITH_REFERENCES_H
10
#define CPROVER_JAVA_BYTECODE_CODE_WITH_REFERENCES_H
11
12
#include <memory>
13
#include <
util/std_code.h
>
14
17
codet
allocate_array
(
18
const
exprt
&expr,
19
const
exprt
&array_length_expr,
20
const
source_locationt
&loc);
21
23
struct
object_creation_referencet
24
{
27
exprt
expr
;
28
33
std::optional<exprt>
array_length
;
34
};
35
40
class
code_with_referencest
41
{
42
public
:
43
using
reference_substitutiont
=
44
std::function<
const
object_creation_referencet
&(
const
std::string &)>;
45
46
virtual
code_blockt
to_code
(
reference_substitutiont
&)
const
= 0;
47
48
virtual
~code_with_referencest
() =
default
;
49
};
50
52
class
code_without_referencest
:
public
code_with_referencest
53
{
54
public
:
55
codet
code
;
56
57
explicit
code_without_referencest
(
codet
code
) :
code
(
std
::move(
code
))
58
{
59
}
60
61
code_blockt
to_code
(
reference_substitutiont
&)
const override
62
{
63
return
code_blockt
({
code
});
64
}
65
};
66
76
class
reference_allocationt
:
public
code_with_referencest
77
{
78
public
:
79
std::string
reference_id
;
80
source_locationt
loc
;
81
82
reference_allocationt
(std::string
reference_id
,
source_locationt
loc
)
83
:
reference_id
(
std
::move(
reference_id
)),
loc
(
std
::move(
loc
))
84
{
85
}
86
87
code_blockt
to_code
(
reference_substitutiont
&references)
const override
;
88
};
89
92
class
code_with_references_listt
93
{
94
public
:
95
std::list<std::shared_ptr<code_with_referencest>>
list
;
96
97
void
add
(
code_without_referencest
code);
98
99
void
add
(
codet
code);
100
101
void
add
(
reference_allocationt
ref);
102
103
void
append
(
code_with_references_listt
&&other);
104
105
void
add_to_front
(
code_without_referencest
code);
106
};
107
108
#endif
// CPROVER_JAVA_BYTECODE_CODE_WITH_REFERENCES_H
code_blockt
A codet representing sequential composition of program statements.
Definition
std_code.h:130
code_with_references_listt
Wrapper around a list of shared pointer to code_with_referencest objects, which provides a nicer inte...
Definition
code_with_references.h:93
code_with_references_listt::add_to_front
void add_to_front(code_without_referencest code)
Definition
code_with_references.cpp:73
code_with_references_listt::list
std::list< std::shared_ptr< code_with_referencest > > list
Definition
code_with_references.h:95
code_with_references_listt::append
void append(code_with_references_listt &&other)
Definition
code_with_references.cpp:68
code_with_references_listt::add
void add(code_without_referencest code)
Definition
code_with_references.cpp:51
code_with_referencest
Base class for code which can contain references which can get replaced before generating actual code...
Definition
code_with_references.h:41
code_with_referencest::~code_with_referencest
virtual ~code_with_referencest()=default
code_with_referencest::to_code
virtual code_blockt to_code(reference_substitutiont &) const =0
code_with_referencest::reference_substitutiont
std::function< const object_creation_referencet &(const std::string &)> reference_substitutiont
Definition
code_with_references.h:43
code_without_referencest
Code that should not contain reference.
Definition
code_with_references.h:53
code_without_referencest::code
codet code
Definition
code_with_references.h:55
code_without_referencest::code_without_referencest
code_without_referencest(codet code)
Definition
code_with_references.h:57
code_without_referencest::to_code
code_blockt to_code(reference_substitutiont &) const override
Definition
code_with_references.h:61
codet
Data structure for representing an arbitrary statement in a program.
Definition
std_code_base.h:29
exprt
Base class for all expressions.
Definition
expr.h:57
reference_allocationt
Allocation code which contains a reference.
Definition
code_with_references.h:77
reference_allocationt::reference_allocationt
reference_allocationt(std::string reference_id, source_locationt loc)
Definition
code_with_references.h:82
reference_allocationt::loc
source_locationt loc
Definition
code_with_references.h:80
reference_allocationt::reference_id
std::string reference_id
Definition
code_with_references.h:79
reference_allocationt::to_code
code_blockt to_code(reference_substitutiont &references) const override
Definition
code_with_references.cpp:29
source_locationt
Definition
source_location.h:20
allocate_array
codet allocate_array(const exprt &expr, const exprt &array_length_expr, const source_locationt &loc)
Allocate a fresh array of length array_length_expr and assigns expr to it.
Definition
code_with_references.cpp:14
std
STL namespace.
std_code.h
object_creation_referencet
Information to store when several references point to the same Java object.
Definition
code_with_references.h:24
object_creation_referencet::array_length
std::optional< exprt > array_length
If symbol is an array, this expression stores its length.
Definition
code_with_references.h:33
object_creation_referencet::expr
exprt expr
Expression for the symbol that stores the value that may be reference equal to other values.
Definition
code_with_references.h:27
jbmc
src
java_bytecode
code_with_references.h
Generated by
1.17.0