9 #ifndef CPROVER_UTIL_EXPR_ITERATOR_H
10 #define CPROVER_UTIL_EXPR_ITERATOR_H
48 std::reference_wrapper<const exprt>
expr;
65 template<
typename depth_iterator_t>
75 template <
typename other_depth_iterator_t>
78 template <
typename other_depth_iterator_t>
85 template <
typename other_depth_iterator_t>
89 return !(*
this == other);
99 if(
m_stack.back().op_idx ==
m_stack.back().expr.get().operands().size())
132 depth_iterator_t tmp(this->
downcast());
142 return m_stack.back().expr.get();
164 {
m_stack=std::move(other.m_stack); }
168 m_stack = std::move(other.m_stack);
174 return m_stack.front().expr.get();
194 expr = &expr->
operands()[state.op_idx];
211 std::deque<depth_iterator_expr_statet>
m_stack;
214 {
return static_cast<depth_iterator_t &
>(*this); }
277 "mutate_root must return the same root node that depth_iteratort was "
300 const bool inserted=this->
m_traversed.insert(expr).second;
const_depth_iteratort(const exprt &expr)
Create iterator starting at the supplied node (root)
const_depth_iteratort()=default
Create an end iterator.
friend depth_iterator_baset
const_unique_depth_iteratort()=default
Create an end iterator.
bool push_expr(const exprt &expr)
Push expression onto the stack and add to the set of traversed exprts.
std::set< exprt > m_traversed
const_unique_depth_iteratort(const exprt &expr)
Create iterator starting at the supplied node (root)
Depth first search iterator base - iterates over supplied expression and all its operands recursively...
const exprt * operator->() const
Dereference operator (member access) Dereferencing end() iterator is undefined behaviour.
exprt & mutate()
Obtain non-const exprt reference.
depth_iterator_baset(const depth_iterator_baset &)=default
std::deque< depth_iterator_expr_statet > m_stack
depth_iterator_baset & operator=(depth_iterator_baset &&other)
depth_iterator_baset(const exprt &root)
Create begin iterator, starting at the supplied node.
depth_iterator_baset(depth_iterator_baset &&other)
bool operator!=(const depth_iterator_baset< other_depth_iterator_t > &other) const
depth_iterator_t & next_sibling_or_parent()
bool push_expr(const exprt &expr)
Pushes expression onto the stack If overridden, this function should be called from the inheriting cl...
depth_iterator_t & downcast()
bool operator==(const depth_iterator_baset< other_depth_iterator_t > &other) const
const exprt & operator*() const
Dereference operator Dereferencing end() iterator is undefined behaviour.
depth_iterator_t operator++(int)
Post-increment operator Expensive copy.
std::forward_iterator_tag iterator_category
depth_iterator_t & operator++()
Preincrement operator Do not call on the end() iterator.
~depth_iterator_baset()=default
Destructor Protected to discourage upcasting.
depth_iterator_baset & operator=(const depth_iterator_baset &)=default
depth_iterator_baset()=default
Create end iterator.
depth_iteratort(const exprt &expr, std::function< exprt &()> mutate_root)
Create iterator starting at the supplied node (root) If mutations of the child nodes are required the...
depth_iteratort(exprt &expr)
Create iterator starting at the supplied node (root) All mutations of the child nodes will be reflect...
exprt & mutate()
Obtain non-const reference to the exprt instance currently pointed to by the iterator.
depth_iteratort()=default
Create an end iterator.
std::function< exprt &()> mutate_root
If this is non-empty then the root is currently const and this function must be called before any mut...
Base class for all expressions.
bool operator==(const depth_iterator_expr_statet &left, const depth_iterator_expr_statet &right)
int __CPROVER_ID java::java io InputStream read
#define PRECONDITION(CONDITION)
Helper class for depth_iterator_baset.
std::reference_wrapper< const exprt > expr
depth_iterator_expr_statet(const exprt &expr)
exprt::operandst::const_iterator operands_iteratort