本文整理汇总了C++中cache_t::contains方法的典型用法代码示例。如果您正苦于以下问题:C++ cache_t::contains方法的具体用法?C++ cache_t::contains怎么用?C++ cache_t::contains使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cache_t
的用法示例。
在下文中一共展示了cache_t::contains方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: abstract
expr_ref bind_variables::abstract(expr* term, cache_t& cache, unsigned scope) {
unsigned sz = m_todo.size();
m_todo.push_back(term);
m_args.reset();
expr* b, *arg;
while (m_todo.size() > sz) {
expr* e = m_todo.back();
if (cache.contains(e)) {
m_todo.pop_back();
continue;
}
switch(e->get_kind()) {
case AST_VAR: {
SASSERT(to_var(e)->get_idx() < scope);
// mixing bound variables and free is possible for the caller,
// but not proper use.
// So we assert here even though we don't check for it.
cache.insert(e, e);
m_todo.pop_back();
break;
}
case AST_APP: {
app* a = to_app(e);
var2bound::obj_map_entry* w = m_var2bound.find_core(a);
if (w) {
var* v = w->get_data().m_value;
if (!v) {
// allocate a bound index.
v = m.mk_var(m_names.size(), m.get_sort(a));
m_names.push_back(a->get_decl()->get_name());
m_bound.push_back(m.get_sort(a));
w->get_data().m_value = v;
m_pinned.push_back(v);
}
if (scope == 0) {
cache.insert(e, v);
}
else {
var* v1 = m.mk_var(scope + v->get_idx(), m.get_sort(v));
m_pinned.push_back(v1);
cache.insert(e, v1);
}
m_todo.pop_back();
break;
}
bool all_visited = true;
bool some_diff = false;
m_args.reset();
for (unsigned i = 0; i < a->get_num_args(); ++i) {
arg = a->get_arg(i);
if (!cache.find(arg, b)) {
m_todo.push_back(arg);
all_visited = false;
}
else if (all_visited) {
m_args.push_back(b);
if (b != arg) {
some_diff = true;
}
}
}
if (all_visited) {
if (some_diff) {
b = m.mk_app(a->get_decl(), m_args.size(), m_args.c_ptr());
m_pinned.push_back(b);
}
else {
b = a;
}
cache.insert(e, b);
m_todo.pop_back();
}
break;
}
case AST_QUANTIFIER: {
quantifier* q = to_quantifier(e);
expr_ref_buffer patterns(m);
expr_ref result1(m);
unsigned new_scope = scope + q->get_num_decls();
cache_t new_cache;
for (unsigned i = 0; i < q->get_num_patterns(); ++i) {
patterns.push_back(abstract(q->get_pattern(i), new_cache, new_scope));
}
result1 = abstract(q->get_expr(), new_cache, new_scope);
b = m.update_quantifier(q, patterns.size(), patterns.c_ptr(), result1.get());
m_pinned.push_back(b);
cache.insert(e, b);
m_todo.pop_back();
break;
}
default:
UNREACHABLE();
}
}
return expr_ref(cache.find(term), m);
}