CBMC
smt_object_size.cpp
Go to the documentation of this file.
1
// Author: Diffblue Ltd.
2
3
#include "
smt_object_size.h
"
4
5
#include <
util/c_types.h
>
6
#include <
util/config.h
>
7
8
#include <
solvers/smt2_incremental/convert_expr_to_smt.h
>
9
#include <
solvers/smt2_incremental/smt_core_theory.h
>
10
#include <
solvers/smt2_incremental/smt_sorts.h
>
11
12
static
smt_declare_function_commandt
make_object_size_function_declaration
()
13
{
14
return
smt_declare_function_commandt
{
15
smt_identifier_termt
{
16
"size_of_object"
,
convert_type_to_smt_sort
(
size_type
())},
17
{
smt_bit_vector_sortt
{
config
.
bv_encoding
.
object_bits
}}};
18
}
19
20
smt_object_sizet::smt_object_sizet
()
21
: declaration{
make_object_size_function_declaration
()},
22
make_application{
smt_command_functiont
{declaration}}
23
{
24
}
25
26
smt_commandt
smt_object_sizet::make_definition
(
27
const
std::size_t unique_id,
28
smt_termt
size)
const
29
{
30
const
auto
id_sort =
31
declaration
.
parameter_sorts
().at(0).get().cast<
smt_bit_vector_sortt
>();
32
INVARIANT
(id_sort,
"Object identifiers are expected to have bit vector sort"
);
33
const
auto
bit_vector_of_id =
34
smt_bit_vector_constant_termt
{unique_id, *id_sort};
35
return
smt_assert_commandt
{
smt_core_theoryt::equal
(
36
make_application
(std::vector<smt_termt>{bit_vector_of_id}),
37
std::move(size))};
38
}
smt_object_sizet::make_application
make_applicationt make_application
Definition:
smt_object_size.h:23
configt::bv_encodingt::object_bits
std::size_t object_bits
Definition:
config.h:336
configt::bv_encoding
struct configt::bv_encodingt bv_encoding
smt_identifier_termt
Stores identifiers in unescaped and unquoted form.
Definition:
smt_terms.h:91
smt_object_sizet::declaration
smt_declare_function_commandt declaration
The command for declaring the object size function.
Definition:
smt_object_size.h:19
smt_termt
Definition:
smt_terms.h:20
smt_core_theory.h
smt_bit_vector_sortt
Definition:
smt_sorts.h:83
smt_sorts.h
smt_object_size.h
smt_declare_function_commandt
Definition:
smt_commands.h:46
smt_object_sizet::make_definition
smt_commandt make_definition(std::size_t unique_id, smt_termt size) const
Makes the command to define the resulting size of calling the object size function with unique_id.
Definition:
smt_object_size.cpp:26
smt_commandt
Definition:
smt_commands.h:13
smt_declare_function_commandt::parameter_sorts
std::vector< std::reference_wrapper< const smt_sortt > > parameter_sorts() const
Definition:
smt_commands.cpp:69
config
configt config
Definition:
config.cpp:25
make_object_size_function_declaration
static smt_declare_function_commandt make_object_size_function_declaration()
Definition:
smt_object_size.cpp:12
smt_assert_commandt
Definition:
smt_commands.h:32
smt_core_theoryt::equal
static const smt_function_application_termt::factoryt< equalt > equal
Definition:
smt_core_theory.h:57
smt_object_sizet::smt_object_sizet
smt_object_sizet()
Definition:
smt_object_size.cpp:20
config.h
size_type
unsignedbv_typet size_type()
Definition:
c_types.cpp:68
smt_bit_vector_constant_termt
Definition:
smt_terms.h:116
smt_command_functiont
A function generated from a command.
Definition:
smt_commands.h:145
convert_type_to_smt_sort
static smt_sortt convert_type_to_smt_sort(const bool_typet &type)
Definition:
convert_expr_to_smt.cpp:83
c_types.h
validation_modet::INVARIANT
@ INVARIANT
convert_expr_to_smt.h
src
solvers
smt2_incremental
smt_object_size.cpp
Generated by
1.8.17