Exemplo n.º 1
0
void Option::LoadRootHdf(const Hdf &roots, vector<string> &vec) {
  if (roots.exists()) {
    for (Hdf hdf = roots.firstChild(); hdf.exists(); hdf = hdf.next()) {
      vec.push_back(hdf.getString(""));
    }
  }
}
Exemplo n.º 2
0
void IpBlockMap::LoadIpList(hphp_string_map<bool> &ips, Hdf hdf, bool allow) {
  for (Hdf child = hdf.firstChild(); child.exists(); child = child.next()) {
    string ip = child.getString();
    size_t pos = ip.find('/');
    if (pos != string::npos) {
      ip = ip.substr(0, pos);
    }
    ips[ip] = allow;
  }
}
Exemplo n.º 3
0
static bool matchHdfPattern(const std::string &value, Hdf hdfPattern) {
  string pattern = hdfPattern.getString();
  if (!pattern.empty()) {
    Variant ret = preg_match(String(pattern.c_str(), pattern.size(),
                                    AttachLiteral),
                             String(value.c_str(), value.size(),
                                    AttachLiteral));
    if (ret.toInt64() <= 0) {
      return false;
    }
  }
  return true;
}
Exemplo n.º 4
0
void Hdf::lint(std::vector<std::string> &names,
               const char *excludePatternNode /* = "LintExcludePatterns" */,
               bool visited /* = false */) {
  std::vector<std::string> patterns;
  if (excludePatternNode && *excludePatternNode) {
    for (Hdf hdf = operator[](excludePatternNode).firstChild();
         hdf.exists(); hdf = hdf.next()) {
      std::string value = hdf.getString();
      if (!value.empty()) {
        patterns.push_back(value);
      }
    }
  }

  lintImpl(names, patterns, visited);
}
Exemplo n.º 5
0
void Extension::LoadModules(Hdf hdf) {
  // Load up any dynamic extensions
  std::string path = hdf["DynamicExtensionPath"].getString(".");
  for (Hdf ext = hdf["DynamicExtensions"].firstChild();
       ext.exists(); ext = ext.next()) {
    std::string extLoc = ext.getString();
    if (extLoc.empty()) {
      continue;
    }
    if (extLoc[0] != '/') {
      extLoc = path + "/" + extLoc;
    }

    // Extensions are self-registering,
    // so we bring in the SO then
    // throw away its handle.
    void *ptr = dlopen(extLoc.c_str());
    if (!ptr) {
      throw Exception("Could not open extension %s: %s",
                      extLoc.c_str(), dlerror());
    }
    auto getModule = (Extension *(*)())dlsym(ptr, "getModule");
    if (!getModule) {
      throw Exception("Could not load extension %s: %s (%s)",
                      extLoc.c_str(),
                      "getModule() symbol not defined.",
                      dlerror());
    }
    Extension *mod = getModule();
    if (mod->m_hhvmAPIVersion != HHVM_API_VERSION) {
      throw Exception("Could not use extension %s: "
                      "Compiled with HHVM API Version %" PRId64 ", "
                      "this version of HHVM expects %ld",
                      extLoc.c_str(),
                      mod->m_hhvmAPIVersion,
                      HHVM_API_VERSION);
    }
    mod->setDSOName(extLoc);
  }

  // Invoke Extension::moduleLoad() callbacks
  assert(s_registered_extensions);
  for (ExtensionMap::const_iterator iter = s_registered_extensions->begin();
       iter != s_registered_extensions->end(); ++iter) {
    iter->second->moduleLoad(hdf);
  }
}
Exemplo n.º 6
0
void IpBlockMap::LoadIpList(AclPtr acl, Hdf hdf, bool allow) {
  for (Hdf child = hdf.firstChild(); child.exists(); child = child.next()) {
    string ip = child.getString();

    unsigned int start, end;
    if (ReadIPv4Address(ip.c_str(), start, end)) {
      ASSERT(end >= start);
      if (end - start < 1024) {
        for (unsigned int i = start; i <= end; i++) {
          acl->ips[i] = allow;
        }
      } else {
        acl->ranges.resize(acl->ranges.size() + 1);
        IpRange &range = acl->ranges.back();
        range.start = start;
        range.end = end;
        range.allow = allow;
      }
    }
  }
}
Exemplo n.º 7
0
void Option::Load(Hdf &config) {
  LoadRootHdf(config["IncludeRoots"], IncludeRoots);
  LoadRootHdf(config["AutoloadRoots"], AutoloadRoots);

  config["PackageFiles"].get(PackageFiles);
  config["IncludeSearchPaths"].get(IncludeSearchPaths);
  config["PackageDirectories"].get(PackageDirectories);
  config["PackageExcludeDirs"].get(PackageExcludeDirs);
  config["PackageExcludeFiles"].get(PackageExcludeFiles);
  config["PackageExcludePatterns"].get(PackageExcludePatterns);
  config["PackageExcludeStaticDirs"].get(PackageExcludeStaticDirs);
  config["PackageExcludeStaticFiles"].get(PackageExcludeStaticFiles);
  config["PackageExcludeStaticPatterns"].get(PackageExcludeStaticPatterns);
  CachePHPFile = config["CachePHPFile"].getBool();

  config["ParseOnDemandDirs"].get(ParseOnDemandDirs);

  {
    Hdf cg = config["CodeGeneration"];
    string tmp;

#define READ_CG_OPTION(name)                    \
    tmp = cg[#name].getString();                \
    if (!tmp.empty()) {                         \
      name = OptionStrings.add(tmp.c_str());    \
    }

    READ_CG_OPTION(IdPrefix);
    READ_CG_OPTION(LabelEscape);
    READ_CG_OPTION(LambdaPrefix);
  }

  int count = 0;
  for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
       hdf = hdf.next()) {
    ++count;
  }
  SepExtensions.resize(count);
  count = 0;
  for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
       hdf = hdf.next()) {
    SepExtensionOptions &options = SepExtensions[count++];
    options.name = hdf.getName();
    options.soname = hdf["soname"].getString();
    options.include_path = hdf["include"].getString();
    options.lib_path = hdf["libpath"].getString();
    options.shared = hdf["shared"].getBool();
  }

  config["DynamicFunctionPrefix"].get(DynamicFunctionPrefixes);
  config["DynamicFunctionPostfix"].get(DynamicFunctionPostfixes);
  config["DynamicMethodPrefix"].get(DynamicMethodPrefixes);
  config["DynamicInvokeFunctions"].get(DynamicInvokeFunctions);
  config["VolatileClasses"].get(VolatileClasses);

  // build map from function names to sections
  for (Hdf hdf = config["FunctionSections"].firstChild(); hdf.exists();
       hdf = hdf.next()) {
    for (Hdf hdfFunc = hdf.firstChild(); hdfFunc.exists();
         hdfFunc = hdfFunc.next()) {
           FunctionSections[hdfFunc.getString()] = hdf.getName();
    }
  }

  {
    Hdf repo = config["Repo"];
    {
      Hdf repoCentral = repo["Central"];
      RepoCentralPath = repoCentral["Path"].getString();
    }
    RepoDebugInfo = repo["DebugInfo"].getBool(false);
  }

  {
    Hdf autoloadMap = config["AutoloadMap"];
    autoloadMap["class"].get(AutoloadClassMap);
    autoloadMap["function"].get(AutoloadFuncMap);
    autoloadMap["constant"].get(AutoloadConstMap);
    AutoloadRoot = autoloadMap["root"].getString();
  }

  HardTypeHints = config["HardTypeHints"].getBool(true);

  EnableHipHopSyntax = config["EnableHipHopSyntax"].getBool();
  JitEnableRenameFunction = config["JitEnableRenameFunction"].getBool();
  EnableHipHopExperimentalSyntax =
    config["EnableHipHopExperimentalSyntax"].getBool();
  EnableShortTags = config["EnableShortTags"].getBool(true);

  EnableAspTags = config["EnableAspTags"].getBool();

  EnableXHP = config["EnableXHP"].getBool(true);

  ParserThreadCount = config["ParserThreadCount"].getInt32(0);
  if (ParserThreadCount <= 0) {
    ParserThreadCount = Process::GetCPUCount();
  }

  EnableFinallyStatement = config["EnableFinallyStatement"].getBool();

  EnableEval = (EvalLevel)config["EnableEval"].getByte(0);
  AllDynamic = config["AllDynamic"].getBool(true);
  AllVolatile = config["AllVolatile"].getBool();

  GenerateCppLibCode       = config["GenerateCppLibCode"].getBool(false);
  GenerateSourceInfo       = config["GenerateSourceInfo"].getBool(false);
  GenerateDocComments      = config["GenerateDocComments"].getBool(true);
  UseVirtualDispatch       = config["UseVirtualDispatch"].getBool(false);
  EliminateDeadCode        = config["EliminateDeadCode"].getBool(true);
  CopyProp                 = config["CopyProp"].getBool(false);
  LocalCopyProp            = config["LocalCopyProp"].getBool(true);
  StringLoopOpts           = config["StringLoopOpts"].getBool(true);
  AutoInline               = config["AutoInline"].getInt32(0);
  ControlFlow              = config["ControlFlow"].getBool(true);
  VariableCoalescing       = config["VariableCoalescing"].getBool(false);
  ArrayAccessIdempotent    = config["ArrayAccessIdempotent"].getBool(false);
  DumpAst                  = config["DumpAst"].getBool(false);
  WholeProgram             = config["WholeProgram"].getBool(true);

  if (m_hookHandler) m_hookHandler(config);

  OnLoad();
}
Exemplo n.º 8
0
void Hdf::get(hphp_string_imap<std::string> &values) const {
  values.clear();
  for (Hdf hdf = firstChild(); hdf.exists(); hdf = hdf.next()) {
    values[hdf.getName()] = hdf.getString("");
  }
}
Exemplo n.º 9
0
void Hdf::get(std::set<std::string, stdltistr> &values) const {
  values.clear();
  for (Hdf hdf = firstChild(); hdf.exists(); hdf = hdf.next()) {
    values.insert(hdf.getString(""));
  }
}
Exemplo n.º 10
0
void Hdf::get(boost::container::flat_set<std::string> &values) const {
  values.clear();
  for (Hdf hdf = firstChild(); hdf.exists(); hdf = hdf.next()) {
    values.insert(hdf.getString(""));
  }
}
Exemplo n.º 11
0
void Hdf::get(std::vector<std::string> &values) const {
  values.clear();
  for (Hdf hdf = firstChild(); hdf.exists(); hdf = hdf.next()) {
    values.push_back(hdf.getString(""));
  }
}
Exemplo n.º 12
0
void SourceRootInfo::createFromUserConfig() {
  String homePath = String(RuntimeOption::SandboxHome) + "/" + m_user + "/";
  {
    struct stat hstat;
    if (stat(homePath.c_str(), &hstat) != 0) {
      if (!RuntimeOption::SandboxFallback.empty()) {
        homePath = String(RuntimeOption::SandboxFallback) + "/" + m_user + "/";
        if (stat(homePath.c_str(), &hstat) != 0) {
          m_sandboxCond = SandboxOff;
          return;
        }
      }
    }
  }

  string confpath = string(homePath.c_str()) +
    RuntimeOption::SandboxConfFile;
  Hdf config, serverVars;
  String sp, lp, alp, userOverride;
  try {
    config.open(confpath);
    userOverride = config["user_override"].get();
    Hdf sboxConf = config[m_sandbox.c_str()];
    if (sboxConf.exists()) {
      sp = sboxConf["path"].get();
      lp = sboxConf["log"].get();
      alp = sboxConf["accesslog"].get();
      serverVars = sboxConf["ServerVars"];
    }
  } catch (HdfException &e) {
    Logger::Error("%s ignored: %s", confpath.c_str(),
                  e.getMessage().c_str());
  }
  if (serverVars.exists()) {
    for (Hdf hdf = serverVars.firstChild(); hdf.exists(); hdf = hdf.next()) {
      m_serverVars.set(String(hdf.getName()), String(hdf.getString()));
    }
  }
  if (!userOverride.empty()) {
    m_user = std::move(userOverride);
  }
  if (m_sandbox == "default") {
    if (sp.isNull()) {
      sp = "www/";
    }
  }
  if (sp.isNull()) {
    m_sandboxCond = SandboxError;
    return;
  }
  if (sp.charAt(0) == '/') {
    m_path = std::move(sp);
  } else {
    m_path = homePath + sp;
  }
  if (m_path.charAt(m_path.size() - 1) != '/') {
    m_path += "/";
  }
  if (!lp.isNull()) {
    if (lp.charAt(0) != '/') {
      lp = homePath + lp;
    }
    if (!Logger::SetThreadLog(lp.c_str())) {
      Logger::Warning("Sandbox error log %s could not be opened",
                      lp.c_str());
    }
  }
  if (!alp.isNull()) {
    if (alp.charAt(0) != '/') {
      alp = homePath + alp;
    }
    if (!HttpRequestHandler::GetAccessLog().setThreadLog(alp.c_str())) {
      Logger::Warning("Sandbox access log %s could not be opened",
                      alp.c_str());
    }
  }
}
Exemplo n.º 13
0
void Option::Load(Hdf &config) {
  LoadRootHdf(config["IncludeRoots"], IncludeRoots);
  LoadRootHdf(config["AutoloadRoots"], AutoloadRoots);

  config["PackageFiles"].get(PackageFiles);
  config["IncludeSearchPaths"].get(IncludeSearchPaths);
  config["PackageDirectories"].get(PackageDirectories);
  config["PackageExcludeDirs"].get(PackageExcludeDirs);
  config["PackageExcludeFiles"].get(PackageExcludeFiles);
  config["PackageExcludePatterns"].get(PackageExcludePatterns);
  config["PackageExcludeStaticDirs"].get(PackageExcludeStaticDirs);
  config["PackageExcludeStaticFiles"].get(PackageExcludeStaticFiles);
  config["PackageExcludeStaticPatterns"].get(PackageExcludeStaticPatterns);
  CachePHPFile = config["CachePHPFile"].getBool();

  config["ParseOnDemandDirs"].get(ParseOnDemandDirs);

  {
    Hdf cg = config["CodeGeneration"];
    string tmp;

#define READ_CG_OPTION(name)                    \
    tmp = cg[#name].getString();                \
    if (!tmp.empty()) {                         \
      name = OptionStrings.add(tmp.c_str());    \
    }

    READ_CG_OPTION(IdPrefix);
    READ_CG_OPTION(LabelEscape);
    READ_CG_OPTION(LambdaPrefix);
    READ_CG_OPTION(FunctionPrefix);
    READ_CG_OPTION(BuiltinFunctionPrefix);
    READ_CG_OPTION(InvokePrefix);
    READ_CG_OPTION(CreateObjectPrefix);
    READ_CG_OPTION(PseudoMainPrefix);
    READ_CG_OPTION(VariablePrefix);
    READ_CG_OPTION(GlobalVariablePrefix);
    READ_CG_OPTION(StaticVariablePrefix);
    READ_CG_OPTION(ScalarArrayName);
    READ_CG_OPTION(SystemScalarArrayName);
    READ_CG_OPTION(ClassPrefix);
    READ_CG_OPTION(ClassStaticsPrefix);
    READ_CG_OPTION(ClassStaticsObjectPrefix);
    READ_CG_OPTION(ClassStaticsCallbackPrefix);
    READ_CG_OPTION(ClassStaticsIdGetterPrefix);
    READ_CG_OPTION(ClassStaticInitializerPrefix);
    READ_CG_OPTION(ClassStaticInitializerFlagPrefix);
    READ_CG_OPTION(ClassWrapperFunctionPrefix);
    READ_CG_OPTION(ObjectPrefix);
    READ_CG_OPTION(ObjectStaticPrefix);
    READ_CG_OPTION(SmartPtrPrefix);
    READ_CG_OPTION(MethodPrefix);
    READ_CG_OPTION(MethodWrapperPrefix);
    READ_CG_OPTION(MethodImplPrefix);
    READ_CG_OPTION(PropertyPrefix);
    READ_CG_OPTION(StaticPropertyPrefix);
    READ_CG_OPTION(ConstantPrefix);
    READ_CG_OPTION(ClassConstantPrefix);
    READ_CG_OPTION(ExceptionPrefix);
    READ_CG_OPTION(TempVariablePrefix);
    READ_CG_OPTION(EvalOrderTempPrefix);
    READ_CG_OPTION(SilencerPrefix);
    READ_CG_OPTION(EvalInvokePrefix);
    READ_CG_OPTION(TempPrefix);
    READ_CG_OPTION(MapPrefix);
    READ_CG_OPTION(IterPrefix);
    READ_CG_OPTION(InitPrefix);
    READ_CG_OPTION(FFIFnPrefix);
    READ_CG_OPTION(SystemFilePrefix);
    READ_CG_OPTION(UserFilePrefix);
    READ_CG_OPTION(ClassHeaderPrefix);
    READ_CG_OPTION(ClusterPrefix);
    READ_CG_OPTION(FFIFilePrefix);
  }

  int count = 0;
  for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
       hdf = hdf.next()) {
    ++count;
  }
  SepExtensions.resize(count);
  count = 0;
  for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
       hdf = hdf.next()) {
    SepExtensionOptions &options = SepExtensions[count++];
    options.name = hdf.getName();
    options.soname = hdf["soname"].getString();
    options.include_path = hdf["include"].getString();
    options.lib_path = hdf["libpath"].getString();
    options.shared = hdf["shared"].getBool();
  }

  config["DynamicFunctionPrefix"].get(DynamicFunctionPrefixes);
  config["DynamicFunctionPostfix"].get(DynamicFunctionPostfixes);
  config["DynamicMethodPrefix"].get(DynamicMethodPrefixes);
  config["DynamicInvokeFunctions"].get(DynamicInvokeFunctions);
  config["VolatileClasses"].get(VolatileClasses);

  // build map from function names to sections
  for (Hdf hdf = config["FunctionSections"].firstChild(); hdf.exists();
       hdf = hdf.next()) {
    for (Hdf hdfFunc = hdf.firstChild(); hdfFunc.exists();
         hdfFunc = hdfFunc.next()) {
           FunctionSections[hdfFunc.getString()] = hdf.getName();
    }
  }

  ScalarArrayFileCount = config["ScalarArrayFileCount"].getByte(1);
  if (ScalarArrayFileCount <= 0) ScalarArrayFileCount = 1;
  LiteralStringFileCount = config["LiteralStringFileCount"].getInt32(10);
  if (LiteralStringFileCount <= 0) LiteralStringFileCount = 10;
  HardTypeHints = config["HardTypeHints"].getBool(true);
  ScalarArrayOverflowLimit = config["ScalarArrayOverflowLimit"].getInt32(2000);
  if (ScalarArrayOverflowLimit <= 0) ScalarArrayOverflowLimit = 2000;
  if (UseNamedScalarArray) {
    ScalarArrayOptimization = true;
    ScalarArrayCompression = true;
  }

  EnableShortTags = config["EnableShortTags"].getBool(true);
  if (EnableShortTags) ScannerType |= Scanner::AllowShortTags;
  else ScannerType &= ~Scanner::AllowShortTags;

  EnableAspTags = config["EnableAspTags"].getBool();
  if (EnableAspTags) ScannerType |= Scanner::AllowAspTags;
  else ScannerType &= ~Scanner::AllowAspTags;

  EnableXHP = config["EnableXHP"].getBool();
  if (EnableXHP) ScannerType |= Scanner::PreprocessXHP;
  else ScannerType &= ~Scanner::PreprocessXHP;

  ParserThreadCount = config["ParserThreadCount"].getInt32(0);
  if (ParserThreadCount <= 0) {
    ParserThreadCount = Process::GetCPUCount() * 2;
  }

  RTTIOutputFile = config["RTTIOutputFile"].getString();
  EnableEval = (EvalLevel)config["EnableEval"].getByte(0);
  AllDynamic = config["AllDynamic"].getBool(true);
  AllVolatile = config["AllVolatile"].getBool();

  GenerateCppLibCode = config["GenerateCppLibCode"].getBool(false);
  GenerateSourceInfo = config["GenerateSourceInfo"].getBool(false);
  GenerateDocComments = config["GenerateDocComments"].getBool(true);
  UseVirtualDispatch = config["UseVirtualDispatch"].getBool(false);
  EliminateDeadCode  = config["EliminateDeadCode"].getBool(true);
  LocalCopyProp      = config["LocalCopyProp"].getBool(true);
  StringLoopOpts     = config["StringLoopOpts"].getBool(true);
  AutoInline         = config["AutoInline"].getBool(false);

  if (m_hookHandler) m_hookHandler(config);

  OnLoad();
}
Exemplo n.º 14
0
void Option::Load(Hdf &config) {
  LoadRootHdf(config["IncludeRoots"], IncludeRoots);
  LoadRootHdf(config["AutoloadRoots"], AutoloadRoots);

  config["PackageFiles"].get(PackageFiles);
  config["IncludeSearchPaths"].get(IncludeSearchPaths);
  config["PackageDirectories"].get(PackageDirectories);
  config["PackageExcludeDirs"].get(PackageExcludeDirs);
  config["PackageExcludeFiles"].get(PackageExcludeFiles);
  config["PackageExcludePatterns"].get(PackageExcludePatterns);
  config["PackageExcludeStaticDirs"].get(PackageExcludeStaticDirs);
  config["PackageExcludeStaticFiles"].get(PackageExcludeStaticFiles);
  config["PackageExcludeStaticPatterns"].get(PackageExcludeStaticPatterns);
  CachePHPFile = config["CachePHPFile"].getBool();

  config["ParseOnDemandDirs"].get(ParseOnDemandDirs);

  {
    Hdf cg = config["CodeGeneration"];
    string tmp;

#define READ_CG_OPTION(name)                    \
    tmp = cg[#name].getString();                \
    if (!tmp.empty()) {                         \
      name = OptionStrings.add(tmp.c_str());    \
    }

    READ_CG_OPTION(IdPrefix);
    READ_CG_OPTION(LabelEscape);
    READ_CG_OPTION(LambdaPrefix);
  }

  config["DynamicFunctionPrefix"].get(DynamicFunctionPrefixes);
  config["DynamicFunctionPostfix"].get(DynamicFunctionPostfixes);
  config["DynamicMethodPrefix"].get(DynamicMethodPrefixes);
  config["DynamicInvokeFunctions"].get(DynamicInvokeFunctions);
  config["VolatileClasses"].get(VolatileClasses);

  // build map from function names to sections
  for (Hdf hdf = config["FunctionSections"].firstChild(); hdf.exists();
       hdf = hdf.next()) {
    for (Hdf hdfFunc = hdf.firstChild(); hdfFunc.exists();
         hdfFunc = hdfFunc.next()) {
           FunctionSections[hdfFunc.getString()] = hdf.getName();
    }
  }

  {
    Hdf repo = config["Repo"];
    {
      Hdf repoCentral = repo["Central"];
      RepoCentralPath = repoCentral["Path"].getString();
    }
    RepoDebugInfo = repo["DebugInfo"].getBool(false);
  }

  {
    Hdf autoloadMap = config["AutoloadMap"];
    autoloadMap["class"].get(AutoloadClassMap);
    autoloadMap["function"].get(AutoloadFuncMap);
    autoloadMap["constant"].get(AutoloadConstMap);
    AutoloadRoot = autoloadMap["root"].getString();
  }

  HardTypeHints = config["HardTypeHints"].getBool(true);

  EnableHipHopSyntax = config["EnableHipHopSyntax"].getBool();
  EnableZendCompat = config["EnableZendCompat"].getBool();
  JitEnableRenameFunction = config["JitEnableRenameFunction"].getBool();
  EnableHipHopExperimentalSyntax =
    config["EnableHipHopExperimentalSyntax"].getBool();
  EnableShortTags = config["EnableShortTags"].getBool(true);

  EnableAspTags = config["EnableAspTags"].getBool();

  EnableXHP = config["EnableXHP"].getBool(false);

  if (EnableHipHopSyntax) {
    // If EnableHipHopSyntax is true, it forces EnableXHP to true
    // regardless of how it was set in the config
    EnableXHP = true;
  }

  ParserThreadCount = config["ParserThreadCount"].getInt32(0);
  if (ParserThreadCount <= 0) {
    ParserThreadCount = Process::GetCPUCount();
  }

  EnableFinallyStatement = config["EnableFinallyStatement"].getBool();

  EnableEval = (EvalLevel)config["EnableEval"].getByte(0);
  AllDynamic = config["AllDynamic"].getBool(true);
  AllVolatile = config["AllVolatile"].getBool();

  GenerateDocComments      = config["GenerateDocComments"].getBool(true);
  EliminateDeadCode        = config["EliminateDeadCode"].getBool(true);
  CopyProp                 = config["CopyProp"].getBool(false);
  LocalCopyProp            = config["LocalCopyProp"].getBool(true);
  StringLoopOpts           = config["StringLoopOpts"].getBool(true);
  AutoInline               = config["AutoInline"].getInt32(0);
  ControlFlow              = config["ControlFlow"].getBool(true);
  VariableCoalescing       = config["VariableCoalescing"].getBool(false);
  ArrayAccessIdempotent    = config["ArrayAccessIdempotent"].getBool(false);
  DumpAst                  = config["DumpAst"].getBool(false);
  WholeProgram             = config["WholeProgram"].getBool(true);
  UseHHBBC                 = config["UseHHBBC"].getBool(UseHHBBC);

  // Temporary, during file-cache migration.
  FileCache::UseNewCache   = config["UseNewCache"].getBool(false);

  if (m_hookHandler) m_hookHandler(config);

  OnLoad();
}
Exemplo n.º 15
0
void Option::Load(Hdf &config) {
    LoadRootHdf(config["IncludeRoots"], IncludeRoots);
    LoadRootHdf(config["AutoloadRoots"], AutoloadRoots);

    config["IncludeSearchPaths"].get(IncludeSearchPaths);
    config["PackageDirectories"].get(PackageDirectories);
    config["PackageExcludeDirs"].get(PackageExcludeDirs);
    config["PackageExcludeFiles"].get(PackageExcludeFiles);

    config["PackageExcludeStaticFiles"].get(PackageExcludeStaticFiles);
    CachePHPFile = config["CachePHPFile"].getBool();

    {
        Hdf cg = config["CodeGeneration"];
        string tmp;

#define READ_CG_OPTION(name)                    \
    tmp = cg[#name].getString();                \
    if (!tmp.empty()) {                         \
      name = OptionStrings.add(tmp.c_str());    \
    }

        READ_CG_OPTION(IdPrefix);
        READ_CG_OPTION(LambdaPrefix);
        READ_CG_OPTION(FunctionPrefix);
        READ_CG_OPTION(BuiltinFunctionPrefix);
        READ_CG_OPTION(InvokePrefix);
        READ_CG_OPTION(CreateObjectPrefix);
        READ_CG_OPTION(PseudoMainPrefix);
        READ_CG_OPTION(VariablePrefix);
        READ_CG_OPTION(GlobalVariablePrefix);
        READ_CG_OPTION(StaticVariablePrefix);
        READ_CG_OPTION(ScalarArrayName);
        READ_CG_OPTION(SystemScalarArrayName);
        READ_CG_OPTION(ClassPrefix);
        READ_CG_OPTION(ClassStaticsPrefix);
        READ_CG_OPTION(ClassStaticsObjectPrefix);
        READ_CG_OPTION(ClassStaticsIdGetterPrefix);
        READ_CG_OPTION(ClassStaticInitializerPrefix);
        READ_CG_OPTION(ClassStaticInitializerFlagPrefix);
        READ_CG_OPTION(ClassWrapperFunctionPrefix);
        READ_CG_OPTION(ObjectPrefix);
        READ_CG_OPTION(ObjectStaticPrefix);
        READ_CG_OPTION(SmartPtrPrefix);
        READ_CG_OPTION(MethodPrefix);
        READ_CG_OPTION(MethodImplPrefix);
        READ_CG_OPTION(PropertyPrefix);
        READ_CG_OPTION(StaticPropertyPrefix);
        READ_CG_OPTION(ConstantPrefix);
        READ_CG_OPTION(ClassConstantPrefix);
        READ_CG_OPTION(ExceptionPrefix);
        READ_CG_OPTION(TempVariablePrefix);
        READ_CG_OPTION(EvalOrderTempPrefix);
        READ_CG_OPTION(SilencerPrefix);
        READ_CG_OPTION(EvalInvokePrefix);
        READ_CG_OPTION(TempPrefix);
        READ_CG_OPTION(MapPrefix);
        READ_CG_OPTION(IterPrefix);
        READ_CG_OPTION(InitPrefix);
        READ_CG_OPTION(FFIFnPrefix);
        READ_CG_OPTION(SystemFilePrefix);
        READ_CG_OPTION(UserFilePrefix);
        READ_CG_OPTION(ClassHeaderPrefix);
        READ_CG_OPTION(ClusterPrefix);
        READ_CG_OPTION(FFIFilePrefix);
    }

    int count = 0;
    for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
            hdf = hdf.next()) {
        ++count;
    }
    SepExtensions.resize(count);
    count = 0;
    for (Hdf hdf = config["SepExtensions"].firstChild(); hdf.exists();
            hdf = hdf.next()) {
        SepExtensionOptions &options = SepExtensions[count++];
        options.name = hdf.getName();
        options.soname = hdf["soname"].getString();
        options.include_path = hdf["include"].getString();
        options.lib_path = hdf["libpath"].getString();
        options.shared = hdf["shared"].getBool();
    }

    config["DynamicFunctionPrefix"].get(DynamicFunctionPrefixes);
    config["DynamicFunctionPostfix"].get(DynamicFunctionPostfixes);
    config["DynamicMethodPrefix"].get(DynamicMethodPrefixes);
    config["DynamicInvokeFunctions"].get(DynamicInvokeFunctions);
    config["VolatileClasses"].get(VolatileClasses);

    // build map from function names to sections
    for (Hdf hdf = config["FunctionSections"].firstChild(); hdf.exists();
            hdf = hdf.next()) {
        for (Hdf hdfFunc = hdf.firstChild(); hdfFunc.exists();
                hdfFunc = hdfFunc.next()) {
            FunctionSections[hdfFunc.getString()] = hdf.getName();
        }
    }

    ScalarArrayFileCount = config["ScalarArrayFileCount"].getByte(1);
    if (ScalarArrayFileCount <= 0) ScalarArrayFileCount = 1;
    LiteralStringFileCount = config["LiteralStringFileCount"].getInt32(1);
    if (LiteralStringFileCount <= 0) LiteralStringFileCount = 1;
    ScalarArrayOverflowLimit = config["ScalarArrayOverflowLimit"].getInt32(2000);
    if (ScalarArrayOverflowLimit <= 0) ScalarArrayOverflowLimit = 2000;
    FlibDirectory = config["FlibDirectory"].getString();
    EnableXHP = config["EnableXHP"].getBool();
    RTTIOutputFile = config["RTTIOutputFile"].getString();
    EnableEval = (EvalLevel)config["EnableEval"].getByte(0);
    AllDynamic = config["AllDynamic"].getBool(true);
    AllVolatile = config["AllVolatile"].getBool();

    GenerateSourceInfo = config["GenerateSourceInfo"].getBool(false);
    UseVirtualDispatch = config["UseVirtualDispatch"].getBool(false);

    OnLoad();
}