int go() { Eval::FileRepository::forEachUnit(*this); // user-defined (*this)(SystemLib::s_nativeFuncUnit); // native // Now all the classes. AllFuncs above only visited the Funcs hanging // off of preclasses. for (AllClasses ac; !ac.empty();) { for (Class::MutableMethodRange fr(ac.popFront()->mutableMethodRange()); !fr.empty();) { visit(fr.popFront()); } } return m_numFuncs; }
TEST(CallframeTestSuite, Unmapped) { Callframe fr(34, "libc.so.7"); fr.setUnmapped(); ASSERT_TRUE(fr.isUnmapped()); const auto & frames = fr.getInlineFrames(); ASSERT_EQ(frames.size(), 1); ASSERT_EQ(frames[0].getFile(), "libc.so.7"); ASSERT_EQ(frames[0].getOffset(), 34); ASSERT_TRUE(!frames[0].isMapped()); }
static inline void sdup() { /* duplicate string */ int i; SUBTITLE(strdup); /* allocation phase */ for (i = 0 ; i < MAX_ALLOC ; i ++) my_alloc[i] = sdu(); /* free phase */ fr(); }
vframe* compiledVFrame::sender() const { const frame f = fr(); if (scope() == NULL) { // native nmethods have no scope the method/bci is implied nmethod* nm = code(); assert(nm->is_native_method(), "must be native"); return vframe::sender(); } else { return scope()->is_top() ? vframe::sender() : new compiledVFrame(&f, register_map(), thread(), scope()->sender()); } }
RGBColor GlossyReflector::area_light_shade(ShadeRec& sr)const { RGBColor L(Phong::area_light_shade(sr)); Vector3D wo(-sr.ray.d); Vector3D wi; float pdf; RGBColor fr(glossy_specular_brdf->sample_f(sr,wo,wi,pdf)); Ray reflected_ray(sr.hit_point,wi); L += fr * sr.w.tracer_ptr->trace_ray(reflected_ray,sr.depth+1) * (sr.normal*wi) / pdf; return L; }
void DocumentApi::setConstantFrameRate(Sprite* sprite, int msecs) { // Add undoers. DocumentUndo* undo = m_document->getUndo(); if (undo->isEnabled()) { for (FrameNumber fr(0); fr<sprite->getTotalFrames(); ++fr) m_undoers->pushUndoer(new undoers::SetFrameDuration( getObjects(), sprite, fr)); } // Do the action. sprite->setDurationForAllFrames(msecs); }
void MemoryManager::imageRead(FILE* fp) { long i, size; fr(fp, (char *) &symbols, sizeof(object)); i = 0; while(fr(fp, (char *) &dummyObject, sizeof(dummyObject))) { i = dummyObject.di; if ((i < 0) || (i >= objectTable.size())) { // Grow enough, plus a bit. growObjectStore(i - objectTable.size() + 500); } objectTable[i]._class = dummyObject.cl; if ((objectTable[i]._class < 0) || ((objectTable[i]._class) >= objectTable.size())) { // Grow enough, plus a bit. growObjectStore(objectTable[i]._class - objectTable.size() + 500); } objectTable[i].size = size = dummyObject.ds; if (size < 0) size = ((- size) + 1) / 2; if (size != 0) { objectTable[i].memory = mBlockAlloc((int) size); fr(fp, (char *) objectTable[i].memory, sizeof(object) * (int) size); } else objectTable[i].memory = (object *) 0; objectTable[i].referenceCount = 666; } setFreeLists(); }
StackValueCollection* interpretedVFrame::expressions() const { int length = fr().interpreter_frame_expression_stack_size(); if (method()->is_native()) { // If the method is native, there is no expression stack length = 0; } int nof_locals = method()->max_locals(); StackValueCollection* result = new StackValueCollection(length); InterpreterOopMap oop_mask; // Get oopmap describing oops and int for current bci if (TraceDeoptimization && Verbose) { methodHandle m_h(method()); OopMapCache::compute_one_oop_map(m_h, bci(), &oop_mask); } else { method()->mask_for(bci(), &oop_mask); } // handle expressions for(int i=0; i < length; i++) { // Find stack location intptr_t *addr = fr().interpreter_frame_expression_stack_at(i); // Depending on oop/int put it in the right package StackValue *sv; if (oop_mask.is_oop(i + nof_locals)) { // oop value Handle h(*(oop *)addr); sv = new StackValue(h); } else { // integer sv = new StackValue(*addr); } assert(sv != NULL, "sanity check"); result->add(sv); } return result; }
RGBColor GlossyReflector::area_light_shade(ShadeRec& sr) //this is for chapter 18 page one image ad-hoc { RGBColor L(Phong::area_light_shade(sr)); // direct illumination Vector3D wo(-sr.ray.d); Vector3D wi; float pdf; RGBColor fr(glossy_specular_brdf->sample_f(sr, wo, wi, pdf)); Ray reflected_ray(sr.hit_point, wi); L += fr * sr.w.tracer_ptr->trace_ray(reflected_ray, sr.depth + 1) * (sr.normal * wi) / pdf; return (L); }
void loadRefTable(FILE* f, GHash<RefTran>& rt) { GLineReader fr(f); char* line=NULL; while ((line=fr.getLine())) { char* orig_id=line; char* p=line; while (*p!=0 && !isspace(*p)) p++; if (*p==0) continue; *p=0;p++;//split the line here while (*p==' ' || *p=='\t') p++; if (*p==0) continue; rt.Add(orig_id, new RefTran(p)); } //while lines }
static inline void reallo() { /* realloc/free */ int i; SUBTITLE(realloc); /* allocation phase */ for (i = 0 ; i < MAX_ALLOC ; i ++) my_alloc[i] = real(); /* free phase */ fr(); }
/*A :in B :ans C :out D :res */ int main() { setspj("numbers1"); int correct = 0; int u = 0,v=0; fr(B,"%d",&u); fr(C,"%d",&v); for(int i = 1;i<=60000;++i) { fr(B,"%d",&u); fr(C,"%d",&v); if(u==v) ++correct; else { ff(D,"%d\n",i); } } ff(D,"%d\n",correct); closespj(); return 0; }
TexturePack::TexturePack( std::string const& filename ) { // file format: // // uint32 numImages; // uint32 totalWidth; // uint32 totalHeight; // // for i in numImages: // uint8 nameLength // char[nameLength] name // uint32 startX // uint32 startY // uint32 width // uint32 height // pixel[width][height] image try { FileReader fr( filename ); int numImages = fr.readInt32(); int width = fr.readInt32(); int height = fr.readInt32(); this->texture.create( width, height ); for ( int i = 0; i < numImages; ++i ) { std::string name = fr.readString(); int xPos = fr.readInt32(); int yPos = fr.readInt32(); PixelObject p; p.loadFromFile( fr ); sf::Uint8 const* rawPixelData = this->vectorToPixelArray( p.getPixelData() ); this->texture.update( rawPixelData, p.getWidth(), p.getHeight(), xPos, yPos ); this->definitions[name] = sf::IntRect( xPos, yPos, p.getWidth(), p.getHeight() ); } } catch ( std::exception const& e ) { throw std::runtime_error( e.what() ); } }
void compiledVFrame::update_local(BasicType type, int index, jvalue value) { #ifdef ASSERT assert(fr().is_deoptimized_frame(), "frame must be scheduled for deoptimization"); #endif /* ASSERT */ GrowableArray<jvmtiDeferredLocalVariableSet*>* deferred = thread()->deferred_locals(); if (deferred != NULL ) { // See if this vframe has already had locals with deferred writes int f; for ( f = 0 ; f < deferred->length() ; f++ ) { if (deferred->at(f)->matches(this)) { // Matching, vframe now see if the local already had deferred write GrowableArray<jvmtiDeferredLocalVariable*>* locals = deferred->at(f)->locals(); int l; for (l = 0 ; l < locals->length() ; l++ ) { if (locals->at(l)->index() == index) { locals->at(l)->set_value(value); return; } } // No matching local already present. Push a new value onto the deferred collection locals->push(new jvmtiDeferredLocalVariable(index, type, value)); return; } } // No matching vframe must push a new vframe } else { // No deferred updates pending for this thread. // allocate in C heap deferred = new(ResourceObj::C_HEAP, mtCompiler) GrowableArray<jvmtiDeferredLocalVariableSet*> (1, true); thread()->set_deferred_locals(deferred); } deferred->push(new jvmtiDeferredLocalVariableSet(method(), bci(), fr().id())); assert(deferred->top()->id() == fr().id(), "Huh? Must match"); deferred->top()->set_local_at(index, type, value); }
void javaVFrame::print_value() const { methodOop m = method(); klassOop k = m->method_holder(); tty->print("%s.%s", Klass::cast(k)->internal_name(), m->name()->as_C_string()); if (!m->is_native()) { symbolOop source_name = instanceKlass::cast(k)->source_file_name(); int line_number = m->line_number_from_bci(bci()); if (source_name != NULL && (line_number != -1)) { tty->print("(%s:%d)", source_name->as_C_string(), line_number); } } else { tty->print("(Native Method)"); } // Check frame size and print warning if it looks suspiciously large if (fr().sp() != NULL) { int size = fr().frame_size(); #ifdef _LP64 if (size > 8*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size); #else if (size > 4*K) warning("SUSPICIOUSLY LARGE FRAME (%d)", size); #endif } }
void MainWindow::calculate_total_length(){ for(int i =0; i<playlist_names.count(); i++){ QString filename = playlist_names.at(i); #ifdef Q_OS_WIN const wchar_t * encodedName = reinterpret_cast<const wchar_t*>(filename.utf16()); #else const char * encodedName = QFile::encodeName(filename).constData(); #endif TagLib::FileRef fr(encodedName, true, TagLib::AudioProperties::Accurate); total_length += fr.audioProperties()->length(); } ui->label_totallength->setText(convert_time(total_length)); }
static void testEmptyAfterDone(int num_narrow, int num_full) { FakeRoots fr(num_narrow, num_full); DoNothingOopClosure cl; BufferingOopClosure boc(&cl); fr.oops_do(&boc, 0); // Make sure all get processed. boc.done(); assert(boc.is_buffer_empty(), err_msg("Should be empty after call to done(). testEmptyAfterDone(%d, %d)", num_narrow, num_full)); }
/*! * Checks whether the file extension is supported by the language counter. * * \param file_name file name * * \return whether file extension is supported */ bool CCodeCounter::IsSupportedFileExtension(const string &file_name) { // if Makefile, check whether name equals MAKEFILE since no extension exists if (classtype == MAKEFILE && file_name.size() >= 8) { if (CUtil::ToLower(file_name.substr(file_name.size() - 8)) == "makefile") return true; } size_t idx = file_name.find_last_of("."); if (idx == string::npos) return false; string file_ext = file_name.substr(idx); file_ext = CUtil::ToLower(file_ext); if (find(file_extension.begin(), file_extension.end(), file_ext) != file_extension.end()) { // if X-Midas/NeXtMidas, parse file to check for startmacro or endmacro (needed since Midas can use .txt or .mm) if (classtype == XMIDAS || classtype == NEXTMIDAS) { string oneline; ifstream fr(file_name.c_str(), ios::in); if (!fr.is_open()) return false; // search for "startmacro" (optional) or "endmacro" (required) while (fr.good() || fr.eof()) { getline(fr, oneline); if ((!fr.good() && !fr.eof()) || (fr.eof() && oneline.empty())) break; oneline = CUtil::ToLower(CUtil::TrimString(oneline)); if (oneline.compare(0, 10, "startmacro") == 0 || oneline.compare(0, 8, "endmacro") == 0) { fr.clear(); fr.close(); return true; } if (!fr.good()) break; } fr.clear(); fr.close(); } else return true; } return false; }
void RollbackStorage::loadPageFromFile() { currentPage.clear(); currentPageSize = 0; FileName pageFileName = computePageFileName(numPages - 1); sizeSavedPages -= FileWriter::getFileSize(pageFileName); { boost::shared_ptr<FileReader> fr(FileReader::getFileReader(pageFileName)); fr->openFile(true); if (fr->isSectionLine() && fr->getSection() == "VALUES") { fr->nextLine(); while (fr->isDataLine()) { IdentifiersType path = fr->getDataIdentifiers(0); int type = fr->getDataInteger(1); string value = fr->getDataString(2); CellValue val; if (type == 1) { // integer char *p; double d = strtod(value.c_str(), &p); if (*p == '\0') { val = d; } } else { // string val = value; } currentPage.push_back(make_pair(path, val)); currentPageSize += getSize(path, val); // get next line of saved data fr->nextLine(); } } } FileUtils::remove(pageFileName); pageSizes.pop_back(); Logger::debug << "rollback page '" << numPages - 1 << "' loaded (sizeSavedPages = " << sizeSavedPages << ")" << endl; }
void FlatTextarea::onMentionHashtagOrBotCommandInsert(QString str) { QTextCursor c(textCursor()); int32 pos = c.position(); QTextDocument *doc(document()); QTextBlock block = doc->findBlock(pos); for (QTextBlock::Iterator iter = block.begin(); !iter.atEnd(); ++iter) { QTextFragment fr(iter.fragment()); if (!fr.isValid()) continue; int32 p = fr.position(), e = (p + fr.length()); if (p >= pos || e < pos) continue; QTextCharFormat f = fr.charFormat(); if (f.isImageFormat()) continue; bool mentionInCommand = false; QString t(fr.text()); for (int i = pos - p; i > 0; --i) { if (t.at(i - 1) == '@' || t.at(i - 1) == '#' || t.at(i - 1) == '/') { if ((i == pos - p || (t.at(i - 1) == '/' ? t.at(i).isLetterOrNumber() : t.at(i).isLetter()) || t.at(i - 1) == '#') && (i < 2 || !(t.at(i - 2).isLetterOrNumber() || t.at(i - 2) == '_'))) { c.setPosition(p + i - 1, QTextCursor::MoveAnchor); int till = p + i; for (; (till < e) && (till - p - i + 1 < str.size()); ++till) { if (t.at(till - p).toLower() != str.at(till - p - i + 1).toLower()) { break; } } if (till - p - i + 1 == str.size() && till < e && t.at(till - p) == ' ') { ++till; } c.setPosition(till, QTextCursor::KeepAnchor); c.insertText(str + ' '); return; } else if ((i == pos - p || t.at(i).isLetter()) && t.at(i - 1) == '@' && i > 2 && (t.at(i - 2).isLetterOrNumber() || t.at(i - 2) == '_') && !mentionInCommand) { mentionInCommand = true; --i; continue; } break; } if (pos - p - i > 127 || (!mentionInCommand && (pos - p - i > 63))) break; if (!t.at(i - 1).isLetterOrNumber() && t.at(i - 1) != '_') break; } break; } c.insertText(str + ' '); }
TEST_F(FileV4Test, EmptyFile) { PWSfileV4 fw(fname.c_str(), PWSfile::Write, PWSfile::V40); ASSERT_EQ(PWSfile::SUCCESS, fw.Open(passphrase)); ASSERT_EQ(PWSfile::SUCCESS, fw.Close()); ASSERT_TRUE(pws_os::FileExists(fname)); PWSfileV4 fr(fname.c_str(), PWSfile::Read, PWSfile::V40); // Try opening with wrong passphrasse, check failure EXPECT_EQ(PWSfile::WRONG_PASSWORD, fr.Open(_T("x"))); // Now open with correct one, check emptiness ASSERT_EQ(PWSfile::SUCCESS, fr.Open(passphrase)); EXPECT_EQ(PWSfile::END_OF_FILE, fr.ReadRecord(item)); EXPECT_EQ(PWSfile::SUCCESS, fr.Close()); }
void TaskStore::scan() { clear(); // scan files DataFieldFileReader fr(_T("%s"), _T("%s"), NULL); fr.ScanDirectoryTop(_T("*.tsk")); fr.Sort(); // append to list for (unsigned i = 1; i < fr.size(); i++) { const DataFieldFileReaderEntry& item = fr.getItem(i); m_store.push_back(TaskStoreItem(item.mTextPathFile, item.mTextFile)); } }
void Braces::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) { // Draw left brace. painter->setPen(style()->leftBracePen()); QFont fl(style()->leftBraceFont()); fl.setPixelSize(textSize_); painter->setFont(fl); painter->drawText(QPointF(xOffset(), yOffset()) + leftBraceOffset_, style()->leftBrace()); // Draw right brace. painter->setPen(style()->rightBracePen()); QFont fr(style()->rightBraceFont()); fr.setPixelSize(textSize_); painter->setFont(fr); painter->drawText(QPointF(xOffset()+rightBraceLeft_, yOffset()) + rightBraceOffset_, style()->rightBrace()); }
TEST_F(FileV4Test, AttTest) { PWSfileV4 fw(fname.c_str(), PWSfile::Write, PWSfile::V40); ASSERT_EQ(PWSfile::SUCCESS, fw.Open(passphrase)); EXPECT_EQ(PWSfile::SUCCESS, fw.WriteRecord(attItem)); ASSERT_EQ(PWSfile::SUCCESS, fw.Close()); ASSERT_TRUE(pws_os::FileExists(fname)); CItemAtt readAtt; PWSfileV4 fr(fname.c_str(), PWSfile::Read, PWSfile::V40); ASSERT_EQ(PWSfile::SUCCESS, fr.Open(passphrase)); EXPECT_EQ(PWSfile::SUCCESS, fr.ReadRecord(readAtt)); EXPECT_EQ(PWSfile::END_OF_FILE, fr.ReadRecord(item)); EXPECT_EQ(PWSfile::SUCCESS, fr.Close()); attItem.SetOffset(readAtt.GetOffset()); EXPECT_EQ(attItem, readAtt); }
static void testIsBufferEmptyOrFull(int num_narrow, int num_full, bool expect_empty, bool expect_full) { FakeRoots fr(num_narrow, num_full); DoNothingOopClosure cl; BufferingOopClosure boc(&cl); fr.oops_do(&boc, 0); #define assert_testIsBufferEmptyOrFull(got, expected) \ assert((got) == (expected), \ err_msg("Expected: %d, got: %d. testIsBufferEmptyOrFull(%d, %d, %s, %s)", \ (got), (expected), num_narrow, num_full, \ BOOL_TO_STR(expect_empty), BOOL_TO_STR(expect_full))) assert_testIsBufferEmptyOrFull(expect_empty, boc.is_buffer_empty()); assert_testIsBufferEmptyOrFull(expect_full, boc.is_buffer_full()); }
/* Function :downloadCustomFace Notes :读取头像文件并发给请求的客户端 Author :Fred Huang Date :2008-03-18 Parameter : long :用户的ID号,是被请求下载的用户ID号 long :数据块的索引 UINT :客户在服务器的SOCKET索引 DWORD :未知 return :void */ void CUserCustomLogo::downloadCustomFace(long dwUserID, long nBlockIndex, UINT uIndex, DWORD dwHandleID) { //取管理窗口指针 CGameLogonManage *pWnd=(CGameLogonManage*)pParentWnd; //计算头像文件名 CString logoFile; logoFile.Format("%s\\%d\\%d.png",pWnd->m_CustomFacePath,dwUserID/1000,dwUserID); //查询文件是否存在 CFileFind ff; BOOL bFoundFile=ff.FindFile(logoFile); ff.Close(); if(!bFoundFile) return; //读取文件块,每个块大小为 char buf[513]={0}; //多一个字节 CFile fr(logoFile,CFile::modeRead); int filelen=fr.GetLength(); //文件大小 int packagesize=512; //数据块大小 if(nBlockIndex*512>filelen) //是否超出了文件的结尾 { fr.Close(); return; } if(nBlockIndex*512+packagesize>filelen) //最后一块大小是否超出了文件的结尾 packagesize=filelen-nBlockIndex*512; //最不足块大小的数据 fr.Seek(nBlockIndex*512,CFile::begin); //文件定位 fr.Read(buf,packagesize); //读数据 fr.Close(); //关闭文件 //填充数据结构 MSG_UL_S_DOWN msg; ZeroMemory(&msg,sizeof(MSG_UL_S_DOWN)); msg.dwUserID=dwUserID; //用户ID msg.nBlockIndex=nBlockIndex; //数据块索引 msg.nBlockSize=512; //数据块大小 msg.nPackageSize=packagesize; //数据包的大小 msg.nFileSize=filelen; //文件大小 msg.nBlockCount=(filelen-1)/512+1; //数据块数量 memcpy(msg.szData,buf,packagesize); //数据 //发送数据 pWnd->m_TCPSocket.SendData(uIndex,&msg,sizeof(MSG_UL_S_DOWN),MDM_GR_USER_LOGO,ASS_ULS_DOWN,dwHandleID,0); }
void FlatTextarea::getMentionHashtagBotCommandStart(QString &start) const { int32 pos = textCursor().position(); if (textCursor().anchor() != pos) return; QTextDocument *doc(document()); QTextBlock block = doc->findBlock(pos); for (QTextBlock::Iterator iter = block.begin(); !iter.atEnd(); ++iter) { QTextFragment fr(iter.fragment()); if (!fr.isValid()) continue; int32 p = fr.position(), e = (p + fr.length()); if (p >= pos || e < pos) continue; QTextCharFormat f = fr.charFormat(); if (f.isImageFormat()) continue; bool mentionInCommand = false; QString t(fr.text()); for (int i = pos - p; i > 0; --i) { if (t.at(i - 1) == '@') { if ((pos - p - i < 1 || t.at(i).isLetter()) && (i < 2 || !(t.at(i - 2).isLetterOrNumber() || t.at(i - 2) == '_'))) { start = t.mid(i - 1, pos - p - i + 1); } else if ((pos - p - i < 1 || t.at(i).isLetter()) && i > 2 && (t.at(i - 2).isLetterOrNumber() || t.at(i - 2) == '_') && !mentionInCommand) { mentionInCommand = true; --i; continue; } return; } else if (t.at(i - 1) == '#') { if (i < 2 || !(t.at(i - 2).isLetterOrNumber() || t.at(i - 2) == '_')) { start = t.mid(i - 1, pos - p - i + 1); } return; } else if (t.at(i - 1) == '/') { if (i < 2) { start = t.mid(i - 1, pos - p - i + 1); } return; } if (pos - p - i > 127 || (!mentionInCommand && (pos - p - i > 63))) break; if (!t.at(i - 1).isLetterOrNumber() && t.at(i - 1) != '_') break; } return; } }
void Thread::gc_epilogue(void) { // Java frames if (last_java_frame_exists()) { Frame fr(this); while (true) { if (fr.is_entry_frame()) { fr.as_EntryFrame().gc_epilogue(); if (fr.as_EntryFrame().is_first_frame()) { break; } fr.as_EntryFrame().caller_is(fr); } else { fr.as_JavaFrame().gc_epilogue(); fr.as_JavaFrame().caller_is(fr); } } } }
TEST_F(FileV4Test, ItemTest) { PWSfileV4 fw(fname.c_str(), PWSfile::Write, PWSfile::V40); ASSERT_EQ(PWSfile::SUCCESS, fw.Open(passphrase)); EXPECT_EQ(PWSfile::SUCCESS, fw.WriteRecord(smallItem)); EXPECT_EQ(PWSfile::SUCCESS, fw.WriteRecord(fullItem)); ASSERT_EQ(PWSfile::SUCCESS, fw.Close()); ASSERT_TRUE(pws_os::FileExists(fname)); PWSfileV4 fr(fname.c_str(), PWSfile::Read, PWSfile::V40); ASSERT_EQ(PWSfile::SUCCESS, fr.Open(passphrase)); EXPECT_EQ(PWSfile::SUCCESS, fr.ReadRecord(item)); EXPECT_EQ(smallItem, item); EXPECT_EQ(PWSfile::SUCCESS, fr.ReadRecord(item)); EXPECT_EQ(fullItem, item); EXPECT_EQ(PWSfile::END_OF_FILE, fr.ReadRecord(item)); EXPECT_EQ(PWSfile::SUCCESS, fr.Close()); }
// reads the content of the given map file, and stores the relative map in the given vector // each line of the file must be composed of two components (namely, x and y), // lines with too few or too many components WILL BE IGNORED. void readMapFile(std::string filename, std::vector<Eigen::Vector3d> * positions) { FileReader fr(filename); std::vector<std::string> textline; fr.readLine(&textline); while (fr.good()) { if (textline.size() == 2) { Eigen::Vector3d v; v[0] = atof(textline[0].c_str()); v[1] = atof(textline[1].c_str()); v[2] = 1; // this is for getting coordinates in homogeneous form positions->push_back(v); } textline.clear(); fr.readLine(&textline); } }