CBMC
smt_index.h
Go to the documentation of this file.
1 // Author: Diffblue Ltd.
2 
3 #ifndef CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_INDEX_H
4 #define CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_INDEX_H
5 
6 #include <util/irep.h>
7 
9 
13 class smt_indext : protected irept
14 {
15 public:
16  // smt_indext does not support the notion of an empty / null state. Use
17  // optionalt<smt_indext> instead if an empty index is required.
18  smt_indext() = delete;
19 
20  using irept::pretty;
21 
22  bool operator==(const smt_indext &) const;
23  bool operator!=(const smt_indext &) const;
24 
25  template <typename sub_classt>
26  const sub_classt *cast() const &;
27 
29 
35  template <typename derivedt>
36  class storert
37  {
38  protected:
39  storert();
40  static irept upcast(smt_indext index);
41  static const smt_indext &downcast(const irept &);
42  };
43 
44 protected:
45  using irept::irept;
46 };
47 
48 template <typename derivedt>
50 {
51  static_assert(
52  std::is_base_of<irept, derivedt>::value &&
53  std::is_base_of<storert<derivedt>, derivedt>::value,
54  "Only irept based classes need to upcast smt_sortt to store it.");
55 }
56 
57 template <typename derivedt>
59 {
60  return static_cast<irept &&>(std::move(index));
61 }
62 
63 template <typename derivedt>
65 {
66  return static_cast<const smt_indext &>(irep);
67 }
68 
70 {
71 public:
72  explicit smt_numeral_indext(std::size_t value);
73  std::size_t value() const;
74 };
75 
77 {
78 public:
80  irep_idt identifier() const;
81 };
82 
84 {
85 public:
86  virtual void visit(const smt_numeral_indext &) = 0;
87  virtual void visit(const smt_symbol_indext &) = 0;
88 };
89 
90 #endif // CPROVER_SOLVERS_SMT2_INCREMENTAL_SMT_INDEX_H
smt_indext::storert::storert
storert()
Definition: smt_index.h:49
dstringt
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
Definition: dstring.h:36
smt_indext::operator!=
bool operator!=(const smt_indext &) const
Definition: smt_index.cpp:14
smt_indext::accept
void accept(smt_index_const_downcast_visitort &) const
Definition: smt_index.cpp:35
irept::pretty
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
Definition: irep.cpp:495
smt_indext
For implementation of indexed identifiers.
Definition: smt_index.h:13
smt_numeral_indext
Definition: smt_index.h:69
smt_symbol_indext::identifier
irep_idt identifier() const
Definition: smt_index.cpp:62
smt_index_const_downcast_visitort::visit
virtual void visit(const smt_numeral_indext &)=0
smt_indext::storert::downcast
static const smt_indext & downcast(const irept &)
Definition: smt_index.h:64
smt_numeral_indext::smt_numeral_indext
smt_numeral_indext(std::size_t value)
Definition: smt_index.cpp:44
smt_indext::cast
const sub_classt * cast() const &
irept::irept
irept()=default
smt_symbol_indext::smt_symbol_indext
smt_symbol_indext(irep_idt identifier)
Definition: smt_index.cpp:55
smt_numeral_indext::value
std::size_t value() const
Definition: smt_index.cpp:50
smt_indext::operator==
bool operator==(const smt_indext &) const
Definition: smt_index.cpp:9
smt_indext::storert::upcast
static irept upcast(smt_indext index)
Definition: smt_index.h:58
smt_indext::storert
Class for adding the ability to up and down cast smt_indext to and from irept.
Definition: smt_index.h:36
smt_symbol_indext
Definition: smt_index.h:76
irept
There are a large number of kinds of tree structured or tree-like data in CPROVER.
Definition: irep.h:359
smt_index_const_downcast_visitort
Definition: smt_index.h:83
smt_indext::smt_indext
smt_indext()=delete
irep.h