void CAtom::remove_guard( CAtom** ptr ) { if( !*ptr ) return; GuardMap* map = guard_map(); if( !map || map->empty() ) return; bool more = false; // if the CAtom has more pointers attached to it. GuardMap::iterator it = map->find( *ptr ); const GuardMap::iterator end = map->end(); for( ; it != end && it->first == *ptr; ++it ) { if( it->second == ptr ) { if( !more ) { ++it; more = ( it != end ) && ( it->first == *ptr ); --it; } map->erase( it ); break; } more = true; } if( !more ) ( *ptr )->set_has_guards( false ); }
z3::expr Z3AssumptionSolverImpl::getAssumption(ref<Expr> assertion) { GuardMap::iterator it = guards_.find(assertion); if (it != guards_.end()) { return it->second; } char name[16]; snprintf(name, 16, "g%lu", guard_counter_++); z3::expr result = context_.bool_const(name); guards_.insert(std::make_pair(assertion, result)); solver_.add(z3::to_expr(context_, Z3_mk_implies(context_, result, builder_->construct(assertion)))); return result; }
void CAtom::clear_guards( CAtom* o ) { GuardMap* map = 0; try { map = guard_map(); } catch( std::bad_alloc& ) { // do nothing in case of OOM - code below is safe } if( !map || map->empty() ) return; GuardMap::iterator it = map->find( o ); GuardMap::iterator first = it; const GuardMap::iterator end = map->end(); for( ; it != end && it->first == o; ++it ) *it->second = 0; map->erase( first, it ); o->set_has_guards( false ); }