Esempio n. 1
0
/*
 * Initialize a converter structure:
 * - vtbl = table of values
 * - term = term table
 */
void init_val_converter(val_converter_t *convert, value_table_t *vtbl, term_table_t *terms) {
  convert->vtbl = vtbl;
  convert->terms = terms;

  init_int_hmap(&convert->cache, 0); // default hmap size
  init_istack(&convert->stack);
  // convert->env not initialized
}
Esempio n. 2
0
/*
 * Initialize model
 * - terms = attached term table
 * - keep_subst = whether to support alias_map or not
 * - map and vtbl are given default sizes
 * - alias_map is NULL
 */
void init_model(model_t *model, term_table_t *terms, bool keep_subst) {
  init_value_table(&model->vtbl, 0, terms->types);
  value_table_set_namer(&model->vtbl, terms, (unint_namer_fun_t) name_of_const);

  init_int_hmap(&model->map, 0);
  model->alias_map = NULL;
  model->terms = terms;
  model->has_alias = keep_subst;

}
Esempio n. 3
0
/*
 * Store the substitution t --> u in the model
 * - t and u must be valid term indices
 * - t must be an uninterpreted term, not mapped to anything
 */
void model_add_substitution(model_t *model, term_t t, term_t u) {
  int_hmap_t *alias;
  int_hmap_pair_t *r;

  assert(term_kind(model->terms, t) == UNINTERPRETED_TERM &&
         good_term(model->terms, u) && t != u && model->has_alias &&
         int_hmap_find(&model->map, t) == NULL);

  alias = model->alias_map;
  if (alias == NULL) {
    alias = (int_hmap_t *) safe_malloc(sizeof(int_hmap_t));
    init_int_hmap(alias, 0); // default size
    model->alias_map = alias;
  }

  r = int_hmap_get(alias, t);
  assert(r->val < 0);
  r->val = u;
}
Esempio n. 4
0
/*
 * Allocate and initialize the internal imap
 */
void egraph_alloc_imap(egraph_t *egraph) {
  assert(egraph->imap == NULL);
  egraph->imap = (int_hmap_t *) safe_malloc(sizeof(int_hmap_t));
  init_int_hmap(egraph->imap, 0);
}