environment decl_attributes::apply(environment env, io_state const & ios, name const & d) const { if (m_is_instance) { if (m_priority) { #if defined(__GNUC__) && !defined(__CLANG__) #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif env = add_instance(env, d, *m_priority, m_persistent); } else { env = add_instance(env, d, m_persistent); } } if (m_is_trans_instance) { if (m_priority) { #if defined(__GNUC__) && !defined(__CLANG__) #pragma GCC diagnostic ignored "-Wmaybe-uninitialized" #endif env = add_trans_instance(env, d, *m_priority, m_persistent); } else { env = add_trans_instance(env, d, m_persistent); } } if (m_is_coercion) env = add_coercion(env, ios, d, m_persistent); auto decl = env.find(d); if (decl && decl->is_definition()) { if (m_is_reducible) env = set_reducible(env, d, reducible_status::Reducible, m_persistent); if (m_is_irreducible) env = set_reducible(env, d, reducible_status::Irreducible, m_persistent); if (m_is_semireducible) env = set_reducible(env, d, reducible_status::Semireducible, m_persistent); if (m_is_quasireducible) env = set_reducible(env, d, reducible_status::Quasireducible, m_persistent); if (m_unfold_hint) env = add_unfold_hint(env, d, m_unfold_hint, m_persistent); if (m_unfold_full_hint) env = add_unfold_full_hint(env, d, m_persistent); } if (m_constructor_hint) env = add_constructor_hint(env, d, m_persistent); if (m_symm) env = add_symm(env, d, m_persistent); if (m_refl) env = add_refl(env, d, m_persistent); if (m_trans) env = add_trans(env, d, m_persistent); if (m_subst) env = add_subst(env, d, m_persistent); if (m_recursor) env = add_user_recursor(env, d, m_recursor_major_pos, m_persistent); if (m_is_class) env = add_class(env, d, m_persistent); if (m_rewrite) env = add_rewrite_rule(env, d, m_persistent); if (m_has_multiple_instances) env = mark_multiple_instances(env, d, m_persistent); return env; }
static void parse_config_file(FILE *f) { char line[2048]; char *cp, *ptr; while (!feof(f)) { memset(line, 0, sizeof(line)); if (fgets(line, sizeof(line), f) == NULL) break; /* * Strip newlines and comments. */ cp = strchr(line, '\n'); if (cp) *cp = 0; cp = strchr(line, '#'); if (cp) *cp = 0; /* * Skip trailing and leading whitespace */ for (cp = line + strlen(line) - 1; cp >= line; cp--) { if (*cp == ' ' || *cp == '\t') *cp = 0; else break; } cp = line; while (*cp && isspace(*cp)) cp++; ptr = cp; /* * Skip empty lines */ if (*ptr == 0) continue; /* * Ignore future extensions */ if (*ptr == '@') continue; /* * Parse substitutions */ for (cp = ptr; *cp; cp++) if (isspace(*cp)) break; *cp = 0; for (cp++; *cp; cp++) if (!isspace(*cp)) break; #if 0 printf("Substitute: '%s' for '%s'\n", ptr, cp ? cp : "<NULL>"); #endif add_subst(ptr, cp); } }
static void test_assert_eq(test_bench_t *bench, int32_t x, int32_t y, int32_t offset) { offset_equality_t e; rational_t q; int32_t id; id = push_assert_eq(&bench->stack, x, y, offset); e.lhs = x; e.rhs = y; e.offset = offset; printf("[%"PRIu32"]: TEST_ASSERT_EQ: eq[%"PRId32"]: ", ctr, id); print_offset_eq(&e); printf("\n"); subst_eq(&bench->subst, &e); // if e.lhs == e.rhs, we can't add to the substitution table if (e.lhs != e.rhs) { if (e.lhs < 0) { // convert 0 = y + offset into y := -offset e.lhs = e.rhs; e.rhs = -1; e.offset = -e.offset; } // add substitution e.lhs := e.rhs + e.offset add_subst(&bench->subst, e.lhs, e.rhs, e.offset); subst_queue_push_var(&bench->squeue, e.lhs); } else if (e.offset != 0) { bench->conflict = true; printf("---> Conflict\n"); fflush(stdout); if (bench->conflict_eq < 0) { bench->conflict_eq = id; } } // forward to the offset manager q_init(&q); q_set32(&q, offset); assert_offset_equality(&bench->manager, x, y, &q, id); q_clear(&q); ctr ++; }
/* * Build a substitution from the equalities stored in v * - every element of v must be the id of a asserted equality * - if an equality can't be added to the substitution, it's left in v */ static substitution_t *subst_from_explanation(test_bench_t *bench, ivector_t *v) { substitution_t *s; op_stack_t *stack; offset_equality_t e; uint32_t i, j, n; int32_t id; s = (substitution_t *) safe_malloc(sizeof(substitution_t)); init_substitution(s, bench->ptable->npolys); stack = &bench->stack; j = 0; n = v->size; for (i=0; i<n; i++) { id = v->data[i]; assert(0 <= id && id < stack->top); assert(stack->data[id].tag == ASSERT_EQ); e = stack->data[id].arg.eq; // make a copy of eq[id] subst_eq(s, &e); // normalize eq modulo previous equalities if (e.lhs == e.rhs) { // keep in v v->data[j] = id; j ++; } else { // add to subst if (e.lhs < 0) { // convert 0 := rhs + offset into rhs = - offset e.lhs = e.rhs; e.rhs = -1; e.offset = - e.offset; } add_subst(s, e.lhs, e.rhs, e.offset); } } v->size = j; return s; }