Exemple #1
0
Unit* compile_string(const char* s,
                     size_t sz,
                     const char* fname /* = nullptr */) {
  auto const md5 = MD5{mangleSystemMd5(string_md5(folly::StringPiece{s, sz}))};
  if (auto u = Repo::get().loadUnit(fname ? fname : "", md5).release()) {
    return u;
  }
  // NB: fname needs to be long-lived if generating a bytecode repo because it
  // can be cached via a Location ultimately contained by ErrorInfo for printing
  // code errors.
  return g_hphp_compiler_parse(s, sz, md5, fname);
}
Exemple #2
0
Unit* compile_string(const char* s,
                     size_t sz,
                     const char* fname /* = nullptr */) {
  auto md5string = mangleSystemMd5(string_md5(s, sz));
  MD5 md5(md5string.c_str());
  Unit* u = Repo::get().loadUnit(fname ? fname : "", md5).release();
  if (u != nullptr) {
    return u;
  }
  // NB: fname needs to be long-lived if generating a bytecode repo because it
  // can be cached via a Location ultimately contained by ErrorInfo for printing
  // code errors.
  return g_hphp_compiler_parse(s, sz, md5, fname);
}
Exemple #3
0
Unit* compile_systemlib_string(const char* s, size_t sz, const char* fname) {
  if (RuntimeOption::RepoAuthoritative) {
    String systemName = String("/:") + fname;
    auto md5 = MD5{mangleSystemMd5(string_md5(folly::StringPiece{s,sz}))};
    if (Repo::get().findFile(systemName.data(),
                             SourceRootInfo::GetCurrentSourceRoot(),
                             md5)) {
      if (auto u = Repo::get().loadUnit(fname, md5)) {
        return u.release();
      }
    }
  }
  return compile_string(s, sz, fname);
}