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


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

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


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

示例1: build

void Dictionary::build(StatementPtr stmt) {
  for (int i = 0, n = stmt->getKidCount(); i < n; i++) {
    if (ConstructPtr kid = stmt->getNthKid(i)) {
      if (StatementPtr s = boost::dynamic_pointer_cast<Statement>(kid)) {
        if (FunctionWalker::SkipRecurse(s)) continue;
        build(s);
      } else {
        ExpressionPtr e = boost::dynamic_pointer_cast<Expression>(kid);
        build(e);
      }
    }
  }
}
开发者ID:524777134,项目名称:hiphop-php,代码行数:13,代码来源:dictionary.cpp

示例2: cloneStmtsForInline

static int cloneStmtsForInline(InlineCloneInfo &info, StatementPtr s,
                               const std::string &prefix,
                               AnalysisResultConstPtr ar,
                               FunctionScopePtr scope) {
  switch (s->getKindOf()) {
  case Statement::KindOfStatementList:
    {
      for (int i = 0, n = s->getKidCount(); i < n; ++i) {
        if (int ret = cloneStmtsForInline(info, s->getNthStmt(i),
                                          prefix, ar, scope)) {
          return ret;
        }
      }
      return 0;
    }
  case Statement::KindOfExpStatement:
    info.elist->addElement(cloneForInline(
                             info, dynamic_pointer_cast<ExpStatement>(s)->
                             getExpression(), prefix, ar, scope));
    return 0;
  case Statement::KindOfReturnStatement:
    {
      ExpressionPtr exp =
        dynamic_pointer_cast<ReturnStatement>(s)->getRetExp();

      if (exp) {
        exp = cloneForInline(info, exp, prefix, ar, scope);
        if (exp->hasContext(Expression::RefValue)) {
          exp->clearContext(Expression::RefValue);
          if (exp->isRefable()) exp->setContext(Expression::LValue);
        }
        info.elist->addElement(exp);
        return 1;
      }
      return -1;
    }
  default:
    not_reached();
  }
  return 1;
}
开发者ID:7755373049,项目名称:hiphop-php,代码行数:41,代码来源:function_call.cpp

示例3: build

void Dictionary::build(StatementPtr stmt) {
  for (int i = 0, n = stmt->getKidCount(); i < n; i++) {
    if (ConstructPtr kid = stmt->getNthKid(i)) {
      if (StatementPtr s = boost::dynamic_pointer_cast<Statement>(kid)) {
        switch (s->getKindOf()) {
          case Statement::KindOfFunctionStatement:
          case Statement::KindOfMethodStatement:
          case Statement::KindOfClassStatement:
          case Statement::KindOfInterfaceStatement:
            continue;
          default:
            break;
        }
        build(s);
      } else {
        ExpressionPtr e = boost::dynamic_pointer_cast<Expression>(kid);
        build(e);
      }
    }
  }
}
开发者ID:SimplProduction,项目名称:hiphop-php,代码行数:21,代码来源:dictionary.cpp

示例4: canonicalizeRecur

int AliasManager::canonicalizeRecur(StatementPtr s) {
  if (!s) return FallThrough;

  Statement::KindOf stype = s->getKindOf();
  int ret = FallThrough;
  int start = 0;

  switch (stype) {
  case Statement::KindOfFunctionStatement:
  case Statement::KindOfMethodStatement:
  case Statement::KindOfClassStatement:
  case Statement::KindOfInterfaceStatement:
    // Dont handle nested functions
    // they will be dealt with by another
    // top level call to optimize
    return ret;
  case Statement::KindOfStaticStatement:
    clear();
    ret = Converge;
    break;
  case Statement::KindOfClassVariable:
    clear();
    ret = Branch;
  case Statement::KindOfClassConstant:
  case Statement::KindOfGlobalStatement:
  case Statement::KindOfEchoStatement:
  case Statement::KindOfUnsetStatement:
  case Statement::KindOfExpStatement:
  case Statement::KindOfStatementList:
  case Statement::KindOfBlockStatement:
  case Statement::KindOfTryStatement:
    // No special action, just execute
    // and fall through
    break;

  case Statement::KindOfIfStatement:
    {
      StatementPtr iflist = spc(Statement, s->getNthKid(0));
      if (iflist) {
        for (int i = 0, n = iflist->getKidCount(); i < n; i++) {
          StatementPtr ifstmt = spc(Statement, iflist->getNthKid(i));
          ExpressionPtr cond = spc(Expression, ifstmt->getNthKid(0));
          canonicalizeKid(ifstmt, cond, 0);
          if (!i) beginScope();
          beginScope();
          canonicalizeRecur(spc(Statement, ifstmt->getNthKid(1)));
          endScope();
          if (i+1 < n) resetScope();
        }
        endScope();
      }
      ret = Converge;
      return FallThrough;
    }
    break;

  case Statement::KindOfIfBranchStatement:
    assert(0);
    break;

  case Statement::KindOfForStatement:
    canonicalizeKid(s, spc(Expression,s->getNthKid(0)), 0);
    clear();
    canonicalizeKid(s, spc(Expression,s->getNthKid(1)), 1);
    canonicalizeRecur(spc(Statement, s->getNthKid(2)));
    clear();
    canonicalizeKid(s, spc(Expression,s->getNthKid(3)), 3);
    return Converge;

  case Statement::KindOfWhileStatement:
  case Statement::KindOfDoStatement:
  case Statement::KindOfForEachStatement:
    clear();
    ret = Converge;
    break;

  case Statement::KindOfSwitchStatement:
    canonicalizeKid(s, spc(Expression,s->getNthKid(0)), 0);
    clear();
    start = 1;
    ret = Converge;
    break;

  case Statement::KindOfCaseStatement:
    clear();
    break;

  case Statement::KindOfBreakStatement:
  case Statement::KindOfContinueStatement:
  case Statement::KindOfReturnStatement:
    ret = Branch;
    break;

  case Statement::KindOfCatchStatement:
    clear();
    ret = Converge;
    break;

  case Statement::KindOfThrowStatement:
    ret = Branch;
//.........这里部分代码省略.........
开发者ID:scottmac,项目名称:hiphop-dev,代码行数:101,代码来源:alias_manager.cpp


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