/** * Obtem o tipo do argumento 'arg' presente na linha de comando. Esta funcao e' usada * para verificar se um argumento e' do tipo requerido por 'tag'. * @param tag identificador da tag procurada * @param arg argumento a ser obter o tipo * @return o tipo de argumento 'arg'. * @date 22/05/2002 */ PRIVATE PARAMTYPE param_arg_type (PCHAR tag, PCHAR arg) { PPARAMINFO info; // informacoes sobre o tag 'tag' PARAMTYPE type; // tipo do argumento 'arg' UINT i; // auxiliar // verifica se o argumento 'arg' e' um numero. se nao for e' string type = pt_int; for (i=0;arg[i];i++) { if (!isdigit (arg[i])) type = pt_str; } // como uma string tambem pode ser um caractere, verifica se o tag 'tag' // requer uma string ou um caractere e definido para 'arg' o tipo adequado if (assigned (tag)) { info = param_info (tag); if (assigned (info)) { if ((info->p_type == pt_char) && (strlen (arg) == 1)) type = pt_char; } } return type; }
forceinline ModEvent FloatVarImp::lq(Space& home, const FloatVal& n) { if (n.max() < dom.min()) return ME_FLOAT_FAILED; if ((n.max() >= dom.max()) || assigned()) return ME_FLOAT_NONE; FloatDelta d(n.max(),dom.max()); ModEvent me = ME_FLOAT_BND; dom = intersect(dom,FloatVal(dom.min(),n.max())); if (assigned()) me = ME_FLOAT_VAL; GECODE_ASSUME((me == ME_FLOAT_VAL) | (me == ME_FLOAT_BND)); return notify(home,me,d); }
forceinline ModEvent FloatVarImp::eq(Space& home, const FloatVal& n) { if (!overlap(dom,n)) return ME_FLOAT_FAILED; if (assigned() || subset(dom,n)) return ME_FLOAT_NONE; FloatDelta d; ModEvent me = ME_FLOAT_BND; dom = intersect(dom,n); if (assigned()) me = ME_FLOAT_VAL; GECODE_ASSUME((me == ME_FLOAT_VAL) | (me == ME_FLOAT_BND)); return notify(home,me,d); }
/* * Dependencies * */ forceinline void BoolVarImp::subscribe(Space& home, Propagator& p, PropCond, bool schedule) { // Subscription can be used with integer propagation conditions, // which must be remapped to the single Boolean propagation condition. BoolVarImpBase::subscribe(home,p,PC_BOOL_VAL,assigned(),schedule); }
ExecStatus Single<View>::advise(Space& home, Advisor& a0, const Delta& d) { Index& a(static_cast<Index&>(a0)); int i = a.i; // Check for gamma if ((beta <= gamma) && (i < gamma) && assigned(x[i],t)) gamma = i; if (x[i].assigned()) { a.dispose(home,c); if (c.empty()) return ES_NOFIX; } else if ((i < alpha) || (i > gamma)) { x[i].cancel(home,a); a.dispose(home,c); return (c.empty()) ? ES_NOFIX : ES_FIX; } if (beta > gamma) return ES_NOFIX; if ((alpha == i) || (beta == i)) { if (x[i].any(d) && !x[i].in(s)) return ES_NOFIX; if ((x[i].min(d) <= s) && (s <= x[i].max(d))) return ES_NOFIX; } return ES_FIX; }
inline ModEvent SetVarImp::intersectI(Space& home, I& iterator) { if (assigned()) { BndSetRanges lbi(glb); Iter::Ranges::Diff<BndSetRanges,I> probe(lbi,iterator); if (probe()) return ME_SET_FAILED; return ME_SET_NONE; } if (!iterator()) { if (cardMin() > 0) return ME_SET_FAILED; lub.card(0); SetDelta d(1, 0, lub.min(), lub.max()); lub.excludeAll(home); return notify(home, ME_SET_VAL, d); } int mi=iterator.min(); int ma=iterator.max(); ++iterator; if (iterator()) return intersectI_full(home, mi, ma, iterator); else return intersect(home, mi, ma); }
schedule_type min_min_impl(matrix<double> const& etc) { std::vector<bool> assigned(etc.rows(), false); schedule_type schedule(etc.rows(), etc.cols()); for (std::size_t i = 0; i < schedule.tasks(); ++i) { std::size_t min_task = 0, min_machine = 0; double min_time = std::numeric_limits<double>::max(); for (std::size_t t = 0; t < schedule.tasks(); ++t) { if (!assigned[t]) { for (std::size_t m = 0; m < schedule.machines(); ++m) { double ct = completion_time(schedule, etc, t, m); if (ct < min_time) { min_time = ct; min_task = t; min_machine = m; } } } } schedule.assign_task(min_task, min_machine); assigned[min_task] = true; } return schedule; }
void RegionGraph::calcCVMCountingNumbers() { // Calculates counting numbers of inner regions based upon counting numbers of outer regions vector<vector<size_t> > ancestors(nrIRs()); boost::dynamic_bitset<> assigned(nrIRs()); for( size_t beta = 0; beta < nrIRs(); beta++ ) { IR(beta).c() = 0.0; for( size_t beta2 = 0; beta2 < nrIRs(); beta2++ ) if( (beta2 != beta) && IR(beta2) >> IR(beta) ) ancestors[beta].push_back(beta2); } bool new_counting; do { new_counting = false; for( size_t beta = 0; beta < nrIRs(); beta++ ) { if( !assigned[beta] ) { bool has_unassigned_ancestor = false; for( vector<size_t>::const_iterator beta2 = ancestors[beta].begin(); (beta2 != ancestors[beta].end()) && !has_unassigned_ancestor; beta2++ ) if( !assigned[*beta2] ) has_unassigned_ancestor = true; if( !has_unassigned_ancestor ) { Real c = 1.0; foreach( const Neighbor &alpha, nbIR(beta) ) c -= OR(alpha).c(); for( vector<size_t>::const_iterator beta2 = ancestors[beta].begin(); beta2 != ancestors[beta].end(); beta2++ ) c -= IR(*beta2).c(); IR(beta).c() = c; assigned.set(beta, true); new_counting = true; } } }
inline ExecStatus Single<View>::post(Home home, ViewArray<View>& x, int s, int t) { { int alpha = 0; while ((alpha < x.size()) && !x[alpha].in(s)) GECODE_ME_CHECK(x[alpha++].nq(home,t)); x.drop_fst(alpha); if (x.size() == 0) return ES_OK; } // alpha has been normalized to 0 int beta = 0, gamma = 0; GECODE_ME_CHECK(x[0].nq(home,t)); do { gamma++; } while ((gamma < x.size()) && !assigned(x[gamma],t)); do { beta++; } while ((beta < x.size()) && !x[beta].in(s)); if (beta > gamma) { GECODE_ME_CHECK(x[0].eq(home, s)); return ES_OK; } if (gamma < x.size()) x.drop_lst(gamma); (void) new (home) Single<View>(home, x, s, t, beta, gamma); return ES_OK; }
ModEvent CPTupleVarImp::exclude(Space& home, const TupleSet& s) { if (s.disjoint(dom_)) return ME_CPTUPLE_NONE; dom_.differenceAssign(s); if (dom_.empty()) return ME_CPTUPLE_FAILED; CPTupleDelta d(1,2); return notify(home, assigned() ? ME_CPTUPLE_VAL : ME_CPTUPLE_DOM, d); }
int Variable::getCurrentVarId() { if (assigned()) return -1; if (wcsp->getNbNodes() > timestamp) wcsp->updateCurrentVarsId(); assert(pos>=0); assert(wcsp->getNbNodes() == timestamp); return pos; }
void AssignNameOverlay::setActive(bool active) { PersistentWidgetDelegateOverlay::setActive(active); if (active) { connect(assignNameWidget(), SIGNAL(assigned(TaggingAction,ImageInfo,QVariant)), this, SLOT(slotAssigned(TaggingAction,ImageInfo,QVariant))); connect(assignNameWidget(), SIGNAL(rejected(ImageInfo,QVariant)), this, SLOT(slotRejected(ImageInfo,QVariant))); connect(assignNameWidget(), SIGNAL(selected(TaggingAction,ImageInfo,QVariant)), this, SLOT(enterPersistentMode())); connect(assignNameWidget(), SIGNAL(assigned(TaggingAction,ImageInfo,QVariant)), this, SLOT(leavePersistentMode())); connect(assignNameWidget(), SIGNAL(rejected(ImageInfo,QVariant)), this, SLOT(leavePersistentMode())); connect(assignNameWidget(), SIGNAL(assigned(TaggingAction,ImageInfo,QVariant)), this, SLOT(storeFocus())); connect(assignNameWidget(), SIGNAL(rejected(ImageInfo,QVariant)), this, SLOT(storeFocus())); /* if (view()->model()) connect(view()->model(), SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(slotDataChanged(QModelIndex,QModelIndex))); */ } else { // widget is deleted /* if (view() && view()->model()) disconnect(view()->model(), 0, this, 0); */ } }
std::unique_ptr<MappedStmt> MappedStmt::fromMetadata(llvm::MDNode *RootMD, MappedModule const &Module) { if (RootMD->getNumOperands() != 4u) { llvm::errs() << "MappedStmt::fromMetadata(): " << "invalid number of operands.\n"; return nullptr; } // Get the type of the mapping. auto TypeMD = llvm::dyn_cast_or_null<llvm::MDString> (RootMD->getOperand(0u).get()); auto Type = getTypeFromMDString(TypeMD); if (!Type.assigned()) { llvm::errs() << "MappedStmt::fromMetadata(): " << "failed to get type.\n"; return nullptr; } // Find the clang::Stmt. auto StmtIdentMD = llvm::dyn_cast_or_null<llvm::MDNode> (RootMD->getOperand(1u).get()); if (!StmtIdentMD) { llvm::errs() << "MappedStmt::fromMetadata(): " << "Stmt identifier is not an MDNode.\n"; return nullptr; } auto ASTAndStmt = Module.getASTAndStmt(StmtIdentMD); assert(ASTAndStmt.first && ASTAndStmt.second); // Find the values. auto const MapVal1MD = RootMD->getOperand(2u).get(); auto const MapVal2MD = RootMD->getOperand(3u).get(); auto Val1 = seec::cm::getMappedValueFromMD(MapVal1MD, Module.getModuleIndex()); auto Val2 = seec::cm::getMappedValueFromMD(MapVal2MD, Module.getModuleIndex()); if (!Val1) { llvm::errs() << "MappedStmt::fromMetadata(): " << "llvm::Value not found.\n"; return nullptr; } return std::unique_ptr<MappedStmt>(new MappedStmt(Type.get<0>(), ASTAndStmt.first, ASTAndStmt.second, Val1, Val2)); }
bool KeyAssignWidget::event(QEvent *event) { QKeyEvent *keyEvent = 0; bool pressed(false); if (event->type() == QEvent::KeyPress) { keyEvent = (QKeyEvent *)event; pressed = true; } else if (event->type() == QEvent::KeyRelease) { keyEvent = (QKeyEvent *)event; pressed = false; } if (keyEvent) { int keyInt = keyEvent->key(); Qt::Key key = static_cast<Qt::Key>(keyInt); if(key == Qt::Key_unknown) { event->ignore(); return true; } if (key == Qt::Key_Control) m_ctrl = pressed; else if (key == Qt::Key_Alt) m_alt = pressed; else if (key == Qt::Key_Shift) m_shift = pressed; else if (key == Qt::Key_Meta) m_meta = pressed; else { m_key = pressed ? keyInt : -1; } event->accept(); bool final(false); QString res = makeText(final); setText(res); if (final) { m_sequence = QKeySequence(res); emit(assigned(m_sequence)); m_ctrl = false; m_alt = false; m_shift = false; m_meta = false; m_key = -1; } return true; } return QWidget::event(event); }
forceinline ModEvent FloatVarImp::eq(Space& home, FloatNum n) { if (!dom.in(n)) return ME_FLOAT_FAILED; if (assigned()) return ME_FLOAT_NONE; FloatDelta d; dom = n; return notify(home,ME_FLOAT_VAL,d); }
typename std::enable_if<!std::is_void<T>::value, bool>::type checkArgumentType(detect_calls::VarArgList<TraceThreadListener> const &Args, unsigned ArgIndex) const { if (ArgIndex < Args.size()) { typedef typename default_arg_promotion_of<T>::type PromotedT; auto MaybeArg = Args.getAs<PromotedT>(ArgIndex); return MaybeArg.assigned(); } return false; }
forceinline ModEvent FloatVarImp::gq(Space& home, FloatNum n) { if (n <= dom.min()) return ME_FLOAT_NONE; if (n > dom.max()) return ME_FLOAT_FAILED; FloatDelta d(dom.min(),n); ModEvent me = ME_FLOAT_BND; dom = intersect(dom,FloatVal(n,dom.max())); if (assigned()) me = ME_FLOAT_VAL; GECODE_ASSUME((me == ME_FLOAT_VAL) | (me == ME_FLOAT_BND)); return notify(home,me,d); }
forceinline ModEvent FloatVarImp::gq(Space* home,double n) { if (n <= lower(dom)) return ME_FLOAT_NONE; if (n > upper(dom)) return ME_FLOAT_FAILED; dom = boost::numeric::max(dom,Interval(n)); ModEvent me = ME_FLOAT_BND; if (assigned()) me = ME_FLOAT_VAL; FloatDelta d; return notify(home,me,&d); }
int main(void) { srand(time(NULL)); char prog; int seed, end=0; //Prompts the user to seed the program. printf("Enter seed value, either:\n\t>= 0 to randomize rand( ) with u"); printf("ser-input seed value\n\t< 0 to randomize rand( ) with system"); printf(" time\n"); scanf("%i", &seed); if(seed>=0) srand(seed); if(seed<0) srand(time(NULL)); do { ct1=ct2=ct3=ct4=ct5=0; printf("Do you want to use the assigned function, play poker or end program(A/P/E)?"); prog=getchar(); prog=getchar(); printf("\n"); if (prog=='A' || prog=='a') { for(ct1=0; ct1<52; ct1++) createDeck(); assigned(); } else if(prog=='p' || prog=='P') { poker(); } else if(prog=='e' || prog=='E') { for(ct2=0; ct2<100000; ct2++) //Smilies! printf("%2c", 1); end++; } //Prints after invalid inputs. else printf("Would you like to try that again.....\n\n"); }while(end==0); return 0; } // end main
PUBLIC BOOL param_asbool (PCHAR tag) { PPARAMINFO info; info = param_info (tag); if (assigned (info)) { if (param_tag_index (info->p_tag) != -1) return TRUE; else return info->p_default.u_bool; } return FALSE; }
RuntimeValue const * TraceThreadListener::getCurrentRuntimeValue(llvm::Instruction const *I) const { auto const ActiveFunc = ActiveFunction; if (!ActiveFunc) return nullptr; auto &FIndex = ActiveFunc->getFunctionIndex(); auto MaybeIndex = FIndex.getIndexOfInstruction(I); if (!MaybeIndex.assigned()) return nullptr; return ActiveFunc->getCurrentRuntimeValue(MaybeIndex.get<0>()); }
/** * Obtem as informacoes sobre o parametro especificado por 'tag'. * @date 22/05/2002 * @param tag identificador da tag procurada * @return informacoes sobre o parametro 'tag'. NULL se a 'tag' nao estiver definida. */ PRIVATE PPARAMINFO param_info (PCHAR tag) { UINT i; // verifica se 'tag' nao e' NULL if (assigned (tag)) { // procura 'tag' na lista de configuracao de parametros for (i=0;i < params.p_count;i++) { if (strcmp (tag,params.p_info[i].p_tag) == 0) return ¶ms.p_info[i]; } } return NULL; }
typename std::enable_if <std::is_pointer<T>::value && !std::is_void<typename std::remove_pointer<T>::type>::value, seec::Maybe<MemoryArea>>::type getArgumentPointee(detect_calls::VarArgList<TraceThreadListener> const &Args, unsigned ArgIndex) const { if (ArgIndex < Args.size()) { auto MaybeArg = Args.getAs<T>(ArgIndex); if (MaybeArg.assigned()) { auto const Ptr = MaybeArg.template get<0>(); return MemoryArea(Ptr, sizeof(*Ptr)); } } return seec::Maybe<MemoryArea>(); }
inline ModEvent SetVarImp::excludeI(Space& home, I& iterator) { if (!iterator()) return ME_SET_NONE; if (assigned()) { BndSetRanges ubi(lub); Iter::Ranges::Inter<BndSetRanges,I> probe(ubi,iterator); return probe() ? ME_SET_FAILED : ME_SET_NONE; } int mi=iterator.min(); int ma=iterator.max(); ++iterator; if (iterator()) return excludeI_full(home, mi, ma, iterator); else return exclude(home, mi, ma); }
wxTipWindow *makeDeclTooltip(wxWindow *Parent, OpenTrace &Trace, clang::Decl const * const Decl, wxCoord MaxLength, wxRect &RectBound) { wxString TipString; bool SuppressEPV = false; auto &Annotations = Trace.getAnnotations(); auto const MaybeAnno = Annotations.getPointForNode(Trace.getTrace(), Decl); if (MaybeAnno.assigned<AnnotationPoint>()) { auto const &Point = MaybeAnno.get<AnnotationPoint>(); auto const Text = Point.getText(); if (!Text.empty()) { if (!TipString.empty()) TipString << "\n"; TipString << Text << "\n"; } if (Point.hasSuppressEPV()) SuppressEPV = true; } if (!SuppressEPV) { auto const &Augmentations = wxGetApp().getAugmentations(); auto Augmenter = Augmentations.getCallbackFn(); auto const MaybeExplanation = seec::clang_epv::explain(Decl, Augmenter); if (MaybeExplanation.assigned(0)) { auto const &Explanation = MaybeExplanation.get<0>(); if (!TipString.empty()) TipString << "\n"; TipString << seec::towxString(Explanation->getString()) << "\n"; } } TipString.Trim(); if (TipString.size()) return new wxTipWindow(Parent, TipString, MaxLength, nullptr, &RectBound); return nullptr; }
// liveIn(bb) = usedBeforeAssigned(bb) U (liveOut(bb) - assigned(bb)) void Function::buildLiveSetsPreSSA(BasicBlock *bb, const int seq) { Function *f = bb->getFunction(); BitSet usedBeforeAssigned(allLValues.getSize(), true); BitSet assigned(allLValues.getSize(), true); bb->liveSet.allocate(allLValues.getSize(), false); int n = 0; for (Graph::EdgeIterator ei = bb->cfg.outgoing(); !ei.end(); ei.next()) { BasicBlock *out = BasicBlock::get(ei.getNode()); if (out == bb) continue; if (out->cfg.visit(seq)) buildLiveSetsPreSSA(out, seq); if (!n++) bb->liveSet = out->liveSet; else bb->liveSet |= out->liveSet; } if (!n && !bb->liveSet.marker) bb->liveSet.fill(0); bb->liveSet.marker = true; for (Instruction *i = bb->getEntry(); i; i = i->next) { for (int s = 0; i->srcExists(s); ++s) if (i->getSrc(s)->asLValue() && !assigned.test(i->getSrc(s)->id)) usedBeforeAssigned.set(i->getSrc(s)->id); for (int d = 0; i->defExists(d); ++d) assigned.set(i->getDef(d)->id); } if (bb == BasicBlock::get(f->cfgExit)) { for (std::deque<ValueRef>::iterator it = f->outs.begin(); it != f->outs.end(); ++it) { if (!assigned.test(it->get()->id)) usedBeforeAssigned.set(it->get()->id); } } bb->liveSet.andNot(assigned); bb->liveSet |= usedBeforeAssigned; }
template<class I> forceinline ModEvent SetVarImp::includeI(Space& home, I& iterator) { if (!iterator()) { return ME_SET_NONE; } if (assigned()) { BndSetRanges lbi(glb); Iter::Ranges::Diff<I,BndSetRanges> probe(iterator,lbi); return probe() ? ME_SET_FAILED : ME_SET_NONE; } int mi=iterator.min(); int ma=iterator.max(); ++iterator; if (iterator()) return includeI_full(home, mi, ma, iterator); else return include(home, mi, ma); }
DLVHEX_NAMESPACE_BEGIN #define DBGLOGD(X,Y) DBGLOG(X,Y) //#define DBGLOGD(X,Y) do{}while(false); // ---------- Class CDNLSolver ---------- bool CDNLSolver::unitPropagation(Nogood& violatedNogood) { DBGLOG(DBG, "Unit propagation starts"); int nogoodNr; while (unitNogoods.size() > 0) { nogoodNr = *(unitNogoods.begin()); const Nogood& nextUnitNogood = nogoodset.getNogood(nogoodNr); unitNogoods.erase(unitNogoods.begin()); // find propagation DL int propDL = 0; BOOST_FOREACH (ID lit, nextUnitNogood) { if (assigned(lit.address) && decisionlevel[lit.address] > propDL) { propDL = decisionlevel[lit.address]; } } // as the nogood is unit, it has a single watched literal // its negation is the propagated one ID propagatedLit = negation(*(watchedLiteralsOfNogood[nogoodNr].begin())); setFact(propagatedLit, propDL, nogoodNr); } if (contradictoryNogoods.size() > 0) { violatedNogood = nogoodset.getNogood(*(contradictoryNogoods.begin())); DBGLOG(DBG, "Unit propagation finished with detected contradiction " << violatedNogood); return false; } DBGLOG(DBG, "Unit propagation finished successfully"); return true; }
/// \brief Quicksort. /// /// \return true iff sorting should continue (no errors occurred). /// bool quicksort(std::size_t Left, std::size_t Right) { if (Left >= Right) return true; // Divide using naive "halfway" partition. auto const MaybePivotIndex = partition(Left, Right, Left + ((Right - Left) / 2)); if (!MaybePivotIndex.assigned()) return false; auto const PivotIndex = MaybePivotIndex.get<std::size_t>(); // Recursively sort the left side (if there is one). if (PivotIndex != 0 && !quicksort(Left, PivotIndex - 1)) return false; // Sort the right area. return quicksort(PivotIndex + 1, Right); }
PRIVATE UINT param_tag_args (PCHAR tag) { PPARAMINFO info; // informacoes sobre 'tag' UINT count; // no. de argumentos de 'tag' INT idx; // indice de 'tag' na linha de comando count = 0; idx = param_tag_index (tag); if (idx >= 0) { info = param_info (tag); if (assigned (info)) { if ((info->p_type != pt_bool) && (++idx < params.p_argc)) { if (params.p_argv[idx][0] != '-') { if (param_arg_type (tag,params.p_argv[idx]) == info->p_type) count++; } } } } return count; }