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


C++ ConstructPtr类代码示例

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


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

示例1: checkClassPresent

bool AnalysisResult::checkClassPresent(ConstructPtr cs,
                                       const std::string &name) const {
  if (name == "self" || name == "parent") return true;
  std::string lowerName = toLower(name);
  if (ClassScopePtr currentCls = cs->getClassScope()) {
    if (lowerName == currentCls->getName() ||
        currentCls->derivesFrom(shared_from_this(), lowerName,
                                true, false)) {
      return true;
    }
  }
  if (FileScopePtr currentFile = cs->getFileScope()) {
    StatementList &stmts = *currentFile->getStmt();
    for (int i = stmts.getCount(); i--; ) {
      StatementPtr s = stmts[i];
      if (s && s->is(Statement::KindOfClassStatement)) {
        ClassScopePtr scope =
          static_pointer_cast<ClassStatement>(s)->getClassScope();
        if (lowerName == scope->getName()) {
          return true;
        }
        if (scope->derivesFrom(shared_from_this(), lowerName,
                               true, false)) {
          return true;
        }
      }
    }
  }
  return false;
}
开发者ID:atdt,项目名称:hhvm,代码行数:30,代码来源:analysis_result.cpp

示例2: informClosuresAboutScopeClone

void ClassScope::informClosuresAboutScopeClone(
    ConstructPtr root,
    FunctionScopePtr outerScope,
    AnalysisResultPtr ar) {

  if (!root) {
    return;
  }

  for (int i = 0; i < root->getKidCount(); i++) {
    ConstructPtr cons = root->getNthKid(i);
    ClosureExpressionPtr closure =
      dynamic_pointer_cast<ClosureExpression>(cons);

    if (!closure) {
      informClosuresAboutScopeClone(cons, outerScope, ar);
      continue;
    }

    FunctionStatementPtr func = closure->getClosureFunction();
    HPHP::FunctionScopePtr funcScope = func->getFunctionScope();
    assert(funcScope->isClosure());
    funcScope->addClonedTraitOuterScope(outerScope);
    // Don't need to recurse
  }
}
开发者ID:orok,项目名称:hhvm,代码行数:26,代码来源:class_scope.cpp

示例3: analyzeProgram

void AnalysisResult::analyzeProgram(ConstructPtr c) const {
  if (!c) return;
  for (auto i = 0, n = c->getKidCount(); i < n; ++i) {
    analyzeProgram(c->getNthKid(i));
  }
  c->analyzeProgram(AnalysisResultConstRawPtr{this});
}
开发者ID:fredemmott,项目名称:hhvm,代码行数:7,代码来源:analysis_result.cpp

示例4: addHphpNote

void Parser::addHphpNote(ConstructPtr c, const std::string &note) {
  if (note[0] == '@') {
    CodeError::ErrorType e;
    if (CodeError::lookupErrorType(note.substr(1), e)) {
      c->addSuppressError(e);
    } else {
      c->addHphpNote(note);
    }
  } else {
    c->addHphpNote(note);
  }
}
开发者ID:scottmac,项目名称:hiphop-dev,代码行数:12,代码来源:parser.cpp

示例5: getNthKid

int Construct::getChildrenEffects() const {
  int childrenEffects = NoEffect;
  for (int i = getKidCount(); i--; ) {
    ConstructPtr child = getNthKid(i);
    if (child) {
      childrenEffects |= child->getContainedEffects();
      if ((childrenEffects & UnknownEffect) == UnknownEffect) {
        break;
      }
    }
  }
  return childrenEffects;
}
开发者ID:mayank245,项目名称:hiphop-php,代码行数:13,代码来源:construct.cpp

示例6: VD4

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

示例7: getNthKid

int Construct::getChildrenEffects() const {
  int childrenEffects = NoEffect;
  for (int i = getKidCount(); i--; ) {
    ConstructPtr child = getNthKid(i);
    if (child) {
      if (FunctionWalker::SkipRecurse(child)) continue;
      childrenEffects |= child->getContainedEffects();
      if ((childrenEffects & UnknownEffect) == UnknownEffect) {
        break;
      }
    }
  }
  return childrenEffects;
}
开发者ID:andyanx,项目名称:hhvm,代码行数:14,代码来源:construct.cpp

