void ExpressionFreeVariableLister::visit(Symbolic::IntegerMaxMin* obj, void* arg)
{
    std::list<Symbolic::Expression*> expressions = obj->getExpressions();
    std::list<Symbolic::Expression*>::iterator iter;

    for (iter = expressions.begin(); iter != expressions.end(); iter++) {
        Symbolic::Expression* expression = *iter;
        expression->accept(this);
    }
}
void ExpressionFreeVariableLister::visit(Symbolic::ObjectArrayIndexOf* obj, void* arg)
{
    obj->getSearchelement()->accept(this, arg);

    std::list<Symbolic::Expression*> list = obj->getArray();
    std::list<Symbolic::Expression*>::iterator it = list.begin();
    for (; it != list.end(); ++it) {
        Symbolic::Expression* elm = (*it);
        elm->accept(this);
    }
}
示例#3
0
void ExpressionPrinter::visit(Symbolic::IntegerMaxMin* obj, void* arg)
{
    if (obj->getMax()) {
        m_result += "IntegerMax( ";
    } else {
        m_result += "IntegerMin( ";
    }

    std::list<Symbolic::Expression*> expressions = obj->getExpressions();
    std::list<Symbolic::Expression*>::iterator iter;

    for (iter = expressions.begin(); iter != expressions.end(); iter++) {
        if (iter != expressions.begin()) {
            m_result += ", ";
        }

        Symbolic::Expression* expression = *iter;
        expression->accept(this);
    }

    m_result += " )";
}
示例#4
0
文件: smt.cpp 项目: mrgenco/Artemis
void SMTConstraintWriter::visit(Symbolic::IntegerMaxMin* obj, void* arg)
{

    std::list<Symbolic::Expression*> expressions = obj->getExpressions();
    std::list<Symbolic::Expression*>::iterator iter;

    std::string comp = obj->getMax() ?  ">" : "<";

    std::string last_var = "0"; // returned if people use Math.max() / Math.min(), correct behaviour would be -infty, but we can't model that

    for (iter = expressions.begin(); iter != expressions.end(); iter++) {

        Symbolic::Expression* expression = *iter;
        expression->accept(this);

        if(!checkType(Symbolic::INT)){
            error("Integer max/min operation with incorrectly typed argument");
            return;
        }

        std::string new_var = this->emitAndReturnNewTemporary(Symbolic::INT);

        if (iter == expressions.begin()) {
            // this is the first element
            mOutput << "(assert (= " << new_var << " " << mExpressionBuffer << " ))" << std::endl;
        } else {

            mOutput << "(assert (= " << new_var << " (ite (" << comp << " " << last_var << " " << mExpressionBuffer << " ) " << last_var << " " << mExpressionBuffer << " )))" << std::endl;
        }

        last_var = new_var;

    }

    mExpressionBuffer = last_var;
    mExpressionType = Symbolic::INT;

}