47 named_subt::const_iterator it=s.find(name);
54 return it->second.id();
59 return get(name)==ID_1;
96 auto it = s.find(name);
113 #if NAMED_SUB_IS_FORWARD_LIST
114 return s.add(name, std::move(irep));
116 std::pair<named_subt::iterator, bool> entry = s.emplace(
117 std::piecewise_construct,
118 std::forward_as_tuple(name),
119 std::forward_as_tuple(irep));
122 entry.first->second = std::move(irep);
124 return entry.first->second;
128 #ifdef IREP_HASH_STATS
129 unsigned long long irep_cmp_cnt=0;
130 unsigned long long irep_cmp_ne_cnt=0;
135 #ifdef IREP_HASH_STATS
145 #ifdef IREP_HASH_STATS
155 named_subt::const_iterator this_it = this_named_sub.begin();
156 named_subt::const_iterator other_it = other_named_sub.begin();
158 while(this_it != this_named_sub.end() || other_it != other_named_sub.end())
160 if(this_it != this_named_sub.end() &&
is_comment(this_it->first))
166 if(other_it != other_named_sub.end() &&
is_comment(other_it->first))
173 this_it == this_named_sub.end() ||
174 other_it == other_named_sub.end() ||
175 this_it->first != other_it->first ||
176 this_it->second != other_it->second)
178 #ifdef IREP_HASH_STATS
205 if(i1_sub.size() != i2_sub.size())
211 if(i1_named_sub.size() != i2_named_sub.size())
214 for(std::size_t i=0; i<i1_sub.size(); i++)
215 if(!i1_sub[i].
full_eq(i2_sub[i]))
219 irept::named_subt::const_iterator i1_it=i1_named_sub.begin();
220 irept::named_subt::const_iterator i2_it=i2_named_sub.begin();
222 for(; i1_it!=i1_named_sub.end(); i1_it++, i2_it++)
223 if(i1_it->first!=i2_it->first ||
224 !i1_it->second.full_eq(i2_it->second))
242 if(X.sub.size()<Y.sub.size())
244 if(Y.sub.size()<X.sub.size())
248 irept::subt::const_iterator it1, it2;
250 for(it1=X.sub.begin(),
252 it1!=X.sub.end() && it2!=Y.sub.end();
262 INVARIANT(it1==X.sub.end() && it2==Y.sub.end(),
263 "Unequal lengths will return before this");
266 if(X.named_sub.size()<Y.named_sub.size())
268 if(Y.named_sub.size()<X.named_sub.size())
272 irept::named_subt::const_iterator it1, it2;
274 for(it1=X.named_sub.begin(),
275 it2=Y.named_sub.begin();
276 it1!=X.named_sub.end() && it2!=Y.named_sub.end();
280 if(it1->first<it2->first)
282 if(it2->first<it1->first)
285 if(
ordering(it1->second, it2->second))
287 if(
ordering(it2->second, it1->second))
291 INVARIANT(it1==X.named_sub.end() && it2==Y.named_sub.end(),
292 "Unequal lengths will return before this");
318 irept::subt::const_iterator it1, it2;
326 r=it1->compare(*it2);
332 "Unequal lengths will return before this");
344 irept::named_subt::const_iterator it1, it2;
371 it2 != i.
get_named_sub().end(),
"not at end of i.get_named_sub()");
373 r=it1->first.compare(it2->first);
377 r=it1->second.compare(it2->second);
387 "Unequal number of non-comments will return before this");
400 #ifdef IREP_HASH_STATS
401 unsigned long long irep_hash_cnt=0;
406 std::size_t result = 0;
408 for(
const auto &n : named_sub)
418 if(
read().hash_code!=0)
427 for(
const auto &irep : sub)
430 std::size_t number_of_named_ireps = 0;
432 for(
const auto &irep_entry : named_sub)
437 result =
hash_combine(result, irep_entry.second.hash());
438 number_of_named_ireps++;
442 result =
hash_finalize(result, sub.size() + number_of_named_ireps);
447 #ifdef IREP_HASH_STATS
460 for(
const auto &irep : sub)
464 for(
const auto &irep_entry : named_sub)
467 result =
hash_combine(result, irep_entry.second.full_hash());
470 const std::size_t named_sub_size = named_sub.size();
478 for(
unsigned i=0; i<indent; i++)
484 if(max_indent>0 && indent>max_indent)
504 result += irep_entry.second.pretty(indent + 2, max_indent);
509 for(
const auto &irep :
get_sub())
517 result += irep.pretty(indent + 2, max_indent);
dstringt has one field, an unsigned integer no which is an index into a static table of strings.
int compare(const dstringt &b) const
There are a large number of kinds of tree structured or tree-like data in CPROVER.
static std::size_t number_of_non_comments(const named_subt &)
count the number of named_sub elements that are not comments
bool get_bool(const irep_idt &name) const
bool operator==(const irept &other) const
std::string pretty(unsigned indent=0, unsigned max_indent=0) const
void move_to_named_sub(const irep_idt &name, irept &irep)
std::size_t get_size_t(const irep_idt &name) const
const irept & find(const irep_idt &name) const
bool ordering(const irept &other) const
defines ordering on the internal representation
const irep_idt & get(const irep_idt &name) const
named_subt & get_named_sub()
const std::string & id_string() const
void remove(const irep_idt &name)
void set(const irep_idt &name, const irep_idt &value)
void set_size_t(const irep_idt &name, const std::size_t value)
int compare(const irept &i) const
defines ordering on the internal representation comments are ignored
bool operator<(const irept &other) const
defines ordering on the internal representation
const irep_idt & id() const
bool full_eq(const irept &other) const
long long get_long_long(const irep_idt &name) const
std::size_t full_hash() const
signed int get_int(const irep_idt &name) const
static bool is_comment(const irep_idt &name)
void move_to_sub(irept &irep)
const std::string & get_string(const irep_idt &name) const
irept & add(const irep_idt &name)
typename dt::named_subt named_subt
size_t hash_string(const dstringt &s)
static std::enable_if< std::is_integral< T >::value, dstringt >::type to_dstring(T value)
equivalent to dstringt(std::to_string(value)), i.e., produces a string from a number
static void indent_str(std::string &s, unsigned indent)
const irept & get_nil_irep()
const std::string & id2string(const irep_idt &d)
#define hash_finalize(h1, len)
#define hash_combine(h1, h2)
std::size_t unsafe_string2size_t(const std::string &str, int base)
int unsafe_string2int(const std::string &str, int base)
signed long long int unsafe_string2signedlonglong(const std::string &str, int base)
std::string to_string(const string_not_contains_constraintt &expr)
Used for debug printing.
irep_pretty_diagnosticst(const irept &irep)