Пример #1
0
/*
 * Store the mapping [v --> t] in the cache
 */
static void convert_cache_map(val_converter_t *convert, value_t v, term_t t) {
  int_hmap_pair_t *r;

  assert(good_object(convert->vtbl, v) && good_term(convert->terms, t));

  r = int_hmap_get(&convert->cache, v);
  assert(r->val < 0);
  r->val = t;
}
Пример #2
0
/*
 * Check what's mapped to v in convert->cache
 * - return -1 if nothing
 */
static term_t convert_cached_term(val_converter_t *convert, value_t v) {
  int_hmap_pair_t *r;
  term_t t;

  assert(good_object(convert->vtbl, v));

  t = NULL_TERM;
  r = int_hmap_find(&convert->cache, v);
  if (r != NULL) {
    t = r->val;
  }

  return t;
}
Пример #3
0
/*
 * Build a yval_t descriptor for value v defined in tbl
 * - v must be a valid index in tbl
 */
void get_yval(value_table_t *tbl, value_t v, yval_t *d) {
  assert(good_object(tbl, v));
  d->node_id = v;
  d->node_tag = tag_for_valkind(object_kind(tbl, v));
}