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


C++ AnalysisResultPtr::findFileScope方法代码示例

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


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

示例1: analyzeInclude

void IncludeExpression::analyzeInclude(AnalysisResultPtr ar,
                                       const std::string &include) {
  ASSERT(ar->getPhase() == AnalysisResult::AnalyzeInclude);
  ConstructPtr self = shared_from_this();
  FileScopePtr file = ar->findFileScope(include, true);
  if (!file) {
    ar->getCodeError()->record(self, CodeError::PHPIncludeFileNotFound, self);
    return;
  }
  if (include.find("compiler/") != 0 ||
      include.find("/compiler/") == string::npos) {
    ar->getCodeError()->record(self, CodeError::PHPIncludeFileNotInLib,
                               self, ConstructPtr(),
                               include.c_str());
  }

  if (!isFileLevel()) { // Not unsupported but potentially bad
    ar->getCodeError()->record(self, CodeError::UseDynamicInclude, self);
  }

  ar->getDependencyGraph()->add
    (DependencyGraph::KindOfProgramMaxInclude,
     ar->getName(), file->getName(), StatementPtr());
  ar->getDependencyGraph()->addParent
    (DependencyGraph::KindOfProgramMinInclude,
     ar->getName(), file->getName(), StatementPtr());
  FunctionScopePtr func = ar->getFunctionScope();
  ar->getFileScope()->addIncludeDependency(ar, m_include,
                                           func && func->isInlined());
}
开发者ID:edv4rd0,项目名称:hiphop-php,代码行数:30,代码来源:include_expression.cpp

示例2: analyzeInclude

void IncludeExpression::analyzeInclude(AnalysisResultPtr ar,
                                       const std::string &include) {
  ConstructPtr self = shared_from_this();
  FileScopePtr file = ar->findFileScope(include);
  if (!file && !include.empty()) {
    Compiler::Error(Compiler::PHPIncludeFileNotFound, self);
    return;
  }
  FunctionScopePtr func = getFunctionScope();
  getFileScope()->addIncludeDependency(ar, m_include,
                                       func && func->isInlined());
  if (func && file->getPseudoMain()) {
    file->getPseudoMain()->addUse(func, BlockScope::UseKindInclude);
  }
}
开发者ID:jahankhanna,项目名称:hiphop-php,代码行数:15,代码来源:include_expression.cpp

示例3: postOptimize

ExpressionPtr IncludeExpression::postOptimize(AnalysisResultPtr ar) {
  ar->postOptimize(m_exp);
  if (!m_include.empty()) {
    FileScopePtr fs = ar->findFileScope(m_include, false);
    if (fs) {
      if (!Option::KeepStatementsWithNoEffect && !fs->hasImpl(ar)) {
        return ScalarExpressionPtr
          (new ScalarExpression(getLocation(),
                                Expression::KindOfScalarExpression,
                                1));
      }
      m_exp.reset();
    }
  }
  return ExpressionPtr();
}
开发者ID:edv4rd0,项目名称:hiphop-php,代码行数:16,代码来源:include_expression.cpp

示例4: outputCPPImpl

void IncludeExpression::outputCPPImpl(CodeGenerator &cg,
                                      AnalysisResultPtr ar) {
  bool linemap = outputLineMap(cg, ar, true);

  // Includes aren't really supported in system mode
  if (cg.getOutput() == CodeGenerator::SystemCPP) {
    cg_printf("true");
    if (linemap) cg_printf(")");
    return;
  }
  const char *vars = m_privateScope ?
    "lvar_ptr(LVariableTable())" : "variables";
  bool require = (m_op == T_REQUIRE || m_op == T_REQUIRE_ONCE);
  bool once = (m_op == T_INCLUDE_ONCE || m_op == T_REQUIRE_ONCE);
  if (!getCurrentInclude(ar).empty()) {
    FileScopePtr fs = ar->findFileScope(getCurrentInclude(ar), false);
    if (fs) {
      cg_printf("%s%s(%s, %s)", Option::PseudoMainPrefix,
                fs->pseudoMainName().c_str(),
                once ? "true" : "false",
                vars);
      if (linemap) cg_printf(")");
      return;
    }
  }

  // include() and require() need containing file's directory
  string currentDir = "NULL";
  if (m_loc && m_loc->file && *m_loc->file) {
    string file = m_loc->file;
    size_t pos = file.rfind('/');
    if (pos != string::npos) {
      currentDir = '"';
      currentDir += file.substr(0, pos + 1);
      currentDir += '"';
    }
  }

  // fallback to dynamic include
  cg_printf("%s(", require ? "require" : "include");
  m_exp->outputCPP(cg, ar);
  cg_printf(", %s, %s, %s)",
            once ? "true" : "false",
            vars,
            currentDir.c_str());
  if (linemap) cg_printf(")");
}
开发者ID:GunioRobot,项目名称:hiphop-php,代码行数:47,代码来源:include_expression.cpp

示例5: postOptimize

ExpressionPtr IncludeExpression::postOptimize(AnalysisResultPtr ar) {
  if (!m_include.empty()) {
    if (!m_depsSet) {
      analyzeInclude(ar, m_include);
      m_depsSet = true;
    }
    FileScopePtr fs = ar->findFileScope(m_include);
    if (fs) {
      if (!Option::KeepStatementsWithNoEffect) {
        if (ExpressionPtr rep = fs->getEffectiveImpl(ar)) {
          recomputeEffects();
          return replaceValue(rep->clone());
        }
      }
      m_exp.reset();
    }
  }
  return ExpressionPtr();
}
开发者ID:jahankhanna,项目名称:hiphop-php,代码行数:19,代码来源:include_expression.cpp


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