コード例 #1
0
int main(void) {
  init_rationals();
  init_pprod_table(&ptable, 0);
  init_rba_buffer(&buffer, &ptable);

  run_tests(&buffer);

  delete_rba_buffer(&buffer);
  delete_pprod_table(&ptable);
  cleanup_rationals();
  return 0;
}
コード例 #2
0
/*
 * Initialize table
 * - the table is initially empty (size = 0)
 * - the array def is allocated on the first addition
 * - vtbl = associated variable table
 */
void init_bvexp_table(bvexp_table_t *table, bv_vartable_t *vtbl) {
  table->nvars = 0;
  table->size = 0;
  table->def = NULL;
  table->vtbl = vtbl;
  init_bvmlist_store(&table->store);
  init_bvmlist64_store(&table->store64);
  init_pprod_table(&table->pprods, 32);
  init_int_htbl(&table->htbl, 0);

  init_bvarith_buffer(&table->aux, &table->pprods, &table->store);
  init_bvarith64_buffer(&table->aux64, &table->pprods, &table->store64);
  init_pp_buffer(&table->pp, 10);
  init_bvconstant(&table->bvconst);
}
コード例 #3
0
int main(void) {
  uint32_t i, j, n;
  pprod_t *q;

  init_pprod_table(&ptbl, 10);
  init_pp_buffer(&buffer, 10);

  p[0] = empty_pp;
  p[1] = var_pp(0);
  p[2] = var_pp(1);
  p[3] = var_pp(2);
  p[4] = var_pp(3);
  num_prods = 5;

  for (i=0; i<5; i++) {
    for (j=0; j<5; j++) {
      q = pprod_mul(&ptbl, p[i], p[j]);
      print_pprod0(stdout, p[i]);
      printf(" * ");
      print_pprod0(stdout, p[j]);
      printf(" = ");
      print_pprod0(stdout, q);
      printf("\n");
      check_product(q);
      printf("\n");
    }
  }

  n = num_prods;
  for (i=0; i<n; i++) {
    for (j=0; j<n; j++) {
      q = pprod_mul(&ptbl, p[i], p[j]);
      print_pprod0(stdout, p[i]);
      printf(" * ");
      print_pprod0(stdout, p[j]);
      printf(" = ");
      print_pprod0(stdout, q);
      printf("\n");
      check_product(q);
      printf("\n");
    }
  }

  for (i=0; i<num_prods; i++) {
    pp_buffer_set_pprod(&buffer, p[i]);
    printf("p[%"PRIu32"] = %p = ", i, p[i]);
    print_pprod0(stdout, p[i]);
    printf("\n");
    printf("buffer: ");
    print_pp_buffer0(stdout, &buffer);
    printf("\n");
    q = pprod_from_buffer(&ptbl, &buffer);
    printf("prod from buffer = %p = ", q);
    print_pprod0(stdout, q);
    if (q != p[i]) {
      printf("BUG: HASH CONSING FAILED\n");
      fflush(stdout);
      abort();
    }
    printf("\n\n");
  }

  // delete the non-trivial products
  for (i=5; i<num_prods; i++) {
    q = p[i];
    assert(q != empty_pp && q != end_pp && !pp_is_var(q));
    printf("deleting p[%"PRIu32"] = %p = ", i, q);
    print_pprod0(stdout, q);
    printf("\n");
    delete_pprod(&ptbl, q);
  }
  printf("\n\n");

  p[5] = var_pp(4);
  num_prods = 6;

  // reconstruct more products
  q = pprod_mul(&ptbl, p[1], p[2]);
  printf("checking q = %p = ", q);
  print_pprod0(stdout, q);
  printf("\n");
  check_product(q);
  printf("\n");

  q = pprod_mul(&ptbl, p[2], p[3]);
  printf("checking q = %p = ", q);
  print_pprod0(stdout, q);
  printf("\n");
  check_product(q);
  printf("\n");

  q = pprod_mul(&ptbl, p[3], p[2]);
  printf("rechecking q = %p = ", q);
  print_pprod0(stdout, q);
  printf("\n");
  check_product(q);
  printf("\n");

  q = pprod_mul(&ptbl, p[3], p[4]);
  printf("checking q = %p = ", q);
  print_pprod0(stdout, q);
  printf("\n");
  check_product(q);
  printf("\n");

  q = pprod_mul(&ptbl, p[4], p[3]);
  printf("rechecking q = %p = ", q);
  print_pprod0(stdout, q);
  printf("\n");
  check_product(q);
  printf("\n");

  q = pprod_mul(&ptbl, p[4], p[5]);
  printf("checking q = %p = ", q);
  print_pprod0(stdout, q);
  printf("\n");
  check_product(q);
  printf("\n");

  q = pprod_mul(&ptbl, p[0], p[5]);
  printf("checking q = %p = ", q);
  print_pprod0(stdout, q);
  printf("\n");
  check_product(q);
  printf("\n");

  printf("*** Table content before GC ***\n");
  print_pprod_table(stdout, &ptbl);
  pprod_table_set_gc_mark(&ptbl, p[num_prods - 1]);
  pprod_table_gc(&ptbl);
  printf("\n*** Table content after GC ***\n");
  print_pprod_table(stdout, &ptbl);
  printf("\n");

  delete_pp_buffer(&buffer);
  delete_pprod_table(&ptbl);


  return 0;
}
コード例 #4
0
/*
 * Initialize table and store
 */
static void init_globals(void) {
  init_bvconstants();
  init_bvmlist_store(&store);
  init_pprod_table(&prod_table, 0);
}
コード例 #5
0
/*
 * Initialize table
 */
static void init_globals(void) {
  init_rationals();
  init_pprod_table(&prod_table, 0);
}