CBMC
sentinel_dll.h
Go to the documentation of this file.
1 /*******************************************************************\
2 
3 Module: Sentinel Doubly Linked Lists
4 
5 Author: Daniel Kroening, dkr@amazon.com
6 
7 \*******************************************************************/
8 
9 #ifndef CPROVER_CPROVER_SENTINEL_DLL_H
10 #define CPROVER_CPROVER_SENTINEL_DLL_H
11 
12 #include <util/std_expr.h>
13 
15 {
16 public:
19  ID_state_is_sentinel_dll,
20  {state, head, tail},
21  bool_typet())
22  {
23  PRECONDITION(this->state().type().id() == ID_state);
24  PRECONDITION(this->head().type().id() == ID_pointer);
25  PRECONDITION(this->tail().type().id() == ID_pointer);
26  }
27 
30  ID_state_is_sentinel_dll,
31  {state, head, tail, node},
32  bool_typet())
33  {
34  PRECONDITION(this->state().type().id() == ID_state);
35  PRECONDITION(this->head().type().id() == ID_pointer);
36  PRECONDITION(this->tail().type().id() == ID_pointer);
37  }
38 
39  const exprt &state() const
40  {
41  return op0();
42  }
43 
45  {
46  return op0();
47  }
48 
49  const exprt &head() const
50  {
51  return op1();
52  }
53 
55  {
56  return op1();
57  }
58 
59  const exprt &tail() const
60  {
61  return op2();
62  }
63 
65  {
66  return op2();
67  }
68 
69  // helper
71  {
72  auto result = *this; // copy
73  result.state() = std::move(state);
74  return result;
75  }
76 };
77 
84 inline const state_is_sentinel_dll_exprt &
86 {
87  PRECONDITION(expr.id() == ID_state_is_sentinel_dll);
88  const state_is_sentinel_dll_exprt &ret =
89  static_cast<const state_is_sentinel_dll_exprt &>(expr);
90  validate_expr(ret);
91  return ret;
92 }
93 
96 {
97  PRECONDITION(expr.id() == ID_state_is_sentinel_dll);
99  static_cast<state_is_sentinel_dll_exprt &>(expr);
100  validate_expr(ret);
101  return ret;
102 }
103 
104 std::optional<exprt>
105 sentinel_dll_next(const exprt &state, const exprt &node, const namespacet &);
106 
107 std::optional<exprt>
108 sentinel_dll_prev(const exprt &state, const exprt &node, const namespacet &);
109 
110 #endif // CPROVER_CPROVER_SENTINEL_DLL_H
void validate_expr(const shuffle_vector_exprt &value)
Definition: c_expr.h:82
The Boolean type.
Definition: std_types.h:36
Base class for all expressions.
Definition: expr.h:56
typet & type()
Return the type of the expression.
Definition: expr.h:84
const irep_idt & id() const
Definition: irep.h:388
A base class for multi-ary expressions Associativity is not specified.
Definition: std_expr.h:912
exprt & op2()
Definition: std_expr.h:944
exprt & op1()
Definition: std_expr.h:938
exprt & op0()
Definition: std_expr.h:932
A namespacet is essentially one or two symbol tables bound together, to allow for symbol lookups in t...
Definition: namespace.h:94
const exprt & head() const
Definition: sentinel_dll.h:49
state_is_sentinel_dll_exprt(exprt state, exprt head, exprt tail, exprt node)
Definition: sentinel_dll.h:28
state_is_sentinel_dll_exprt with_state(exprt state) const
Definition: sentinel_dll.h:70
state_is_sentinel_dll_exprt(exprt state, exprt head, exprt tail)
Definition: sentinel_dll.h:17
const exprt & tail() const
Definition: sentinel_dll.h:59
const exprt & state() const
Definition: sentinel_dll.h:39
std::optional< exprt > sentinel_dll_prev(const exprt &state, const exprt &node, const namespacet &)
const state_is_sentinel_dll_exprt & to_state_is_sentinel_dll_expr(const exprt &expr)
Cast an exprt to a state_is_sentinel_dll_exprt.
Definition: sentinel_dll.h:85
std::optional< exprt > sentinel_dll_next(const exprt &state, const exprt &node, const namespacet &)
#define PRECONDITION(CONDITION)
Definition: invariant.h:463
API to expression classes.