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


C++ ConstructPtr::getLocation方法代码示例

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


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

示例1: TestFunctionCall

bool TestDependGraph::TestFunctionCall() {
  // functions
  VD4(FunctionCall,
      "<?php include $_SERVER['PHP_ROOT'].'f2';\n test();",
      "<?php function test() {}",
      "test", "test()");
  VD4(FunctionCall,
      "<?php test(); function test() {}", "", "test", "test()");
  VD4(FunctionCall,
      "<?php function test() {} test();", "", "test", "test()");

  // methods
  VD4(FunctionCall,
      "<?php include $_SERVER['PHP_ROOT'].'f2';\n"
      "function test() { $a = new C(); $a->test();}",
      "<?php class C { public function test() {}}",
      "c::test", "$a->test()");
  VD4(FunctionCall,
      "<?php function test() { $a = new C(); $a->test();} "
      "class C { public function test() {}}",
      "", "c::test", "$a->test()");
  VD4(FunctionCall,
      "<?php class C { public function test() {}} "
      "function test() { $a = new C(); $a->test();}",
      "", "c::test", "$a->test()");

#ifdef HPHP_NOTE
  // making sure a "MasterCopy" marked function will always be used for
  // dependency's parent
  {
    Option::IncludeRoots["$_SERVER['PHP_ROOT']"] = "";
    AnalysisResultPtr ar(new AnalysisResult());
    BuiltinSymbols::Load(ar);
    Parser::ParseString("<?php function test() {}", ar, "f1");
    Parser::ParseString("<?php /*|MasterCopy|*/ function test() {}", ar, "f2");
    ar->analyzeProgram();
    ar->inferTypes();
    DependencyGraphPtr dg = ar->getDependencyGraph();
    ConstructPtr parent = dg->getParent(DependencyGraph::KindOfFunctionCall,
                                        "test");
    if (!parent || strcmp(parent->getLocation()->file, "f2") != 0) {
      printf("%s:%d: incorrect parent found at %s:%d\n", __FILE__, __LINE__,
             parent ? parent->getLocation()->file : "",
             parent ? parent->getLocation()->line0 : 0);
      return false;
    }
  }
#endif

  return true;
}
开发者ID:GunioRobot,项目名称:hiphop-php,代码行数:51,代码来源:test_depend_graph.cpp

示例2: CheckInclude

string IncludeExpression::CheckInclude(ConstructPtr includeExp,
                                       ExpressionPtr fileExp,
                                       bool &documentRoot) {
  string container = includeExp->getLocation()->file;
  string var, lit;
  parse_string_arg(fileExp, var, lit);
  if (lit.empty()) return lit;

  if (var == "__DIR__") {
    var = "";
    // get_include_file_path will check relative to the current file's dir
    // as long as the first char isn't a /
    if (lit[0] == '/') {
      lit = lit.substr(1);
    }
  }

  string included = get_include_file_path(container, var, lit, documentRoot);
  if (!included.empty()) {
    if (included == container) {
      Compiler::Error(Compiler::BadPHPIncludeFile, includeExp);
    }
    included = Util::canonicalize(included);
    if (!var.empty()) documentRoot = true;
  }
  return included;
}
开发者ID:360buyliulei,项目名称:hiphop-php,代码行数:27,代码来源:include_expression.cpp

示例3: add

string DependencyGraph::add(KindOf kindOf, ConstructPtr childExp,
                            ExpressionPtr parentExp, CodeErrorPtr codeError,
                            bool documentRoot /* = false */) {
  string child = childExp->getLocation()->file;
  string parent;

  switch (kindOf) {
  case KindOfPHPInclude:
    if (!checkInclude(childExp, parentExp, codeError,
                      documentRoot, child, parent)) {
      return "";
    }
    break;
  default:
    if (!m_hookHandler ||
        !m_hookHandler(this, kindOf, childExp, parentExp, codeError,
                       documentRoot, child, parent,
                       beforeDependencyGraphAdd)) {
      return "";
    }
    break;
  }

  string program; // no program is associated
  add(kindOf, program, child, childExp, parent, ConstructPtr(), codeError);

  if (m_hookHandler) {
    m_hookHandler(this, kindOf, childExp, parentExp, codeError,
                  documentRoot, child, parent, afterDependencyGraphAdd);
  }
  return parent;
}
开发者ID:Bittarman,项目名称:hiphop-php,代码行数:32,代码来源:dependency_graph.cpp

示例4: GetValue

ExpressionPtr Option::GetValue(VariableTablePtr variables,
                               const char *varName) {
  ConstructPtr decl = variables->getDeclaration(varName);
  if (!decl) {
    return ExpressionPtr();
  }

  AssignmentExpressionPtr assignment =
    dynamic_pointer_cast<AssignmentExpression>(decl);
  if (!assignment) {
    Logger::Error("Line %d: Ignored option %s", decl->getLocation()->line1,
                  varName);
    return ExpressionPtr();
  }

  return assignment->getValue();
}
开发者ID:Neomeng,项目名称:hiphop-php,代码行数:17,代码来源:option.cpp

示例5: checkInclude

bool DependencyGraph::checkInclude(ConstructPtr childExp,
                                   ExpressionPtr parentExp,
                                   CodeErrorPtr codeError,
                                   bool documentRoot,
                                   string &child,
                                   string &parent) {
  child = childExp->getLocation()->file;
  parent = parseInclude(child, parentExp, documentRoot);
  if ((parent.empty() || parent == child) &&
      Option::AllowedBadPHPIncludes.find(parentExp->getText()) ==
      Option::AllowedBadPHPIncludes.end()) {
    if (codeError) {
      codeError->record(CodeError::BadPHPIncludeFile, childExp);
    }
    return false;
  }
  if (parent.empty()) return false;
  return true;
}
开发者ID:Bittarman,项目名称:hiphop-php,代码行数:19,代码来源:dependency_graph.cpp

示例6: CheckInclude

string IncludeExpression::CheckInclude(ConstructPtr includeExp,
                                       ExpressionPtr fileExp,
                                       bool &documentRoot,
                                       bool relative) {
  string container = includeExp->getLocation()->file;
  string var, lit;
  parse_string_arg(fileExp, var, lit);
  if (lit.empty()) return lit;

  string included = get_include_file_path(container, var, lit,
                                          documentRoot, relative);
  if (!included.empty()) {
    if (included == container) {
      Compiler::Error(Compiler::BadPHPIncludeFile, includeExp);
    }
    included = Util::canonicalize(included);
    if (!var.empty()) documentRoot = true;
  }
  return included;
}
开发者ID:Ulkem,项目名称:hiphop-php,代码行数:20,代码来源:include_expression.cpp

示例7: CheckInclude

string IncludeExpression::CheckInclude(ConstructPtr includeExp,
                                       ExpressionPtr fileExp,
                                       bool documentRoot) {
  string container = includeExp->getLocation()->file;
  string var, lit;
  parse_string_arg(fileExp, var, lit);
  if (!lit.empty()) {
    if (!var.empty()) {
      var += " . ";
    }
    var += "'" + lit + "'";
  }

  string included = get_include_file_path(container, var, documentRoot);
  included = Util::canonicalize(included);
  if (included.empty() || container == included) {
    if (!included.empty() && included.find(' ') == string::npos) {
      Compiler::Error(Compiler::BadPHPIncludeFile, includeExp);
    }
    return "";
  }
  return included;
}
开发者ID:jahankhanna,项目名称:hiphop-php,代码行数:23,代码来源:include_expression.cpp


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