Go to the documentation of this file.
10 #ifndef CPROVER_UTIL_IREP_H
11 #define CPROVER_UTIL_IREP_H
26 #if !defined(NAMED_SUB_IS_FORWARD_LIST) && !defined(_GLIBCXX_DEBUG)
27 # define NAMED_SUB_IS_FORWARD_LIST 1
30 #if NAMED_SUB_IS_FORWARD_LIST
66 template <
bool enabled>
74 unsigned ref_count = 1;
96 template <
typename treet,
typename named_subtreest,
bool sharing = true>
101 typedef std::vector<treet>
subt;
147 :
data(std::move(_data)),
155 template <
typename derivedt,
typename named_subtreest>
171 :
data(new
dt(std::move(_id), std::move(_named_sub), std::move(_sub)))
199 std::cout <<
"COPY MOVE\n";
207 std::cout <<
"ASSIGN\n";
227 std::cout <<
"ASSIGN MOVE\n";
264 template <
typename derivedt,
typename named_subtreest>
269 template <
typename derivedt,
typename named_subtreest>
285 :
data(std::move(_id), std::move(_named_sub), std::move(_sub))
364 : public non_sharing_treet<
367 #if NAMED_SUB_IS_FORWARD_LIST
368 forward_list_as_mapt<irep_idt, irept>>
370 std::map<irep_idt, irept>>
378 return id() == ID_nil;
382 return id() != ID_nil;
390 :
baset(_id, _named_sub, _sub)
426 add(name, std::move(irep));
428 void set(
const irep_idt &name,
const long long value);
439 return !(*
this==other);
461 std::size_t
hash()
const;
466 std::string
pretty(
unsigned indent=0,
unsigned max_indent=0)
const;
469 {
return !name.
empty() && name[0]==
'#'; }
517 template <
typename derivedt,
typename named_subtreest>
521 std::cout <<
"DETACH1: " << data <<
'\n';
529 std::cout <<
"ALLOCATED " << data <<
'\n';
532 else if(data->ref_count > 1)
535 data =
new dt(*old_data);
538 std::cout <<
"ALLOCATED " << data <<
'\n';
542 remove_ref(old_data);
548 std::cout <<
"DETACH2: " << data <<
'\n';
552 template <
typename derivedt,
typename named_subtreest>
555 if(old_data == &empty_d)
559 nonrecursive_destructor(old_data);
565 std::cout <<
"R: " << old_data <<
" " << old_data->
ref_count <<
'\n';
572 std::cout <<
"D: " << pretty() <<
'\n';
573 std::cout <<
"DELETING " << old_data->
data <<
" " << old_data <<
'\n';
575 std::cout <<
"DEALLOCATING " << old_data <<
"\n";
582 std::cout <<
"DONE\n";
590 template <
typename derivedt,
typename named_subtreest>
594 std::vector<dt *> stack(1, old_data);
596 while(!stack.empty())
598 dt *d = stack.back();
599 stack.erase(--stack.end());
612 for(
typename named_subt::iterator it = d->
named_sub.begin();
616 stack.push_back(it->second.data);
617 it->second.data = &empty_d;
620 for(
typename subt::iterator it = d->
sub.begin(); it != d->
sub.end(); it++)
622 stack.push_back(it->data);
632 #endif // CPROVER_UTIL_IREP_H
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
std::vector< treet > subt
std::size_t get_size_t(const irep_idt &name) const
static void remove_ref(dt *old_data)
long long get_long_long(const irep_idt &name) const
void move_to_sub(irept &irep)
bool operator()(const irept &i1, const irept &i2) const
bool full_eq(const irept &other) const
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
sharing_treet tree_implementationt
Used to refer to this class from derived classes.
const irept & find(const irep_idt &name) const
irept(const irep_idt &_id, const named_subt &_named_sub, const subt &_sub)
void set(const irep_idt &name, irept irep)
typename dt::named_subt named_subt
static std::string diagnostics_as_string(const irep_pretty_diagnosticst &irep)
const irep_idt & get(const irep_idt &name) const
sharing_treet(const sharing_treet &irep)
static std::size_t number_of_non_comments(const named_subt &)
count the number of named_sub elements that are not comments
void move_to_named_sub(const irep_idt &name, irept &irep)
Used in tree_nodet for activating or not reference counting.
non_sharing_treet(irep_idt _id)
std::size_t operator()(const irept &irep) const
const std::string & id2string(const irep_idt &d)
named_subt & get_named_sub()
std::size_t operator()(const irept &irep) const
void id(const irep_idt &_data)
tree_nodet(irep_idt _data, named_subt _named_sub, subt _sub)
void set(const irep_idt &name, const irep_idt &value)
static void nonrecursive_destructor(dt *old_data)
Does the same as remove_ref, but using an explicit stack instead of recursion.
#define PRECONDITION(CONDITION)
bool operator!=(const irept &other) const
const std::string & id_string() const
const irept & get_nil_irep()
tree_nodet(irep_idt _data)
const std::string & get_string(const irep_idt &name) const
sharing_treet & operator=(const sharing_treet &irep)
sharing_treet(sharing_treet &&irep)
const irep_idt & id() const
const named_subt & get_named_sub() const
sharing_treet & operator=(sharing_treet &&irep)
void set_size_t(const irep_idt &name, const std::size_t value)
Helper to give us some diagnostic in a usable form on assertion failure.
dstring_hash irep_id_hash
bool operator==(const irept &other) const
irept(const irep_idt &_id)
Base class for tree-like data structures without sharing.
sharing_treet(irep_idt _id, named_subt _named_sub, subt _sub)
#define POSTCONDITION(CONDITION)
bool ordering(const irept &other) const
defines ordering on the internal representation
irept & add(const irep_idt &name)
const subt & get_sub() const
sharing_treet(irep_idt _id)
A node with data in a tree, it contains:
int compare(const irept &i) const
defines ordering on the internal representation comments are ignored
signed int get_int(const irep_idt &name) const
named_subtreest named_subt
std::string as_string(const ai_verifier_statust &status)
Makes a status message string from a status.
There are a large number of kinds of tree structured or tree-like data in CPROVER.
irep_pretty_diagnosticst(const irept &irep)
void remove(const irep_idt &name)
#define INVARIANT(CONDITION, REASON)
This macro uses the wrapper function 'invariant_violated_string'.
irep_idt data
This irep_idt is the only place to store data in an tree node.
bool operator<(const irept &other) const
defines ordering on the internal representation
static bool is_comment(const irep_idt &name)
non_sharing_treet()=default
typename dt::named_subt named_subt
bool get_bool(const irep_idt &name) const
non_sharing_treet(irep_idt _id, named_subt _named_sub, subt _sub)
Base class for tree-like data structures with sharing.
std::size_t full_hash() const