当前位置: 首页>>代码示例>>C++>>正文


C++ PhpFile::unit方法代码示例

本文整理汇总了C++中PhpFile::unit方法的典型用法代码示例。如果您正苦于以下问题:C++ PhpFile::unit方法的具体用法?C++ PhpFile::unit怎么用?C++ PhpFile::unit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PhpFile的用法示例。


在下文中一共展示了PhpFile::unit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: name

PhpFile *FileRepository::checkoutFile(StringData *rname,
                                      const struct stat &s) {
  FileInfo fileInfo;
  PhpFile *ret = nullptr;
  String name(rname);
  if (rname->data()[0] != '/') {
    name = String(SourceRootInfo::GetCurrentSourceRoot()) + name;
  }

  {
    // Get the common fast path out of the way with as little locking
    // as possible: it's in the map and has not changed on disk
    ParsedFilesMap::const_accessor acc;
    if (s_files.find(acc, name.get()) && !acc->second->isChanged(s)) {
      TRACE(1, "FR fast path hit %s\n", rname->data());
      ret = acc->second->getPhpFile();
      ret->incRef();
      return ret;
    }
  }

  TRACE(1, "FR fast path miss: %s\n", rname->data());
  bool interceptsEnabled = s_interceptsEnabled;
  const StringData *n = StringData::GetStaticString(name.get());
  ParsedFilesMap::accessor acc;
  bool isNew = s_files.insert(acc, n);
  assert(isNew || acc->second); // We don't leave null entries around.
  bool isChanged = !isNew && acc->second->isChanged(s);

  if (isNew || isChanged) {
    if (!readFile(n, s, fileInfo)) {
      // Be sure to get rid of the new reference to it.
      s_files.erase(acc);
      TRACE(1, "File disappeared between stat and FR::readNewFile: %s\n",
            rname->data());
      return nullptr;
    }
    ret = fileInfo.m_phpFile;
    if (isChanged && ret == acc->second->getPhpFile()) {
      // The file changed but had the same contents.
      if (debug && md5Enabled()) {
        ReadLock lock(s_md5Lock);
        assert(s_md5Files.find(ret->getMd5())->second == ret);
      }
      ret->incRef();
      return ret;
    }
  } else if (!isNew) {
    // Somebody might have loaded the file between when we dropped
    // our read lock and got the write lock
    ret = acc->second->getPhpFile();
    ret->incRef();
    return ret;
  }

  // If we get here the file was not in s_files or has changed on disk
  if (!ret) {
    // Try to read Unit from .hhbc repo.
    ret = readHhbc(n->data(), fileInfo);
  }
  if (!ret) {
    if (isAuthoritativeRepo()) {
      raise_error("Tried to parse %s in repo authoritative mode", n->data());
    }
    ret = parseFile(n->data(), fileInfo);
    if (!ret) {
      s_files.erase(acc);
      return nullptr;
    }
  }
  assert(ret != nullptr);

  if (isNew) {
    acc->second = new PhpFileWrapper(s, ret);
    ret->incRef();
    ret->setId(VM::Transl::TargetCache::allocBit());
  } else {
    PhpFile *f = acc->second->getPhpFile();
    if (f != ret) {
      ret->setId(f->getId());
      tx64->invalidateFile(f); // f has changed
    }
    f->decRefAndDelete();
    delete acc->second;
    acc->second = new PhpFileWrapper(s, ret);
    ret->incRef();
  }

  if (md5Enabled()) {
    WriteLock lock(s_md5Lock);
    // make sure intercepts are enabled for the functions within the
    // new units
    // Since we have the write lock on s_md5lock, s_interceptsEnabled
    // can't change, and we are serialized wrt enableIntercepts
    // (i.e., this will execute either before or after
    // enableIntercepts).
    if (interceptsEnabled != s_interceptsEnabled) {
      // intercepts were enabled since the time we created the unit
      ret->unit()->enableIntercepts();
    }
//.........这里部分代码省略.........
开发者ID:7755373049,项目名称:hiphop-php,代码行数:101,代码来源:file_repository.cpp


注:本文中的PhpFile::unit方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。