コード例 #1
0
 Z3_lbool Z3_API Z3_check_and_get_model(Z3_context c, Z3_model * m) {
     Z3_TRY;
     LOG_Z3_check_and_get_model(c, m);
     RESET_ERROR_CODE();
     CHECK_SEARCHING(c);
     cancel_eh<smt::kernel> eh(mk_c(c)->get_smt_kernel());
     api::context::set_interruptable(*(mk_c(c)), eh);
     flet<bool> _model(mk_c(c)->fparams().m_model, true);
     lbool result;
     try {
         model_ref _m;
         result = mk_c(c)->check(_m);
         if (m) {
             if (_m) {
                 Z3_model_ref * m_ref = alloc(Z3_model_ref); 
                 m_ref->m_model = _m;
                 // Must bump reference counter for backward compatibility reasons.
                 // Don't need to invoke save_object, since the counter was bumped
                 m_ref->inc_ref(); 
                 *m = of_model(m_ref);
             }
             else {
                 *m = 0;
             }
         }
     }
     catch (z3_exception & ex) {
         mk_c(c)->handle_exception(ex);
         RETURN_Z3_check_and_get_model static_cast<Z3_lbool>(l_undef);
     }
     RETURN_Z3_check_and_get_model static_cast<Z3_lbool>(result);
     Z3_CATCH_RETURN(Z3_L_UNDEF);
 }
