void CodeGen::assignment(Location receiver, realSlotRef* path, Location val, bool isMem) { // <move arg, t> // <loadPath rr, path, receiver> // store receiver/rr, offset - Mem_Tag, arg/t // <check_store> a.Comment("Begin Assignment"); Location t; if (isRegister(val) && val != CReceiverReg) { t = val; } else { t = Temp1; move(t, val); // load argument } assert(t != Temp2, "register conflict"); int32 offset = smiOop(path->desc->data)->byte_count() - Mem_Tag; if (path->holder->is_object_or_map()) { Location t1 = loadPath(CReceiverReg, path->holder, receiver, Temp1); a.StoreI(t1, offset, t); // store object data slot contents if (isMem) { a.AddI(t1, offset, Temp1); // compute store address recordStore(Temp1); } } else { fatal("don't support vframe lookups yet"); } a.Comment("End Assignment"); }
bool CharacterService::loadAllCharacters() { UNIQUE_LOCK(mMutex); fs::path loadPath("data/characters"); fs::directory_iterator endIt; if (!fs::exists(loadPath) || !fs::is_directory(loadPath)) return false; for (fs::directory_iterator dirIt(loadPath); dirIt != endIt; ++dirIt) { fs::path filePath = *dirIt; if (fs::is_regular_file(filePath)) { if (filePath.extension().string() == ".json") { try { Json::Value characterJson = RS->readJsonFile(filePath.string()); std::shared_ptr<Character> character = std::make_shared<Character>(); Json::deserialize(characterJson, character); if (mCharacters[character->id()]) { std::cerr << "Duplicated character id " << character->id() << std::endl; std::cerr << "Ignored"; continue; } mCharacters[character->id()] = character; } catch (const SerializationException &e) { std::cerr << "Loading " << filePath.string() << " failed" << std::endl; std::cerr << e.what(); } } } } return true; }
bool LevelService::loadAllLevels() { boost::unique_lock<boost::mutex> lock(mMutex); fs::path loadPath("data/levels"); fs::directory_iterator endIt; if (!fs::exists(loadPath) || !fs::is_directory(loadPath)) return false; for (fs::directory_iterator dirIt(loadPath); dirIt != endIt; ++dirIt) { fs::path dirPath = *dirIt; if (fs::is_directory(dirPath)) { std::string levelId = dirPath.filename().string(); fs::path levelFilePath = dirPath / (levelId + ".level"); if (fs::exists(levelFilePath) && fs::is_regular_file(levelFilePath)) { try { loadLevelNoLock(levelId, true); } catch (const SerializationException &e) { std::cerr << "Loading " << levelId << " failed\n"; std::cerr << e.what() << std::endl; } } } } for (auto &idLevelPair : mLevels) { idLevelPair.second->resolveRoomExits(); } return true; }
int WINAPI WinMain(HINSTANCE, HINSTANCE, char* commandLine, int) { CPsfVm virtualMachine; #ifdef DEBUGGER_INCLUDED { if(strlen(commandLine) == 0) { MessageBox(NULL, _T("Please provide a PSF file path as a command line argument."), NULL, 16); return 1; } virtualMachine.Reset(); filesystem::path loadPath(commandLine); CPsfLoader::LoadPsf(virtualMachine, loadPath.native(), filesystem::path()); std::string tagPackageName = loadPath.leaf().string().c_str(); virtualMachine.LoadDebugTags(tagPackageName.c_str()); CMiniDebugger debugger(virtualMachine, virtualMachine.GetDebugInfo()); debugger.Show(SW_SHOW); debugger.Run(); virtualMachine.SaveDebugTags(tagPackageName.c_str()); } #else { CMainWindow window(virtualMachine); window.Center(); window.Show(SW_SHOW); window.Run(); } #endif return 0; }
void CodeGen::assignment(Location receiver, realSlotRef* path, Location val, bool isMem) { a.Comment("Begin Assignment"); // called from assignmentCode; real assignment method int32 offset = smiOop(path->desc->data)->byte_count() - Mem_Tag; if (path->holder->is_object_or_map()) { Location tmp = val == Temp1 ? Temp2 : Temp1; bool yipes = tmp == receiver; if (yipes) a.pushl(val); Location tr = loadPath(tmp, path->holder, receiver, tmp); a.leal(tr, offset, NumberOperand, tr); Location r; int32 d; OperandType t; Location other_temp = tr == Temp1 ? Temp2 : Temp1; if (yipes) a.popl(other_temp); else if (val != other_temp) { reg_disp_type_of_loc(&r, &d, &t, val); a.movl(r, d, t, other_temp); } a.movl(other_temp, tr, 0, NumberOperand); if (isMem) { recordStore(tr); } } else { fatal("don't support vframe lookups yet"); } a.Comment("End Assignment"); }
void NodeGen::pathLookup(realSlotRef* path, PReg* receiver, PReg* dest) { if (path->holder->is_object_or_map()) { PReg* base = loadPath(path->holder, receiver, dest); fint offset = smiOop(path->desc->data)->byte_count() - Mem_Tag; APPEND(new LoadOffsetNode(base, offset, dest)); } else { fatal("don't support vframe lookups"); } }
void KnotsDirectory::browseByPath( QString &pathToLoad ) { _basePath = pathToLoad; _currentPage = 0; _totalPages = 1; beginRemoveRows(createIndex(0,0), 0, _items.count()); qDeleteAll(_items.begin(), _items.end()); _items.clear(); endRemoveRows(); reset(); loadPath( _basePath ); }
void NodeGen::pathAssign(PReg* rcvr, realSlotRef* path, PReg* val, bool checkStore) { COMMENT("Begin slot assignment"); int32 offset = smiOop(path->desc->data)->byte_count() - Mem_Tag; if (path->holder->is_object_or_map()) { PReg* t = new TempPReg(currentScope()); t = loadPath(path->holder, rcvr, t); APPEND(new StoreOffsetNode(val, t, offset, checkStore)); } else { fatal("don't support vframe lookups"); } }
MainWindow::MainWindow() { QWidget *w = new QWidget( this ); d_canvas[0] = new Canvas( Canvas::Svg, this ); d_canvas[0]->setAutoFillBackground( true ); d_canvas[0]->setPalette( Qt::gray ); d_canvas[1] = new Canvas( Canvas::VectorGraphic, this ); d_canvas[1]->setAutoFillBackground( true ); d_canvas[1]->setPalette( Qt::gray ); QVBoxLayout *vBox1 = new QVBoxLayout(); vBox1->setContentsMargins( 0, 0, 0, 0 ); vBox1->setSpacing( 5 ); vBox1->addWidget( new QLabel( "SVG" ), 0, Qt::AlignCenter ); vBox1->addWidget( d_canvas[0], 10 ); QVBoxLayout *vBox2 = new QVBoxLayout(); vBox2->setContentsMargins( 0, 0, 0, 0 ); vBox2->setSpacing( 5 ); vBox2->addWidget( new QLabel( "Vector Graphic" ), 0, Qt::AlignCenter ); vBox2->addWidget( d_canvas[1], 10 ); QHBoxLayout *layout = new QHBoxLayout( w ); layout->addLayout( vBox1 ); layout->addLayout( vBox2 ); setCentralWidget( w ); QToolBar *toolBar = new QToolBar( this ); QToolButton *btnLoad = new QToolButton( toolBar ); btnLoad->setText( "Load SVG" ); btnLoad->setToolButtonStyle( Qt::ToolButtonTextUnderIcon ); toolBar->addWidget( btnLoad ); addToolBar( toolBar ); connect( btnLoad, SIGNAL( clicked() ), this, SLOT( loadSVG() ) ); #if 0 QPainterPath path; path.addRect( QRectF( 1.0, 1.0, 2.0, 2.0 ) ); loadPath( path ); #endif };
void CodeGen::lookup(Location dest, realSlotRef* path, Location receiver) { a.Comment("lookup"); // <loadPath dest, path, receiver> // load receiver/dest/t, offset - Mem_Tag, dest/t // <move t, dest> // Since called from CodeGen::loadPath, cannot clobber Temp2 assert(isRegister(dest), "is always a register"); if (path->holder->is_object_or_map()) { Location t1 = loadPath(dest, path->holder, receiver, Temp1); // load data slot a.movl( t1, smiOop(path->desc->data)->byte_count() - Mem_Tag, NumberOperand, dest); } else { fatal("don't support vframe lookups"); } }
bool KeyframeMapper::loadKeyframesSrvCallback( Load::Request& request, Load::Response& response) { std::string filepath = request.filename; ROS_INFO("Loading keyframes..."); std::string filepath_keyframes = filepath + "/keyframes/"; bool result_kf = loadKeyframes(keyframes_, filepath_keyframes); if (result_kf) ROS_INFO("Keyframes loaded successfully"); else ROS_ERROR("Keyframe loading failed!"); ROS_INFO("Loading path..."); bool result_path = loadPath(filepath); if (result_path) ROS_INFO("Path loaded successfully"); else ROS_ERROR("Path loading failed!"); return result_kf && result_path; }
void QgsSvgSelectorLoader::run() { mCanceled = false; mQueuedSvgs.clear(); mTraversedPaths.clear(); // start with a small initial timeout (ms) mTimerThreshold = 10; mTimer.start(); loadPath( mPath ); if ( !mQueuedSvgs.isEmpty() ) { // make sure we notify model of any remaining queued svgs (ie svgs added since last foundSvgs() signal was emitted) emit foundSvgs( mQueuedSvgs ); } mQueuedSvgs.clear(); }
void CodeGen::lookup(Location dest, realSlotRef* path, Location receiver) { // <loadPath dest, path, receiver> // load receiver/dest/t, offset - Mem_Tag, dest/t // <move t, dest> Location t; if (isRegister(dest)) { t = dest; } else { t = Temp1; } if (path->holder->is_object_or_map()) { Location t1 = loadPath(t, path->holder, receiver, Temp1); a.LoadI(t1, smiOop(path->desc->data)->byte_count() - Mem_Tag, t); // load data slot } else { fatal("don't support vframe lookups"); } move(dest, t); }
void MWBotWin::checkPolice() { QWebElement elm = frm->findFirstElement("a.bubble span.text"); if (elm.toPlainText().contains(trUtf8("Задержан за бои"))) { loadPath(QStringList() << "square" << "police"); getFastRes(); if (!opt.police.fine || (info.ore < 5)) { if (state.botWork) start(); log(trUtf8("Вы задержаны. Бот остановлен")); } else { clickElement("form#fine-form div.button div.c"); log(trUtf8("Заплачен штраф в полиции")); } if (opt.police.relations && (info.ore > 20)) { elm = frm->findFirstElement("form.police-relations div.button div.c"); if (!elm.isNull()) { clickElement("form.police-relations div.button div.c"); log(trUtf8("Связи в полиции продлены")); } } } }
void QgsSvgSelectorLoader::loadPath( const QString &path ) { if ( mCanceled ) return; // QgsDebugMsg( QString( "loading path: %1" ).arg( path ) ); if ( path.isEmpty() ) { QStringList svgPaths = QgsApplication::svgPaths(); Q_FOREACH ( const QString &svgPath, svgPaths ) { if ( mCanceled ) return; if ( !svgPath.isEmpty() ) { loadPath( svgPath ); } } }
void KnotsDirectory::onDirectoryFetchFinished( QNetworkReply* reply ) { if( reply == _currentDownload ) { // qWarning() << "Fetched from " << reply->url() ; // qWarning() << "Read " << reply->bytesAvailable() << " Bytes"; // qWarning() << reply->peek( 4096 ); _xmlReader->parse(_xmlSource ); _currentDownload->deleteLater(); emit directoryChanged(); QUrl request( _basePath ); if( ++_currentPage < _totalPages ) { request.addQueryItem("page", QString::number(_currentPage )); loadPath( request ); } } }
void CodeGen::prologue(bool isAccessMethod, fint nargs) { /* ; make stack enter 1-last_extra_offset*4, $0 // make space for current_pc nmethod_frame_chain */ // *if not DI child // <smi/float/memOop prologue> // _verified: (entry point from PICs) // if necessary <check selector> // if necessary <check delegatee> // *endif DI // _diCheck: (entry point after recompile) // <verify assignable parents> // *if using recompilation // <checkRecompilation> // *endif // *if haveStackFrame // save sp, -frameSize*oopSize, sp // *endif // <clear stack temporaries and excess argument locations // CAUTION: use only Temp1/4 for temps in prologue; other temps // may contain lookup parameters. a.Comment("prologue"); fint assignableParents = L->adeps->length(); MethodKind kind = isAccessMethod ? MethodKind(-1) : theCompiler->method()->kind(); _incoming_arg_count = nargs; // for eventual putting into nmethod if (diLink == 0) { if (!L->isReceiverStatic()) { // test receiver map # if GENERATE_DEBUGGING_AIDS if (CheckAssertions) switch (L->lookupType()) { case NormalLookupType: break; case StaticNormalLookupType: case ImplicitSelfLookupType: case ResendLookupType: case DirectedResendLookupType: fatal("shouldn't miss"); break; default: break; } # endif Map* m = L->receiverMap(); bool imm = m == Memory->smi_map || m == Memory->float_map; if (m == Memory->smi_map) { smiOop_prologue(); } else if (m == Memory->float_map) { floatOop_prologue(); } else { memOop_prologue(); } } verifiedOffset = a.offset(); Label generalMiss(a.printing, NULL); a.Comment("verified entry point:"); if (L->isPerform()) { a.Comment("check selector"); checkOop(generalMiss, L->selector(), PerformSelectorLoc); } if (needsDelegatee(L->lookupType()) && !L->isDelegateeStatic()) { a.Comment("check delegatee"); checkOop(generalMiss, L->delegatee(), PerformDelegateeLoc); } } else { // don't check receiver map, selector, delegatee if a DI cache miss assert(assignableParents > 0, "should have some di parents to check"); } diCheckOffset = a.offset(); a.Comment("DI entry point:"); if (assignableParents > 0) { a.Comment("verify state of assignable parents"); fint count = 0; for (fint i = 0; i < assignableParents; i ++) { objectLookupTarget* target = L->adeps->start()[i]; Location t = loadPath(Temp2, target, LReceiverReg, Temp1); count = verifyParents(target, t, count); } } bool recomp = needRecompileCode(theCompiler->level()); if (recomp) checkRecompilation(); if (!haveStackFrame) { prologueAddr = NULL; } else { a.Comment("make stack frame (next instruction will be backpatched)"); a.enter(-0 * oopSize); // will be backpatched for locals prologueAddr = a.addr(); // will be used to patch enter with right frame size frameCreationOffset = a.offset(); // used by nmethod to find save instr, must have frame by this point XXXintel really? callPatchAddr = a.addr(); a.nop(); a.nop(); a.nop(); a.nop(); a.nop(); endCallPatchAddr = a.addr(); } if (GenerateCountCode) { int32* counter; if (assignableParents != 0) { counter = &NumberOfDIMethodCalls; } else if (isAccessMethod) { counter = &NumberOfAccessMethodCalls; } else if (kind == BlockMethodType) { counter = &NumberOfBlockMethodCalls; } else { counter = &NumberOfMethodCalls; } genCountCode(counter); } if (!isAccessMethod) { if (!recomp && GenerateLRUCode) { // this code is rarely generated in practice (recomp is usually true) a.Comment("reset unused bit"); void* unused_addr = &LRUflag[Memory->code->nextNMethodID()]; a.movl(0, NumberOperand, no_reg, int32(unused_addr), VMAddressOperand); } // don't keep uplevel-accessed names in regs // (for now, just flush everything) assert(haveStackFrame, "just checking"); } else { assert(!haveStackFrame, "just checking"); } a.Comment("End Prologue"); }
void ImportModelDialog::loadModel() { modelPath = loadPath(); ui.modelPath->setText(modelPath.c_str()); }
void Level::loadStage() { TiXmlDocument doc(folder + LIBGENS_LEVEL_DATA_STAGE); if (!doc.LoadFile()) { return; } TiXmlHandle hDoc(&doc); TiXmlElement* pElem; TiXmlHandle hRoot(0); pElem=hDoc.FirstChildElement().Element(); if (!pElem) { return; } pElem=pElem->FirstChildElement(); for(pElem; pElem; pElem=pElem->NextSiblingElement()) { string element_name=pElem->ValueStr(); if (element_name == LIBGENS_LEVEL_XML_SONIC) { loadSpawn(pElem); } if (element_name == LIBGENS_LEVEL_XML_PATH) { loadPath(pElem); } if (element_name == LIBGENS_LEVEL_XML_SET_DATA) { TiXmlElement* pElem_i=pElem->FirstChildElement(); for(pElem_i; pElem_i; pElem_i=pElem_i->NextSiblingElement()) { if (pElem_i->ValueStr()==LIBGENS_LEVEL_XML_LAYER) { LevelSetEntry *level_set_entry = new LevelSetEntry(); TiXmlElement* pElem_l=pElem_i->FirstChildElement(); for(pElem_l; pElem_l; pElem_l=pElem_l->NextSiblingElement()) { char *text_ptr=(char *) pElem_l->GetText(); size_t index=0; if (text_ptr) { string layer_attribute=ToString(text_ptr); if (pElem_l->ValueStr()==LIBGENS_LEVEL_XML_INDEX) { FromString<size_t>(index, layer_attribute, std::dec); level_set_entry->index = index; } if (pElem_l->ValueStr()==LIBGENS_LEVEL_XML_NAME) { level_set_entry->name = layer_attribute; } if (pElem_l->ValueStr()==LIBGENS_LEVEL_XML_FILENAME) { level_set_entry->filename = layer_attribute; } if (pElem_l->ValueStr()==LIBGENS_LEVEL_XML_COLOR) { level_set_entry->color = layer_attribute; } if (pElem_l->ValueStr()==LIBGENS_LEVEL_XML_IS_GAME_ACTIVE) { level_set_entry->active = (layer_attribute == LIBGENS_OBJECT_ELEMENT_BOOL_TRUE); } } } set_entries.push_back(level_set_entry); } } } } // Load StageGuidePath since it won't show up in any of the XMLs if the file exists. string path_filename = folder + LIBGENS_LEVEL_STAGE_GUIDE_PATH + LIBGENS_PATH_FULL_GENERATIONS_EXTENSION; if (File::check(path_filename)) { Path *path = new Path(path_filename); paths.push_back(path); } }
void MWBotWin::atkRat() { QWebElement elm; setBusy(true); // go to page loadPath(QStringList() << "square" << "metro"); // select dark/normal rats elm = frm->findFirstElement("div.metro-branch div.metro-rats-light__dark-block"); if (!elm.isNull()) { log(trUtf8("Dark/Normal select"),"bug.png"); if (opt.ratk.dark) { elm = frm->findFirstElement("a.f[href='/metro/select/1/']"); } else { elm = frm->findFirstElement("a.f[href='/metro/select/0/']"); } elm = elm.findFirst("div.c"); if (elm.isNull()) { log(trUtf8("DEBUG: Rat selection error")); return; } clickElement(elm); } // check timer & atk rat int time = getRatTimer(); if (opt.ratk.ratlev > opt.ratk.maxlev) { elm = frm->findFirstElement("div#action-rat-fight div small small.dashedlink"); if (elm.isNull()) { time = 60; } else { time = elm.attribute("timer").toInt() + 60; } opt.ratk.time = QDateTime::currentDateTime().addSecs(time); opt.ratk.ratlev = 1; log(trUtf8("Хватит крыс. Ждём обвала. До обвала <b>%0</b> мин.").arg(time/60 + 1),"rat.png"); } else if (time < 1) { log(trUtf8("Уровень крысы: <b>%0</b>").arg(opt.ratk.ratlev),"rat.png"); restoreHP(); clickElement("div#action-rat-fight div.button-big div.c"); clickElement("div#welcome-rat button.button div.c"); if (opt.ratk.ratlev % 5 == 0) { groupFight(); } else { fightResult(); } getRatTimer(); } else { time += 30 + random() % 30; opt.ratk.time = QDateTime::currentDateTime().addSecs(time); log(trUtf8("До следующей крысы <b>%0</b> мин.").arg(time/60 + 1),"rat.png"); } // take tails prize elm = frm->findFirstElement("div.metro-branch table.collectbar td.actions button.button"); if (!elm.isNull()) { if (!elm.classes().contains("disabled")) { elm = elm.findFirst("div.c"); clickElement(elm); log(trUtf8("Получен приз за крысинные хвосты"),"rattail.png"); } } setBusy(false); }
void ImportModelDialog::loadTextures() { texturePath = loadPath(); ui.texturePath->setText(texturePath.c_str()); }
string FabAtHomePrinter::loadFabFile(string filePath) { //Load the file. TiXmlDocument file; if(!file.LoadFile(filePath.c_str())) { return "Could not interpret "+filePath+" as a xml file."; } //Clear previously loaded data. materialCalibrations.clear(); model.paths.clear(); TiXmlNode* root(file.RootElement()); for(TiXmlNode* child = root->FirstChild(); child != NULL; child = root->IterateChildren(child)) { if(strcmp(child->Value(), "materialCalibration") == 0) { loadMaterialCalibration(child); } else if(strcmp(child->Value(), "path") == 0) { loadPath(child); } else if(strcmp(child->Value(), "printAcceleration") == 0) { PRINT_ACCELERATION = Util::assertType<double>(child->FirstChild()->Value()); } } return ""; /* XMLParser parser; string result = parser.load(filePath); if(result.compare("") != 0) { return result; } //Clear previously loaded data. materialCalibrations.clear(); model.paths.clear(); PRINT_ACCELERATION = Util::assertType<double>(parser.text("fabAtHomePrinter 0\\printAcceleration 0")); //Load material calibrations. unsigned int count = parser.count("fabAtHomePrinter 0\\materialCalibration"); for(unsigned int i = 0; i < count; ++i) { string base = "fabAtHomePrinter 0\\materialCalibration "+Util::toString(i)+"\\"; string name = parser.text(base+"name 0"); double pathSpeed = Util::assertType<double>(parser.text(base+"pathSpeed 0")); double pathWidth = Util::assertType<double>(parser.text(base+"pathWidth 0")); double depositionRate = Util::assertType<double>(parser.text(base+"depositionRate 0")); double pushout = Util::assertType<double>(parser.text(base+"pushout 0")); double suckback = Util::assertType<double>(parser.text(base+"suckback 0")); double suckbackDelay = Util::assertType<double>(parser.text(base+"suckbackDelay 0")); double clearance = Util::assertType<double>(parser.text(base+"clearance 0")); int pausePaths = Util::assertType<int>(parser.text(base+"pausePaths 0")); double pitch = Util::assertType<double>(parser.text(base+"pitch 0")); materialCalibrations[name] = MaterialCalibration(name,pathSpeed,pathWidth,depositionRate,pushout,suckback,suckbackDelay,clearance,pausePaths,pitch); } //Load paths. unsigned int pathCount = parser.count("fabAtHomePrinter 0\\path"); for(unsigned int i = 0; i < pathCount; ++i) { string iBase = "fabAtHomePrinter 0\\path "+Util::toString(i)+"\\"; string materialCalibrationName = parser.text(iBase+"materialCalibrationName 0"); if(materialCalibrations.find(materialCalibrationName) == materialCalibrations.end()) { return "A path references material calibration "+materialCalibrationName+" which has not been loaded."; } vector<Point> points; unsigned int pointCount = parser.count(iBase+"point"); for(unsigned int j = 0; j < pointCount; ++j) { string jBase = iBase+"point "+Util::toString(j)+"\\"; double x = Util::assertType<double>(parser.text(jBase+"x 0")); double y = Util::assertType<double>(parser.text(jBase+"y 0")); double z = Util::assertType<double>(parser.text(jBase+"z 0")); points.push_back(Point(x,y,z)); } model.paths.push_back(Path(&(materialCalibrations[materialCalibrationName]),points)); } return ""; */ }
void MWBotWin::atackOil() { setBusy(true); int time; int susp; int need; int type; int work; int idx; QWebElement elm,blk,tlm; curTime = QDateTime::currentDateTime(); getFastRes(); if (info.level < 10) { opt.oil.time = curTime.addDays(1); log(trUtf8("Нефтепровод доступен только с 10 уровня"),"neft.png"); } else { restoreHP(); loadPath(QStringList() << "tverskaya" << "neftlenin"); while (opt.oil.time < curTime) { restoreHP(); curTime = QDateTime::currentDateTime(); elm = frm->findFirstElement("div#neftlenin_alert_win"); if (elm.styleProperty("display",QWebElement::ComputedStyle).trimmed() != "none") { // already win elm = elm.findFirst("div.object div.data span.restartNeft"); time = elm.attribute("timer").toInt() + 60 + (random() % 30); opt.oil.time = QDateTime::currentDateTime().addSecs(time); log(trUtf8("Нефтепровод будет доступен через %0 сек").arg(time),"neft.png"); } else { // current suspicion tlm = frm->findFirstElement("div.pipeline-actions table td.mc div.progress i.counter"); susp = tlm.toPlainText().toInt(); // detect event type idx = 0; type = -1; do { if (oilType[idx].type == 0) { type = 0; } else { elm = frm->findFirstElement(oilType[idx].query); if (!elm.isNull() && (elm.styleProperty("display",QWebElement::ComputedStyle).trimmed() != "none")) { type = oilType[idx].type; } } idx++; } while (type < 0); // qDebug() << type; switch (type) { case preFight: // start fight if (!checkSusp(susp, 30)) { elm = frm->findFirstElement("div#pipeline-scroll div.enemy-place.fight div.action button.button div.c"); clickElement(elm); } break; case preGame: // start event elm = frm->findFirstElement("div#pipeline-scroll div.enemy-place.mission div.action button.button div.c"); clickElement(elm); break; case preBoss: // start boss if (!checkSusp(susp, 30)) { elm = frm->findFirstElement("div#pipeline-scroll div.enemy-place.fightboss div.action button.button div.c"); clickElement(elm); } break; case evDuel: // go duel elm = frm->findFirstElement("div#neftlenin_alert_d div.action button.button.first div.c"); // кнопка старта need = elm.findFirst("span.suspicion").toPlainText().remove("\"").toInt(); // надо подозрительности if (!checkSusp(susp, need)) { clickElement(elm); fightResult(); } break; case evGroup: // go group fight elm = frm->findFirstElement("div#neftlenin_alert_g div.action button.button.first div.c"); need = elm.findFirst("span.suspicion").toPlainText().remove("\"").toInt(); if (!checkSusp(susp, need)) { clickElement(elm); groupFight(); } break; case evBoss: // go boss elm = frm->findFirstElement("div#neftlenin_alert_b div.action.buttion.button.first div.c"); need = elm.findFirst("span.suspicion").toPlainText().remove("\"").toInt(); if (!checkSusp(susp, need)) { clickElement(elm); groupFight(); } break; case evGamePrepare: // start event timer elm = frm->findFirstElement("div#neftlenin_alert_prem_first div.action button.button div.c"); clickElement(elm); break; case evGameTimer: // event timer elm = frm->findFirstElement("div#neftlenin_alert_prem div.progress-wrapper span.timeleft"); need = elm.attribute("timer").toInt() + 15 + random() % 15; opt.oil.time = curTime.addSecs(need); log(trUtf8("До завершения задания %0 сек").arg(need),"neft.png"); break; case evGame: // event game log(trUtf8("Начало игры на нефтепроводе"),"neft.png"); elm = frm->findFirstElement("div#neftlenin_alert_mission div.game-process div.progress-block"); work = 1; while (work) { blk = elm.findFirst("div.step-block.active"); // блок с кубиками if (blk.isNull()) { need = oilGameEscape(); // проигрыш или выигрыш work = 0; } else { tlm = blk.findFirst("div.enemy-dice span.dice"); // текущий кубик need = tlm.classes().filter("dice-").first().remove("dice-").toInt(); // число на кубике //qDebug() << "cube" << need; if (need == 0) { qDebug() << "some error"; work = 0; opt.oil.time.addMonths(1); } else if (need <= opt.oil.diceMax) { // кликаем tlm = blk.findFirst("div.action button.button div.c"); clickElement(tlm); } else { // убегаем oilGameEscape(); work = 0; } } } break; default: log(trUtf8("DEBUG : oilpipe unknown situation"),"bug.png"); qDebug() << "unknown situation"; opt.oil.time = curTime.addMonths(1); break; } } } } setBusy(false); }
fint CodeGen::verifyParents(objectLookupTarget* target, Location t, fint count) { a.Comment("verify"); assert(target->links != NULL, "expecting an assignable parent link"); for ( assignableSlotLink* l = target->links; ; ) { // load assignable parent slot value a.movl(t, smiOop(l->slot->data)->byte_count() - Mem_Tag, VMAddressOperand, Temp1); Label ok; Label miss; Map* targetMap = l->target->obj->map(); if (l->target->value_constrained) { // constraint for a particular oop (ambiguity resolution) loadOop(Temp2, l->target->obj); // load assumed value a.cmpl(Temp1, Temp2); // compare values a.je(&ok); // will branch } // check if map of parent is correct else if (targetMap == Memory->smi_map) { a.testl(Tag_Mask, NumberOperand, Temp1); // test for integer tag a.je( &ok ); // branch if parent is integer } else if (targetMap == Memory->float_map) { a.btl( Float_Tag_bit_i386, Temp1); // if bit set must be hit, otherwise is mark a.jc(&ok); // branch if parent is a float } else { // must be mem tag a.btl(Mem_Tag_bit_i386, Temp1); // if bit set must be hit, otherwise is mark a.jnc(&miss); // branch if parent is not mem oop a.movl(Temp1, map_offset(), NumberOperand, Temp2); // load receiver map a.cmpl((int32)targetMap->enclosing_mapOop(), OopOperand, Temp2); // cmp to map constraint a.je(&ok); // correct } miss.define(); // This will be backpatched to call an nmethod, so need to leave incoming link alone. // Must look like the original call to me plus extra info in regs // Pass a link to the branch and nmln in the DILinkReg. a.movl(count, NumberOperand, DICountReg); // count of parents verified // must align nmln to follow // There is a call coming, each 5 bytes, so want pc + 5 to be 0 mod 4. // See align * in asmDefs_gcc_i386.[sS] // get ic value to pass in, cannot use call cause of backpatching, etc. Label next; a.call(&next); next.define(); // two tasks: compute amount to add to savedPC so it simulates a call: must point to after the jmp below // Also, just add enough nops so that nmln after call is word-alligned fint bytes_from_here_to_after_jmp_before_alignment = 1 /* popl */ + 3 /* addl */ + 5 /* jmp */; int32 here = a.offset(); fint word_fraction_from_here_to_after_jmp_before_alignment = (here + bytes_from_here_to_after_jmp_before_alignment ) & 3; fint num_nops = (BytesPerWord - word_fraction_from_here_to_after_jmp_before_alignment) & (BytesPerWord-1); fint bytes_from_here_to_after_jmp = bytes_from_here_to_after_jmp_before_alignment + num_nops; for (fint i = 0; i < num_nops; ++i) a.nop(); a.popl(DIInlineCacheReg); // 1 byte, prepare to calculate IC addr below a.addl(bytes_from_here_to_after_jmp, NumberOperand, DIInlineCacheReg); // 3 bytes, finish calc IC addr below // following must be parsable to set_target_of_Self_call_site a.jmp( (int32)SendDIMessage_stub, DIVMAddressOperand); assert( a.offset() == here + bytes_from_here_to_after_jmp, "checking"); assert((a.offset() & (BytesPerWord-1)) == 0, "must be aligned"); a.Data(0); // first part of DI nmln a.Data(0); // second part of DI nmln a.hlt(); ok.define(); ++count; if (l->target->links) count = verifyParents(l->target, Temp1, count); l = l->next; if (l == 0) break; // if multiple dynamic parents, reload slot holder before looping (HACK!) t = loadPath(Temp1, target, LReceiverReg, Temp1); } return count; }
geoData mapload(char* path,VisiLibity::Environment & mapEnv,VisiLibity::Visibility_Graph & visGraph,float clearDist ) { std::ifstream in(path); std::string s; std::string s1=""; while(getline(in, s)) { // Discards newline char s1=s1+s+"\n"; } std::vector<char> xml_copy(s1.begin(), s1.end()); xml_copy.push_back('\0'); rapidxml::xml_document<> doc; // character type defaults to char doc.parse<0>(&xml_copy[0]); // 0 means default parse flags //std::cout << "Name of my first node is: " << doc.first_node()->name() << "\n"; rapidxml::xml_node<char> *n1; n1=doc.first_node("svg"); n1=n1->first_node("g")->first_node("path"); //std::vector < VisiLibity::Point > poly_temp; //geoData vertices_temp(10,poly_temp); geoData vertices_temp; int i=0; while (n1) { vertices_temp.push_back(loadPath(n1->first_attribute("d")->value())); n1=n1->next_sibling("path"); i++; } Polygon_2 mapEnvOB; for (int j=0;j<vertices_temp[0].size();j++) { Point_2 nextVert= Point_2(vertices_temp[0][j][0],vertices_temp[0][j][1]); mapEnvOB.push_back(nextVert); }; Polygon_set_2 S; mapEnvOB.reverse_orientation(); S.insert(mapEnvOB); for (int k=1;k<vertices_temp.size();k++) { Polygon_2 holeCGAL; for (int j=0;j<vertices_temp[k].size();j++) { holeCGAL.push_back(Point_2(vertices_temp[k][j][0],vertices_temp[k][j][1])); }; //holeCGAL.reverse_orientation(); S.difference(holeCGAL); holeCGAL.clear(); }; std::list<Polygon_with_holes_2> res; std::list<Polygon_with_holes_2>::const_iterator it; S.polygons_with_holes (std::back_inserter (res)); std::vector<VisiLibity::Polygon> envPolys; for (it = res.begin(); it != res.end(); ++it) { if(CGAL::ON_BOUNDED_SIDE==CGAL::bounded_side_2(it->outer_boundary().vertices_begin(),it->outer_boundary().vertices_end(),Point_2(guest1.pos.x(),guest1.pos.y()),Kernel())) { envPolys.push_back(ConvertPolygonCGAL2Vis(it->outer_boundary())); Polygon_with_holes_2::Hole_const_iterator hi; for (hi=it->holes_begin();hi!=it->holes_end();++hi) { envPolys.push_back(ConvertPolygonCGAL2Vis(*hi)); }; break; }; } for (int i=0;i<envPolys.size();i++){ //envPolys.push_back(VisiLibity::Polygon(vertices_temp[i])); //i=0; envPolys[i].eliminate_redundant_vertices(0.0001); VisiLibity::Point cm=envPolys[i].centroid(); for (int j=0;j<envPolys[i].n();j++) { if (j<envPolys[i].n()-1){ VisiLibity::Point n1=clearDist*normal(envPolys[i][j+1]-envPolys[i][j]); envPolys[i][j]=envPolys[i][j]+n1; envPolys[i][j+1]=envPolys[i][j+1]+n1; } } VisiLibity::Point norm1=clearDist*normal(envPolys[i][0]-envPolys[i][envPolys[i].n()-1]); envPolys[i][0]=envPolys[i][0]+norm1; envPolys[i][envPolys[i].n()-1]=envPolys[i][envPolys[i].n()-1]+norm1; }; mapEnv = *(new VisiLibity::Environment(envPolys)); mapEnv.enforce_standard_form(); visGraph = *(new VisiLibity::Visibility_Graph(mapEnv,0.00000001)); return vertices_temp; };
void CodeGen::prologue(bool isAccessMethod, fint nargs ) { // *if not DI child // <smi/float/memOop prologue> // _verified: (entry point from PICs) // if necessary <check selector> // if necessary <check delegatee> // *endif DI // _diCheck: (entry point after recompile) // <verify assignable parents> // *if using recompilation // <checkRecompilation> // *endif // *if haveStackFrame // save sp, -frameSize*oopSize, sp // *endif // <flush register windows if neceessary> // <clear stack temporaries and excess argument locations // CAUTION: use only Temp1/4 for temps in prologue; other temps // may contain lookup parameters. assert(Temp1 != PerformSelectorLoc && Temp1 != PerformDelegateeLoc, "will trash lookup parameters"); assert(Temp2 != PerformSelectorLoc && Temp2 != PerformDelegateeLoc, "will trash lookup parameters"); fint assignableParents = L->adeps->length(); MethodKind kind = isAccessMethod ? MethodKind(-1) : theCompiler->method()->kind(); _incoming_arg_count = nargs; // for eventual putting into nmethod if (diLink == 0) { if (!L->isReceiverStatic()) { // test receiver map # if GENERATE_DEBUGGING_AIDS if (CheckAssertions) switch (L->lookupType()) { case NormalLookupType: break; case StaticNormalLookupType: case ImplicitSelfLookupType: case ResendLookupType: case DirectedResendLookupType: fatal("shouldn't miss"); break; default: break; } # endif Map* m = L->receiverMap(); bool imm = m == Memory->smi_map || m == Memory->float_map; if (SICCountTypeTests) { a.startTypeTest(1, true, imm); a.doOneTypeTest(); } if (m == Memory->smi_map) { smiOop_prologue(Memory->code->trapdoors->SendMessage_stub_td()); } else if (m == Memory->float_map) { floatOop_prologue(Memory->code->trapdoors->SendMessage_stub_td()); } else { memOop_prologue(Memory->code->trapdoors->SendMessage_stub_td()); } } verifiedOffset = a.offset(); if (SICCountTypeTests) a.endTypeTest(); Label generalMiss(a.printing, NULL); a.Comment("verified entry point:"); if (L->isPerform()) { a.Comment("check selector"); checkOop(generalMiss, L->selector(), PerformSelectorLoc); } if (needsDelegatee(L->lookupType()) && !L->isDelegateeStatic()) { a.Comment("check delegatee"); checkOop(generalMiss, L->delegatee(), PerformDelegateeLoc); } } else { // don't check receiver map, selector, delegatee if a DI cache miss assert(assignableParents > 0, "should have some di parents to check"); } diCheckOffset = a.offset(); a.Comment("DI entry point:"); if (assignableParents > 0) { a.Comment("verify state of assignable parents"); fint count = 0; for (fint i = 0; i < assignableParents; i ++) { objectLookupTarget* target = L->adeps->start()[i]; Location t = loadPath(Temp2, target, ReceiverReg, Temp1); count = verifyParents(target, t, count); } } bool recomp = needRecompileCode(theCompiler->level()); if (recomp) checkRecompilation(); if (haveStackFrame) { prologueAddr = a.addr(); a.SaveI(SP, -1, SP); // correct frame size is patched in later frameCreationOffset = a.offset(); } else { prologueAddr = NULL; } if (GenerateCountCode) { int32* counter; if (assignableParents != 0) { counter = &NumberOfDIMethodCalls; } else if (isAccessMethod) { counter = &NumberOfAccessMethodCalls; } else if (kind == BlockMethodType) { counter = &NumberOfBlockMethodCalls; } else { counter = &NumberOfMethodCalls; } genCountCode(counter); } if (!isAccessMethod) { if (!recomp && GenerateLRUCode) { // this code is rarely generated in practice (recomp is usually true) a.Comment("reset unused bit"); void* unused_addr = &LRUflag[Memory->code->nextNMethodID()]; a.SetHiA(unused_addr, Temp2); a.StoreA(Temp2, unused_addr, G0); } // don't keep uplevel-accessed names in regs // (for now, just flush everything) if (nargs > NumIArgRegisters) nargs = NumIArgRegisters; a.Comment("flush incoming args to stack"); for (fint i = 0; i < nargs; i++) { flushToStack(IArgLocation(i), NULL); } flushToStack(IReceiverReg, NULL); // flush receiver to stack switch (kind) { case BlockMethodType: if (theCompiler->needRegWindowFlushes) flushRegisterWindows(); break; case OuterMethodType: if (needToFlushRegWindow) { // we inlined the receiver block if (theCompiler->needRegWindowFlushes) flushRegisterWindows(); } else { // receiver is parent, do nothing } break; default: fatal1("unknown kind: %ld", kind); break; } } a.Comment("End Prologue"); }
fint CodeGen::verifyParents(objectLookupTarget* target, Location t, fint count) { assignableSlotLink* l = target->links; assert(l != 0, "expecting an assignable parent link"); for (;;) { a.LoadI(t, smiOop(l->slot->data)->byte_count() - Mem_Tag, Temp1); // load assignable parent slot value Label* ok; Map* targetMap = l->target->obj->map(); if (l->target->value_constrained) { // constraint for a particular oop (ambiguity resolution) loadOop(Temp2, l->target->obj); // load assumed value a.SubCCR(Temp1, Temp2, G0); // compare values ok = a.BeqForward(false); // branch if value OK if (l->target->links) a.Nop(); } else { // check if map of parent is correct if (targetMap == Memory->smi_map) { a.AndCCI(Temp1, Tag_Mask, G0); // test for integer tag ok = a.BeqForward(false); // branch if parent is integer if (l->target->links) a.Nop(); } else if (targetMap == Memory->float_map) { a.AndCCI(Temp1, Float_Tag, G0); // test for float tag ok = a.BneForward(false); // branch if parent is a float if (l->target->links) a.Nop(); } else { Label* miss = NULL; if (!FastMapTest) { a.AndCCI(Temp1, Mem_Tag, G0); // test for mem tag Label* mem = a.BneForward(true); // branch if parent is mem oop a.LoadI(Temp1, map_offset(), Temp2); // load receiver map miss = a.BraForward(true); // branch to diLookup section mem->define(); } else { a.LoadI(Temp1, map_offset(), Temp2); // load receiver map } loadOop(Temp3, targetMap->enclosing_mapOop()); // load map constraint a.SubCCR(Temp2, Temp3, G0); // compare w/ parent's map ok = a.BeqForward(false); // correct if (l->target->links) a.Nop(); if (miss) miss->define(); } } void* addr = Memory->code->trapdoors->SendDIMessage_stub_td(); a.SetHiD(addr, Temp1); a.JmpLD(Temp1, addr, DILinkReg); loadImmediate(DICountReg, count); // count of parents verified a.Data(0); // first part of DI nmln a.Data(0); // second part of DI nmln ok->define(); count ++; if (l->target->links) count = verifyParents(l->target, Temp1, count); l = l->next; if (l == 0) break; // if multiple dynamic parents, reload slot holder before looping (HACK!) t = loadPath(Temp1, target, ReceiverReg, Temp1); } return count; }