/* * We visit terms breadth-first to check for cycles. * The index of all visited terms are stored in subst->cache. * The terms to process are stored in subst->queue. */ static void bfs_visit_index(intern_tbl_t *tbl, int32_t i) { if (kind_for_idx(tbl->terms, i) == UNINTERPRETED_TERM) { // replace i by its root i = index_of(intern_tbl_get_root(tbl, pos_term(i))); } if (int_hset_add(tbl->cache, i)) { // i has not been seen before int_queue_push(tbl->queue, i); } }
/* * Collect the root classes (and sort them) */ static void collect_root_classes(egraph_t *egraph, int_hset_t *roots) { uint32_t i, n; n = egraph->terms.nterms; for (i=0; i<n; i++) { if (egraph->terms.body[i] != NULL) { int_hset_add(roots, egraph_term_class(egraph, i)); } } int_hset_close(roots); // coercion to (int32_t *) is safe since class_ids are less than INT32_MAX int_array_sort((int32_t *)roots->data, roots->nelems); }
/* * Check whether t is in the cache. * If not, add t to the cache and to the end of the queue */ static void flattener_push_term(flattener_t *flat, term_t t) { if (int_hset_add(&flat->cache, t)) { int_queue_push(&flat->queue, t); } }
/* * Add t to queue and cache if it's not already in the cache */ static void push_term(int_queue_t *queue, int_hset_t *cache, term_t t) { if (int_hset_add(cache, t)) { int_queue_push(queue, t); } }