func_decl * float_decl_plugin::mk_float_const_decl(decl_kind k, unsigned num_parameters, parameter const * parameters,
                                                   unsigned arity, sort * const * domain, sort * range) {
    sort * s;
    if (num_parameters == 1 && parameters[0].is_ast() && is_sort(parameters[0].get_ast()) && is_float_sort(to_sort(parameters[0].get_ast()))) {
        s = to_sort(parameters[0].get_ast());
    }
    else if (range != 0 && is_float_sort(range)) {
        s = range;
    }
    else {
        m_manager->raise_exception("sort of floating point constant was not specified");
    }

    SASSERT(is_sort_of(s, m_family_id, FLOAT_SORT));
    
    unsigned ebits = s->get_parameter(0).get_int();
    unsigned sbits = s->get_parameter(1).get_int();
    scoped_mpf val(m_fm);
    if (k == OP_FLOAT_NAN) {
        m_fm.mk_nan(ebits, sbits, val);
        SASSERT(m_fm.is_nan(val));
    }
    else if (k == OP_FLOAT_MINUS_INF) {
        m_fm.mk_ninf(ebits, sbits, val);
    }
    else {
        SASSERT(k == OP_FLOAT_PLUS_INF);
        m_fm.mk_pinf(ebits, sbits, val);
    }
    return mk_value_decl(val);
}
Exemplo n.º 2
0
app * float_decl_plugin::mk_value(mpf const & v) {
    return m_manager->mk_const(mk_value_decl(v));
}