/* Run interpreter on a test */ bool Test::run() { ppc::Interpreter::State state; memset(&state, 0, sizeof(state)); state.cia = 0; state.nia = state.cia + 4; state.reg.lr = m_codeSize; if (!checkConditions(state, m_preconditions)) { return false; } while (state.cia < m_codeSize) { ppc::Instruction instr; instr.value = Memory::read<uint32_t>(reinterpret_cast<uint64_t>(m_code + state.cia)); ppc::Interpreter::decode(&state, instr); state.cia = state.nia; state.nia = state.cia + 4; } if (!checkConditions(state, m_postconditions)) { return false; } return true; }
QWatermark::QWatermark(QWidget *parent) : QMainWindow(parent) { setupUi(this); QCompleter *completer = new QCompleter(this); FSModel *fsModel = new FSModel(completer); fsModel->setRootPath(""); completer->setModel(fsModel); profileComboBox->addItems(Profile::getProfiles()); QSettings s; s.beginGroup("MainWindow"); restoreGeometry(s.value("geometry").toByteArray()); restoreState(s.value("windowState").toByteArray()); sourceLineEdit->setText(s.value("sourcePath").toString()); destinationLineEdit->setText(s.value("destinationPath").toString()); previewZoomSpinBox->setValue(s.value("zoom", 30).toInt()); treeCheckBox->setChecked(s.value("treeIteration", false).toBool()); int ix = profileComboBox->findText(s.value("profile", tr("Default")).toString()); if (ix > -1) profileComboBox->setCurrentIndex(ix); QAbstractButton *b = buttonGroup->button(s.value("buttonGroup", 0).toInt()); if (!b) b = ULRadioButton; b->setChecked(true); s.endGroup(); sourceLineEdit->setCompleter(completer); destinationLineEdit->setCompleter(completer); connect(sourcePushButton,SIGNAL(clicked()),this,SLOT(selectSourceFolder(void))); connect(destinationPushButton,SIGNAL(clicked()),this,SLOT(selectDestinationFolder(void))); connect(startButton,SIGNAL(clicked()),this,SLOT(doWatermark(void))); connect(actionAbout, SIGNAL(triggered()), this, SLOT(about(void))); connect(actionAbout_Qt, SIGNAL(triggered()), qApp, SLOT(aboutQt())); connect(sourceLineEdit, SIGNAL(textEdited(QString)), this, SLOT(checkConditions())); connect(destinationLineEdit, SIGNAL(textEdited(QString)), this, SLOT(checkConditions())); connect(buttonGroup, SIGNAL(buttonClicked(int)), this, SLOT(preview())); connect(profileComboBox, SIGNAL(currentIndexChanged(int)), this, SLOT(preview())); connect(previewZoomSpinBox, SIGNAL(valueChanged(int)), this, SLOT(preview())); connect(editProfileButton, SIGNAL(clicked()), this, SLOT(editProfileButton_clicked())); checkConditions(); preview(); }
bool LabEngine::doActionRuleSub(int16 action, int16 roomNum, const CloseData *closePtr, bool allowDefaults) { action++; if (closePtr) { RuleList *rules = &(_rooms[_roomNum]._rules); if (rules->empty() && (roomNum == 0)) { _resource->readViews(roomNum); rules = &(_rooms[roomNum]._rules); } for (RuleList::iterator rule = rules->begin(); rule != rules->end(); ++rule) { if ((rule->_ruleType == kRuleTypeAction) && ((rule->_param1 == action) || ((rule->_param1 == 0) && allowDefaults))) { if (((rule->_param2 == closePtr->_closeUpType) || ((rule->_param2 == 0) && allowDefaults)) || ((action == 1) && (rule->_param2 == -closePtr->_closeUpType))) { if (checkConditions(rule->_condition)) { doActions(rule->_actionList); return true; } } } } } return false; }
unsigned YKEventPend(YKEVENT *event, unsigned eventMask, int waitMode){ int conditionMet = 0; int i; unsigned flags; TCBptr temp, temp2, iter; YKEnterMutex(); // ------- Test if Conditions are met --------// conditionMet = checkConditions(event->flags, eventMask, waitMode); // -------- If condition met, return. Else, block --------// if (conditionMet){ flags = event->flags; YKExitMutex(); return flags; } else{ // Remove calling task's TCB from ready list temp = YKRdyList; // Hold the first ready task // Remove it from Ready list YKRdyList = temp->next; if (YKRdyList != NULL) YKRdyList->prev = NULL; // modify TCB, put in suspended list temp->state = BLOCKED; temp->flags = eventMask; temp->waitMode = waitMode; // Put task at event's blocked list if (event->waitingOn == NULL){ event->waitingOn = temp; temp->next = NULL; temp->prev = NULL; } else{ iter = event->waitingOn; temp2 = NULL; while (iter != NULL && iter->priority < temp->priority){ temp2 = iter; iter = iter->next; } if (iter == NULL){//At end temp2->next = temp; temp->prev = temp; temp->next = NULL; } else{ // insert before iterator temp->next = iter; temp->prev = temp2; iter->prev = temp; if (temp2 == NULL)//inserted at beginning of list event->waitingOn = temp; else temp2->next = temp; } } YKScheduler(ContextNotSaved); flags = event->flags; YKExitMutex(); } return flags; }
void YKEventSet(YKEVENT *event, unsigned eventMask){ int i; int taskMadeReady = 0; TCBptr iter, temp, temp2, next; unsigned flags; YKEnterMutex(); // ----- Set Flag Group ---- // for (i = 0; i < 16; i++){ if (eventMask & BIT(i)){ event->flags |= BIT(i); } } flags = event->flags; // ----- check Conditions ---- // iter = event->waitingOn; while (iter != NULL){ // if conditions are met for that task, put in ready list if (checkConditions(flags, iter->flags, iter->waitMode)){ // remove from pending list next = iter->next; // check if the task to remove is the head if (iter == event->waitingOn){ event->waitingOn = iter->next; } if (iter->prev != NULL) iter->prev->next = iter->next; if (iter->next != NULL) iter->next->prev = iter->prev; // modify TCB of that task, place in ready list iter->state = READY; // Put in Rdy List temp2 = YKRdyList; while (temp2->priority < iter->priority){ temp2 = temp2->next; } if (temp2->prev == NULL){ YKRdyList = iter; } else{ temp2->prev->next = iter; } iter->prev = temp2->prev; iter->next = temp2; temp2->prev = iter; taskMadeReady = 1; iter = next; } else { iter = iter->next; } } // call scheduler if not called from ISR and a task was made ready if (taskMadeReady && nestingLevel == 0) YKScheduler(ContextNotSaved); YKExitMutex(); }
void Behavior::start() { if (!checkConditions()) { endWithFailure(); return; } result = AiMap::RUNNING; if (interface != NULL) interface->start(agent); }
//Select destination folder for images (similar to source) void QWatermark::selectDestinationFolder(void) { QString destinationDirectoryName = QFileDialog::getExistingDirectory(this, tr("Open Destination Directory"), destinationLineEdit->text(), QFileDialog::ShowDirsOnly); if (destinationDirectoryName.isNull()) return; destinationLineEdit->setText(destinationDirectoryName); checkConditions(); }
bool LabEngine::doMainView() { RuleList &rules = _rooms[_roomNum]._rules; for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) { if (rule->_ruleType == kRuleTypeGoMainView) { if (checkConditions(rule->_condition)) { doActions(rule->_actionList); return true; } } } return false; }
bool LabEngine::doGoForward() { RuleList &rules = _rooms[_roomNum]._rules; for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) { if ((rule->_ruleType == kRuleTypeGoForward) && (rule->_param1 == (_direction + 1))) { if (checkConditions(rule->_condition)) { doActions(rule->_actionList); return true; } } } return false; }
ViewData *LabEngine::getViewData(uint16 roomNum, uint16 direction) { if (_rooms[roomNum]._roomMsg.empty()) _resource->readViews(roomNum); ViewDataList &views = _rooms[roomNum]._view[direction]; ViewDataList::iterator view; for (view = views.begin(); view != views.end(); ++view) { if (checkConditions(view->_condition)) return &(*view); } error("No view with matching condition found"); }
//Select source folder for images void QWatermark::selectSourceFolder(void) { //Create a dialog to select a folder QString sourceDirectoryName = QFileDialog::getExistingDirectory(this, tr("Open Source Directory"), sourceLineEdit->text(), QFileDialog::ShowDirsOnly); if (sourceDirectoryName.isNull()) return; //Assign of the selected folder to the line edit sourceLineEdit->setText(sourceDirectoryName); checkConditions(); }
void CompositeBehavior::doAction(bool directlyExecuted) { if (agent->isDead() || agent->isIncapacitated() || (agent->getZone() == NULL)) { agent->setFollowObject(NULL); return; } if (!started()) this->start(); else if (!checkConditions()) endWithFailure(); if (finished()) { Behavior::doAction(directlyExecuted); return; } Behavior* currentChild; do { currentChild = children.get(currentPos); if (currentChild == NULL) { agent->error("NULL child or empty children list in CompositeBehavior"); endWithError(); Behavior::doAction(directlyExecuted); return; } if (!currentChild->started()) currentChild->start(); else if (!currentChild->checkConditions()) // if this isn't here, I can get a single recursion where the child will call the parent's (this) doAction() endWithFailure(); if (!currentChild->finished()) currentChild->doAction(); if (currentChild->finished()) { if (currentChild->succeeded()) this->childSucceeded(); else if (currentChild->failed()) this->childFailed(); currentChild->end(); } } while (currentChild != NULL && currentChild->finished() && !this->finished() && currentPos < children.size()); if (currentChild->finished()) Behavior::doAction(directlyExecuted); }
// ----------------------------------------------------------------- // Name : pickDialog // ----------------------------------------------------------------- JoS_Element& AI::pickDialog(JoS_Element& listItems) { list<int> lstAcceptableIdx; for (int itemIdx = 0; itemIdx < listItems.size(); itemIdx++) { const JoS_Element& item = listItems[itemIdx]; if (checkConditions(item["condState"])) { // This item is acceptable lstAcceptableIdx.push_back(itemIdx); } } if (!lstAcceptableIdx.empty()) { int rnd = rand() % lstAcceptableIdx.size(); list<int>::iterator it = lstAcceptableIdx.begin(); for (; rnd > 0; it++, rnd--); return listItems[*it]; } return JoS_Null::JoSNull; }
bool LabEngine::doTurn(uint16 from, uint16 to) { from++; to++; RuleList &rules = _rooms[_roomNum]._rules; for (RuleList::iterator rule = rules.begin(); rule != rules.end(); ++rule) { if ((rule->_ruleType == kRuleTypeTurn) || ((rule->_ruleType == kRuleTypeTurnFromTo) && (rule->_param1 == from) && (rule->_param2 == to))) { if (checkConditions(rule->_condition)) { doActions(rule->_actionList); return true; } } } return false; }
void GameMission::advanceTime(int deltamsec) { checkConditions(); }
bool PlotPort::isReady() const { if (isOutport()) return isConnected(); else return (hasData() && checkConditions()); }
bool VolumePort::isReady() const { if (isOutport()) return isConnected(); else return (hasData() && /*getData()->getRepresentation<VolumeRAM>() &&*/ checkConditions()); }
void MigrationFrontDown::seeAt(Carbon *carbon) { if (checkConditions(carbon)) return; _crystal->posMigrDownFrontIter(carbon, std::ref(*this)); }