void insert(pdecl_manager & m, sort * const * s, sort * r) { if (m_num_params == 0) { SASSERT(m_const == 0); m.m().inc_ref(r); m_const = r; return; } psort_inst_cache * curr = this; while (true) { if (curr->m_num_params == 1) { SASSERT(!curr->m_map.contains(*s)); curr->m_map.insert(*s, r); m.m().inc_ref(*s); m.m().inc_ref(r); return; } void * next = 0; if (!curr->m_map.find(*s, next)) { next = new (m.a().allocate(sizeof(psort_inst_cache))) psort_inst_cache(curr->m_num_params-1); curr->m_map.insert(*s, next); m.m().inc_ref(*s); } SASSERT(next != 0); SASSERT(curr->m_num_params == static_cast<psort_inst_cache*>(next)->m_num_params + 1); s++; curr = static_cast<psort_inst_cache*>(next); } }
void finalize(pdecl_manager & m) { if (m_num_params == 0) { SASSERT(m_map.empty()); if (m_const) m.m().dec_ref(m_const); m_const = 0; } else { SASSERT(m_const == 0); obj_map<sort, void *>::iterator it = m_map.begin(); obj_map<sort, void *>::iterator end = m_map.end(); for (; it != end; ++it) { m.m().dec_ref((*it).m_key); if (m_num_params == 1) { m.m().dec_ref(static_cast<sort*>((*it).m_value)); } else { psort_inst_cache * child = static_cast<psort_inst_cache*>((*it).m_value); child->finalize(m); child->~psort_inst_cache(); m.a().deallocate(sizeof(psort_inst_cache), child); } } m_map.reset(); } }
void finalize(pdecl_manager & m) { if (m_num_params == 0) { SASSERT(m_map.empty()); if (m_const) m.m().dec_ref(m_const); m_const = nullptr; } else { SASSERT(m_const == 0); for (auto kv : m_map) { m.m().dec_ref(kv.m_key); if (m_num_params == 1) { m.m().dec_ref(static_cast<sort*>(kv.m_value)); } else { psort_inst_cache * child = static_cast<psort_inst_cache*>(kv.m_value); child->finalize(m); child->~psort_inst_cache(); m.a().deallocate(sizeof(psort_inst_cache), child); } } m_map.reset(); } }
virtual void finalize(pdecl_manager & m) { m.lazy_dec_ref(m_decl); m.lazy_dec_ref(m_args.size(), m_args.c_ptr()); psort::finalize(m); }
virtual void finalize(pdecl_manager & m) { m.m().dec_ref(m_sort); psort::finalize(m); }
psort_sort(unsigned id, pdecl_manager & m, sort * s):psort(id, 0), m_sort(s) { m.m().inc_ref(m_sort); }
void psort::finalize(pdecl_manager & m) { m.del_inst_cache(m_inst_cache); m_inst_cache = 0; }
void psort::cache(pdecl_manager & m, sort * const * s, sort * r) { if (!m_inst_cache) m_inst_cache = m.mk_inst_cache(m_num_params); m_inst_cache->insert(m, s, r); }
void finalize(pdecl_manager & m) override { m.m().dec_ref(m_sort); psort::finalize(m); }
void psort::reset_cache(pdecl_manager& m) { m.del_inst_cache(m_inst_cache); m_inst_cache = nullptr; }