示例8: createNewLocalId

int CodeGenerator::createNewLocalId(ConstructPtr ar) {
  if (m_wrappedExpression[m_curStream]) {
    return m_localId[m_curStream]++;
  }
  FunctionScopePtr func = ar->getFunctionScope();
  if (func) {
    return func->nextInlineIndex();
  }
  FileScopePtr fs = ar->getFileScope();
  if (fs) {
    return createNewId(fs->getName());
  }
  return createNewId("");
}
开发者ID:Hywan,项目名称:hhvm,代码行数:14,代码来源:code_generator.cpp

示例9: createNewId

int CodeGenerator::createNewId(ConstructPtr cs) {
  FileScopePtr fs = cs->getFileScope();
  if (fs) {
    return createNewId(fs->getName());
  }
  return createNewId("");
}
开发者ID:Hywan,项目名称:hhvm,代码行数:7,代码来源:code_generator.cpp

示例10: 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

示例11: switch

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

示例12: 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

示例13: Error

void Error(ErrorType error, ConstructPtr construct) {
  if (hhvm) return;
  ErrorInfoPtr errorInfo(new ErrorInfo());
  errorInfo->m_error = error;
  errorInfo->m_construct1 = construct;
  errorInfo->m_data = construct->getText();
  s_code_errors.record(errorInfo);
}
开发者ID:AviMoto,项目名称:hiphop-php,代码行数:8,代码来源:code_error.cpp

示例14: ASSERT

void ClassConstantExpression::outputCPPImpl(CodeGenerator &cg,
                                            AnalysisResultPtr ar) {
  const char *globals = "g";
  if (cg.getContext() == CodeGenerator::CppParameterDefaultValueDecl ||
      cg.getContext() == CodeGenerator::CppParameterDefaultValueImpl) {
    globals = cg.getGlobals();
  }
  if (m_valid) {
    ClassScopePtr foundCls;
    string trueClassName;
    for (ClassScopePtr cls = ar->findClass(m_className);
         cls; cls = cls->getParentScope(ar)) {
      if (cls->getConstants()->isPresent(m_varName)) {
        foundCls = cls;
        trueClassName = cls->getName();
        break;
      }
    }
    ASSERT(!trueClassName.empty());
    ConstructPtr decl = foundCls->getConstants()->getValue(m_varName);
    if (decl) {
      decl->outputCPP(cg, ar);
      if (cg.getContext() == CodeGenerator::CppImplementation ||
          cg.getContext() == CodeGenerator::CppParameterDefaultValueImpl) {
        cg.printf("(%s::%s)", m_className.c_str(), m_varName.c_str());
      } else {
        cg.printf("/* %s::%s */", m_className.c_str(), m_varName.c_str());
      }
    } else {
      if (foundCls->getConstants()->isDynamic(m_varName)) {
        cg.printf("%s%s::lazy_initializer(%s)->", Option::ClassPrefix,
                  trueClassName.c_str(), globals);
      }
      cg.printf("%s%s_%s", Option::ClassConstantPrefix, trueClassName.c_str(),
                m_varName.c_str());
    }
  } else if (m_redeclared) {
    cg.printf("%s->%s%s->os_constant(\"%s\")", globals,
              Option::ClassStaticsObjectPrefix,
              m_className.c_str(), m_varName.c_str());
  } else {
    cg.printf("throw_fatal(\"unknown class constant %s::%s\")",
              m_className.c_str(), m_varName.c_str());
  }
}
开发者ID:Neomeng,项目名称:hiphop-php,代码行数:45,代码来源:class_constant_expression.cpp

示例15: Error

void Error(ErrorType error, ConstructPtr construct1, ConstructPtr construct2) {
  if (!Option::RecordErrors) return;
  ErrorInfoPtr errorInfo(new ErrorInfo());
  errorInfo->m_error = error;
  errorInfo->m_construct1 = construct1;
  errorInfo->m_construct2 = construct2;
  errorInfo->m_data = construct1->getText();
  s_code_errors.record(errorInfo);
}
开发者ID:1mr3yn,项目名称:hhvm,代码行数:9,代码来源:code_error.cpp


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