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


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

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


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

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

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

  void walk_ast(ConstructPtr node) {
    if (!node) return;

    if (dynamic_pointer_cast<MethodStatement>(node)) {
      // Don't descend into nested non-closure functions, or functions
      // in the psuedo-main.
      return;
    }

    if (auto ce = dynamic_pointer_cast<ClosureExpression>(node)) {
      visit_closure(ce);
      return;
    }

    for (int i = 0; i < node->getKidCount(); ++i) {
      walk_ast(node->getNthKid(i));
    }
  }
开发者ID:2bj,项目名称:hhvm,代码行数:18,代码来源:lambda_names.cpp

示例4: hasStaticLocalsImpl

bool ClosureExpression::hasStaticLocalsImpl(ConstructPtr root) {
  if (!root) {
    return false;
  }
  if (root->getFunctionScope() != m_func->getFunctionScope()) {
    // new scope, new statics
    return false;
  }

  for (int i = 0; i < root->getKidCount(); i++) {
    ConstructPtr cons = root->getNthKid(i);
    if (StatementPtr s = dynamic_pointer_cast<Statement>(cons)) {
      if (s->is(Statement::KindOfStaticStatement)) {
        return true;
      }
    }
    if (hasStaticLocalsImpl(cons)) {
      return true;
    }
  }
  return false;
}
开发者ID:JustProgrammer,项目名称:hiphop-php,代码行数:22,代码来源:closure_expression.cpp

示例5: walk_ast

  // Returns: whether or not $this is implicitly used in this part of the AST,
  // e.g. via a call using parent::.
  bool walk_ast(ConstructPtr node) {
    if (!node) return false;

    if (dynamic_pointer_cast<MethodStatement>(node)) {
      // Don't descend into nested non-closure functions, or functions
      // in the pseudo-main.
      return false;
    }

    if (auto ce = dynamic_pointer_cast<ClosureExpression>(node)) {
      return visit_closure(ce);
    }

    auto ret = false;
    if (auto fc = dynamic_pointer_cast<FunctionCall>(node)) {
      if (fc->isParent()) ret = true;
    }

    for (int i = 0; i < node->getKidCount(); ++i) {
      if (walk_ast(node->getNthKid(i))) ret = true;
    }

    return ret;
  }
开发者ID:nurulimamnotes,项目名称:hhvm,代码行数:26,代码来源:lambda_names.cpp

示例6: collectAliasInfoRecur

void AliasManager::collectAliasInfoRecur(ConstructPtr cs) {
  if (!cs) {
    return;
  }

  if (StatementPtr s = dpc(Statement, cs)) {
    switch (s->getKindOf()) {
      case Statement::KindOfFunctionStatement:
      case Statement::KindOfMethodStatement:
      case Statement::KindOfClassStatement:
      case Statement::KindOfInterfaceStatement:
        return;
      default:
        break;
    }
  }

  int nkid = cs->getKidCount();

  for (int i = 0; i < nkid; i++) {
    ConstructPtr kid = cs->getNthKid(i);
    if (kid) {
      collectAliasInfoRecur(kid);
    }
  }

  if (ExpressionPtr e = dpc(Expression, cs)) {
    int context = e->getContext();
    switch (e->getKindOf()) {
    case Expression::KindOfAssignmentExpression:
      {
        AssignmentExpressionPtr ae = spc(AssignmentExpression, e);
        ExpressionPtr var = ae->getVariable();
        ExpressionPtr val = ae->getValue();
        if (var->is(Expression::KindOfSimpleVariable)) {
          const std::string &name = spc(SimpleVariable, var)->getName();
          AliasInfo &ai = m_aliasInfo[name];
          if (val->getContext() & Expression::RefValue) {
            ai.setIsRefTo();
            m_variables->addUsed(name);
          } else {
            Expression::checkUsed(m_arp, var, val);
          }
        }
      }
      break;
    case Expression::KindOfListAssignment:
      {
        ListAssignmentPtr la = spc(ListAssignment, e);
        ExpressionListPtr vars = la->getVariables();
        for (int i = vars->getCount(); i--; ) {
          ExpressionPtr v = (*vars)[i];
          if (v && v->is(Expression::KindOfSimpleVariable)) {
            SimpleVariablePtr sv = spc(SimpleVariable, v);
            m_variables->addUsed(sv->getName());
          }
        }
      }
      break;
    case Expression::KindOfSimpleVariable:
      {
        const std::string &name = spc(SimpleVariable, e)->getName();
        if (context & Expression::RefValue) {
          AliasInfo &ai = m_aliasInfo[name];
          ai.addRefLevel(0);
        }
        if (!(context & (Expression::AssignmentLHS |
                         Expression::UnsetContext))) {
          m_variables->addUsed(name);
        }
      }
      break;
    case Expression::KindOfDynamicVariable:
      if (context & Expression::RefValue) {
        m_wildRefs = true;
      }
      break;
    case Expression::KindOfArrayElementExpression:
      {
        int n = 1;
        while (n < 10 &&
               e->is(Expression::KindOfArrayElementExpression)) {
          e = spc(ArrayElementExpression, e)->getVariable();
        }
        if (e->is(Expression::KindOfSimpleVariable)) {
          const std::string &name = spc(SimpleVariable, e)->getName();
          if (context & Expression::RefValue) {
            AliasInfo &ai = m_aliasInfo[name];
            ai.addRefLevel(n);
          }
          m_variables->addUsed(name); // need this for UnsetContext
        }
      }
      break;
    case Expression::KindOfObjectPropertyExpression:
      {
        e = spc(ObjectPropertyExpression, e)->getObject();
        if (e->is(Expression::KindOfSimpleVariable)) {
          const std::string &name = spc(SimpleVariable, e)->getName();
          if (context & Expression::RefValue) {
//.........这里部分代码省略.........
开发者ID:scottmac,项目名称:hiphop-dev,代码行数:101,代码来源:alias_manager.cpp


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