Пример #1
0
 Chromosome::Chromosome(Parameters& p,unsigned short cId):chrom(){
   for(unsigned short i=0;i<p.getChromLoci(cId);++i){
     chrom.push_back(Locus(p,cId));
   }
   for(unsigned short i=0;i<p.getChromQtls(cId).size();++i){
     chrom.push_back(Locus(p,p.getChromQtls(cId)[i].a,p.getChromQtls(cId)[i].b));
   }
   for(unsigned long i=0;i<(unsigned long)(p.getChromSizes(cId)/p.getMarkerDist());++i){
     chrom.push_back(Locus(p,i,p.getMarkerDist()));
   }
   sort(chrom.begin(),chrom.end(),sortLociChrom());
 }
void ContractManager::saveState(FunctionIdentifier::Ptr func, PredicateState::Ptr state) {
    if (llvm::isa<BasicPredicateState>(state)) {
        contracts->at(func)->push_back(state);
    } else if (auto&& chain = llvm::dyn_cast<PredicateStateChain>(state)) {
        saveState(func, chain->getBase());
        saveState(func, chain->getCurr());
    } else if (auto&& stateTerm = stateToTerm(state)) {
        auto&& statePred = FN.Predicate->getEqualityPredicate(stateTerm, FN.Term->getTrueTerm(), Locus(), PredicateType::PATH);
        auto&& newState = FN.State->Basic({statePred});

        Z3::ExprFactory ef;
        Z3::Solver s(ef, func->memBounds().first, func->memBounds().second);
        auto res = s.isFullGroup(newState);

        if (res.isSat()) {
            contracts->at(func)->push_back(newState);
        }
    } else {
        errs() << "Unable to save state:" << state << endl;
    }
}
void ContractManager::printContracts() const {
    auto&& dbg = dbgs();

    dbg << "Contract extraction results" << endl;
    for (auto&& it : contracts->data()) {
        auto&& F = it.first;
        auto&& memBounds = F->memBounds();
        auto&& merger = MergingTransformer(FN, memBounds, F->calls());

        if (F->calls() < MIN_FUNCTION_CALLS) continue;

        //analyze each state
        for (auto&& st : *contracts->at(F)) {
            merger.transform(st);
        }

        //collect results
        auto&& mergedState = merger.getMergedState();
        if (not mergedState->isEmpty()) {

            if (auto&& contract = stateToTerm(mergedState)) {
                auto&& function = functionInfo[F].first;
                auto&& fm = functionInfo[F].second;
                auto&& contractPredicate = FN.Predicate->getEqualityPredicate(contract, FN.Term->getTrueTerm(), Locus(), PredicateType::REQUIRES);
                fm->update(function, FN.State->Basic({contractPredicate}));
            }

            dbg << "---" << "Function " << F->name() << "---" << endl;
            dbg << "State:" << endl;
            dbg << mergedState << endl;
            dbg << endl;
        }
    }

    dbg << end;
}
Пример #4
0
/**
 * Creates a locus from a splitted line that is taken from
 * a .info file.
 * 
 * @param splitted_line A line that has been splitted on ' '.
 *
 * @return The individual with all its doses that is represented
 *         by the line.
 */
static Locus
create_locus(const std::vector<std::string> &splitted_line)
{
    return Locus( splitted_line[ 0 ], splitted_line[ 1 ], splitted_line[ 2 ] );
}