CBMC
struct_encoding.h
Go to the documentation of this file.
1 // Author: Diffblue Ltd.
2 
3 #ifndef CPROVER_SOLVERS_SMT2_INCREMENTAL_STRUCT_ENCODING_H
4 #define CPROVER_SOLVERS_SMT2_INCREMENTAL_STRUCT_ENCODING_H
5 
6 #include <util/expr.h> // For passing exprt by value. // IWYU pragma: keep
7 #include <util/type.h> // For passing `typet` by value. // IWYU pragma: keep
8 
9 #include <memory>
10 
11 class namespacet;
12 class boolbv_widtht;
13 class member_exprt;
14 class struct_tag_typet;
15 class union_tag_typet;
16 
18 class struct_encodingt final
19 {
20 public:
21  explicit struct_encodingt(const namespacet &ns);
22  struct_encodingt(const struct_encodingt &other);
24 
25  typet encode(typet type) const;
26  exprt encode(exprt expr) const;
29  exprt
30  decode(const exprt &encoded, const struct_tag_typet &original_type) const;
31  exprt
32  decode(const exprt &encoded, const union_tag_typet &original_type) const;
33 
34 private:
35  std::unique_ptr<boolbv_widtht> boolbv_width;
36  std::reference_wrapper<const namespacet> ns;
37 
38  exprt encode_member(const member_exprt &member_expr) const;
39 };
40 
41 #endif // CPROVER_SOLVERS_SMT2_INCREMENTAL_STRUCT_ENCODING_H
Base class for all expressions.
Definition: expr.h:56
Extract member of struct or union.
Definition: std_expr.h:2854
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
Encodes struct types/values into non-struct expressions/types.
std::unique_ptr< boolbv_widtht > boolbv_width
std::reference_wrapper< const namespacet > ns
typet encode(typet type) const
exprt decode(const exprt &encoded, const struct_tag_typet &original_type) const
Reconstructs a struct expression of the original_type using the data from the bit vector encoded expr...
exprt encode_member(const member_exprt &member_expr) const
The member expression selects the value of a field from a struct or union.
struct_encodingt(const namespacet &ns)
A struct tag type, i.e., struct_typet with an identifier.
Definition: std_types.h:493
The type of an expression, extends irept.
Definition: type.h:29
A union tag type, i.e., union_typet with an identifier.
Definition: c_types.h:199
Defines typet, type_with_subtypet and type_with_subtypest.