コード例 #2
0
void ExecutionListView::deleteRegex()
{
    CSMesBackgroundComputations::Pauser pauser;
    ExecutionListModel *model_p=_model();
    if (! model_p)
        return;
    WExecutionDelete dialog(csmes_p,this);
    if (dialog.exec())
    {
        ExecutionNames sources=dialog.sourceList();
        csmes_p->beginUndoGroup(tr("Delete executions '%1'").arg(dialog.source()));
        int sz=sources.size();
        for (int i=0; i<sz; i++)
        {
            printStatus(tr("Deleting '%1'...").arg(sources.at(i)),static_cast<float>(i)/static_cast<float>(sz));
            if (!model_p->deleteExecution(sources.at(i)))
            {
                if (QMessageBox::warning(this,tr("Error"),tr("Deleting '%1' not possible.").arg(sources.at(i)),
                                         QMessageBox::Abort, QMessageBox::Ignore)==QMessageBox::Abort)
                    break;
            }
        }
        csmes_p->endUndoGroup();
        printStatus("",-1);
    }
}
コード例 #3
0
void ExecutionListView::renameIndex()
{
    QModelIndexList sel = selectedIndexes();
    ExecutionListModel *model_p=_model();
    if (! model_p)
        return;
    SortFilterProxy *sort_model_p=_sort_model();
    for (QModelIndexList::Iterator it=sel.begin(); it!=sel.end(); ++it)
    {
        bool ok;
        QModelIndex index;
        if (sort_model_p)
            index=sort_model_p->mapToSource(*it);
        else
            index=*it;

        QString old_name=model_p->executionName(index);
        QString new_name=QInputDialog::getText(this,tr("Rename execution"),tr("Name:"),QLineEdit::Normal,old_name,&ok);
        if (ok)
            ok=model_p->renameIndex(index,new_name);
        else
            return ;

        if (!ok)
            QMessageBox::warning ( this, tr("Renaming") , tr("Renaming %1 failed").arg(old_name),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
    }
}
コード例 #4
0
void ExecutionListView::deleteIndex()
{
    QModelIndexList sel = selectedIndexes();
    ExecutionListModel *model_p=_model();
    if (! model_p)
        return;

    switch (QMessageBox::question(this, tr("Deleting Execution"),
                                  tr("Are you sure?"),QMessageBox::Ok,QMessageBox::Cancel))
    {
    case QMessageBox::Ok:
        break;
    default:
        return ;
    }

    SortFilterProxy *sort_model_p=_sort_model();
    for (QModelIndexList::Iterator it=sel.begin(); it!=sel.end(); ++it)
    {
        bool ok;
        QModelIndex index;
        if (sort_model_p)
            index=sort_model_p->mapToSource(*it);
        else
            index=*it;

        QString name=model_p->executionName(index);
        ok=model_p->deleteIndex(index);
        if (!ok)
            QMessageBox::warning ( this, tr("Deletion") , tr("Deletion of  %1 failed").arg(name),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
    }
}
コード例 #5
0
 Z3_lbool Z3_API Z3_check_assumptions(Z3_context c, 
                                      unsigned num_assumptions, Z3_ast const assumptions[], 
                                      Z3_model * m, Z3_ast* proof, 
                                      unsigned* core_size, Z3_ast core[]) {
     Z3_TRY;
     LOG_Z3_check_assumptions(c, num_assumptions, assumptions, m, proof, core_size, core);
     RESET_ERROR_CODE();
     CHECK_SEARCHING(c);
     expr * const* _assumptions = to_exprs(assumptions);
     flet<bool> _model(mk_c(c)->fparams().m_model, true);
     cancel_eh<smt::kernel> eh(mk_c(c)->get_smt_kernel());
     api::context::set_interruptable(*(mk_c(c)), eh);
     lbool result;
     result = mk_c(c)->get_smt_kernel().check(num_assumptions, _assumptions);
     if (result != l_false && m) {
         model_ref _m;
         mk_c(c)->get_smt_kernel().get_model(_m);
         if (_m) {
             Z3_model_ref * m_ref = alloc(Z3_model_ref); 
             m_ref->m_model = _m;
             // Must bump reference counter for backward compatibility reasons.
             // Don't need to invoke save_object, since the counter was bumped
             m_ref->inc_ref(); 
             *m = of_model(m_ref);
         }
         else {
             *m = 0;
         }
     }
     if (result == l_false && core_size) {
         *core_size = mk_c(c)->get_smt_kernel().get_unsat_core_size();
         if (*core_size > num_assumptions) {
             SET_ERROR_CODE(Z3_INVALID_ARG);
         }
         for (unsigned i = 0; i < *core_size; ++i) {
             core[i] = of_ast(mk_c(c)->get_smt_kernel().get_unsat_core_expr(i));
         }
     }
     else if (core_size) {
         *core_size = 0;
     }
     if (result == l_false && proof) {
         *proof = of_ast(mk_c(c)->get_smt_kernel().get_proof());
     }
     else if (proof) {
         *proof = 0; // breaks abstraction.
     }
     RETURN_Z3_check_assumptions static_cast<Z3_lbool>(result);         
     Z3_CATCH_RETURN(Z3_L_UNDEF);
 }
コード例 #6
0
void ExecutionListView::moveIndexToFolder()
{
    QModelIndexList sel = selectedIndexes();
    ExecutionListModel *model_p=_model();
    if (! model_p)
        return;
    SortFilterProxy *sort_model_p=_sort_model();
    for (QModelIndexList::Iterator it=sel.begin(); it!=sel.end(); ++it)
    {
        bool ok;
        QModelIndex index;
        if (sort_model_p)
            index=sort_model_p->mapToSource(*it);
        else
            index=*it;

        QString old_full_name=model_p->executionName(index);
        int pos=old_full_name.lastIndexOf("/");
        QString old_path,old_name;
        if (pos>0)
        {
            old_path=old_full_name.mid(0,pos);
            old_name=old_full_name.mid(pos+1);
        }
        else
        {
            old_path="";
            old_name=old_full_name;
        }
        QString new_path=QInputDialog::getText(this,tr("Move to folder"),tr("Folder:"),QLineEdit::Normal,old_path,&ok);
        QString new_full_name;
        if (new_path=="")
            new_full_name=old_name;
        else
            new_full_name=new_path+"/"+old_name;

        if (old_full_name==new_full_name)
            return;

        if (ok)
            ok=model_p->renameIndex(index,new_full_name);
        else
            return ;

        if (!ok)
            QMessageBox::warning ( this, tr("Renaming") , tr("Renaming %1 failed").arg(old_full_name),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
    }
}
コード例 #7
0
void ExecutionListView::setComment()
{
    QModelIndexList sel = selectedIndexes();
    ExecutionListModel *model_p=_model();
    if (! model_p)
        return;

    SortFilterProxy *sort_model_p=_sort_model();
    for (QModelIndexList::Iterator it=sel.begin(); it!=sel.end(); ++it)
    {
        QModelIndex index;
        if (sort_model_p)
            index=sort_model_p->mapToSource(*it);
        else
            index=*it;

        QString name=model_p->executionName(index);
        QString comment ;
        if (!csmes_p->getExecutionComment(name,comment))
        {
            QMessageBox::warning ( this,
                                   tr("Commenting") ,
                                   tr("Reading comment of %1 failed").arg(name),
                                   QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
            return ;
        }
        WComment *comment_p = new WComment();
        comment_p->setCommentLengthCheck(false);
        comment_p->setText(comment);
        if (comment_p->exec())
        {
            comment=comment_p->text();
            if (!model_p->setExecutionComment(index,comment))
            {
                QMessageBox::warning ( this,
                                       tr("Commenting") ,
                                       tr("Changing comment of %1 failed").arg(name),
                                       QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
                return ;
            }
        }
    }
}
コード例 #8
0
void ExecutionListView::DecorateContextMenu ( QMenu * menu_p )
{
    QModelIndexList sel = selectedIndexes();
    if (sel.isEmpty())
        return;
    ExecutionListModel *model_p=_model();
    if (! model_p)
        return;
    SortFilterProxy *sort_model_p=_sort_model();
    bool editable=false;
    for (int i=0; i<sel.count(); i++)
    {
        QModelIndex index;
        if (sort_model_p)
            index=sort_model_p->mapToSource(sel.at(i));
        else
            index=sel.at(i);
        Qt::ItemFlags flags=model_p->flags(index);
        if (index.column()==0 && ( (flags&Qt::ItemIsEditable) == Qt::ItemIsEditable) )
            editable=true;
    }

    menu_p->addAction(tr("Delete"),this,SLOT(deleteIndex()));
    if (editable)
    {
        menu_p->addAction(tr("Rename..."),this,SLOT(renameIndex()));
        menu_p->addAction(tr("Place in folder..."),this,SLOT(moveIndexToFolder()));
        menu_p->addAction(tr("Comment..."),this,SLOT(setComment()));
    }
    if (csmes_p)
    {
        menu_p->addSeparator();
        menu_p->addAction(tr("Rename multiple executions..."),this,SLOT(renameRegex()));
        menu_p->addAction(tr("Delete multiple executions..."),this,SLOT(deleteRegex()));
        menu_p->addAction(tr("Merge executions together..."),this,SLOT(mergeRegex()));
    }
}
コード例 #9
0
void ExecutionListView::mergeRegex()
{
    CSMesBackgroundComputations::Pauser pauser;
    ExecutionListModel *model_p=_model();
    if (! model_p)
        return;
    WExecutionMerge dialog(csmes_p,this);
    if (dialog.exec())
    {
        csmes_p->beginUndoGroup(tr("Merge executions '%1' -> '%2'").arg(dialog.source()).arg(dialog.destination()));
        ExecutionNames sources=dialog.sourceList();
        QString name=dialog.destinationExecution();
        printStatus(tr("Generating '%1'...").arg(name),0.0);
        if (!model_p->mergeExecutions(sources,name))
        {
            QMessageBox::warning(this,tr("Error"),tr("Merging not possible."));
        }
        else
        {
            ExecutionNames sources=dialog.sourceList();
            int sz=sources.size();
            for (int i=0; i<sz; i++)
            {
                printStatus(tr("Deleting '%1'...").arg(sources.at(i)),static_cast<float>(i+1)/static_cast<float>(sz+1));
                if (!model_p->deleteExecution(sources.at(i)))
                {
                    if (QMessageBox::warning(this,tr("Error"),tr("Deleting '%1' not possible.").arg(sources.at(i)),
                                             QMessageBox::Abort, QMessageBox::Ignore)==QMessageBox::Abort)
                        break;
                }
            }
        }
        csmes_p->endUndoGroup();
    }
    printStatus("",-1);
}
コード例 #10
0
void ExecutionListView::refreshView()
{
    ExecutionListModel *model_p=_model();
    if (model_p)
        model_p->refresh();
}