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


C++ ArrayPairExpressionPtr::isRef方法代码示例

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


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

示例1: outputCPPInternal

bool ExpressionList::outputCPPInternal(CodeGenerator &cg,
                                       AnalysisResultPtr ar,
                                       bool needed, bool pre) {
  bool needsComma = false;
  bool anyOutput = false;
  if (m_arrayElements) {
    bool isVector = true;
    for (unsigned int i = 0; i < m_exps.size(); i++) {
      ArrayPairExpressionPtr ap =
        dynamic_pointer_cast<ArrayPairExpression>(m_exps[i]);
      if (ap->getName()) {
        isVector = false;
        break;
      }
    }
    if (outputCPPArrayCreate(cg, ar, isVector, pre)) return true;
    cg_printf("ArrayInit");
    if (pre) {
      cg_printf(" %s", m_cppTemp.c_str());
    }
    cg_printf("(%d)", (int)m_exps.size());
    if (pre) cg_printf(";\n");
    needsComma = true;
    anyOutput = true;
  }

  bool trailingComma = false;
  unsigned i = 0, s = m_exps.size();
  unsigned ix = m_kind == ListKindLeft ? 0 : s - 1;
  bool uniqueStringKeys =
    m_arrayElements && (checkLitstrKeys() == s); // TODO integer keys as well
  for ( ; i < s; i++) {
    if (ExpressionPtr exp = m_exps[i]) {
      if (pre) {
        exp->preOutputCPP(cg, ar, 0);
        cg_printf("%s", m_cppTemp.c_str());
      }
      if (needsComma) {
        cg_printf(m_arrayElements ? "." : ", ");
        trailingComma = true;
      }
      if (m_arrayElements) {
        ArrayPairExpressionPtr ap =
          dynamic_pointer_cast<ArrayPairExpression>(exp);
        if (ap->isRef()) {
          cg_printf("setRef(");
          // The value itself shouldn't be wrapped with ref() any more.
          ap->getValue()->setContext(NoRefWrapper);
        } else {
          cg_printf(uniqueStringKeys ? "add(" : "set(");
        }
        exp->outputCPP(cg, ar);
        cg_printf(")");
        if (pre) {
          cg_printf(";\n");
        }
        needsComma = true;
      } else if (m_kind != ListKindParam && (i != ix || !needed)) {
        needsComma = exp->outputCPPUnneeded(cg, ar);
      } else {
        bool wrap =
          exp->hasCPPTemp() &&
          hasContext(LValue) && !hasAnyContext(RefValue|InvokeArgument) &&
            !(exp->hasContext(LValue) &&
              !exp->hasAnyContext(RefValue|InvokeArgument));
        if (wrap) cg_printf("const_cast<Variant&>(");
        bool noRef = !exp->hasCPPTemp() &&
          hasContext(RefValue) &&
          !exp->hasAllContext(LValue|ReturnContext) &&
          !exp->hasContext(RefValue) &&
          !exp->isTemporary() &&
          Type::IsMappedToVariant(exp->getActualType());
        if (noRef) cg_printf("wrap_variant(");
        exp->outputCPP(cg, ar);
        if (noRef) cg_printf(")");
        if (wrap) cg_printf(")");
        needsComma = true;
      }
      if (needsComma) {
        trailingComma = false;
        anyOutput = true;
      }
    }
  }
  if (trailingComma) {
    cg_printf("id(0)");
  }
  if (m_arrayElements && !pre) {
    cg_printf(".create()");
    anyOutput = true;
  }
  return anyOutput;
}
开发者ID:DenisBazhan,项目名称:hiphop-php,代码行数:93,代码来源:expression_list.cpp

示例2: outputCPPInternal

bool ExpressionList::outputCPPInternal(CodeGenerator &cg,
                                       AnalysisResultPtr ar,
                                       bool needed, bool pre) {
  bool needsComma = false;
  bool anyOutput = false;
  if (m_arrayElements) {
    bool isVector = true;
    for (unsigned int i = 0; i < m_exps.size(); i++) {
      ArrayPairExpressionPtr ap =
        dynamic_pointer_cast<ArrayPairExpression>(m_exps[i]);
      if (ap->getName()) {
        isVector = false;
        break;
      }
    }
    if (outputCPPArrayCreate(cg, ar, isVector, pre)) return true;
    cg_printf("ArrayInit");
    if (pre) {
      cg_printf(" %s", m_cppTemp.c_str());
    }
    cg_printf("(%d, %s)", m_exps.size(), isVector ? "true" : "false");
    if (pre) cg_printf(";\n");
    needsComma = true;
    anyOutput = true;
  }

  bool trailingComma = false;
  unsigned i = 0, s = m_exps.size();
  unsigned ix = m_kind == ListKindLeft ? 0 : s - 1;
  for ( ; i < s; i++) {
    if (ExpressionPtr exp = m_exps[i]) {
      if (pre) {
        exp->preOutputCPP(cg, ar, 0);
        cg_printf("%s", m_cppTemp.c_str());
      }
      if (needsComma) {
        cg_printf(m_arrayElements ? "." : ", ");
        trailingComma = true;
      }
      if (m_arrayElements) {
        ArrayPairExpressionPtr ap =
          dynamic_pointer_cast<ArrayPairExpression>(exp);
        if (ap->isRef()) {
          cg_printf("setRef(");
          // The value itself shouldn't be wrapped with ref() any more.
          ap->getValue()->setContext(NoRefWrapper);
        } else {
          cg_printf("set(");
        }
        exp->outputCPP(cg, ar);
        cg_printf(")");
        if (pre) {
          cg_printf(";\n");
        }
        needsComma = true;
      } else if (m_kind != ListKindParam && (i != ix || !needed)) {
        needsComma = exp->outputCPPUnneeded(cg, ar);
      } else {
        exp->outputCPP(cg, ar);
        needsComma = true;
      }
      if (needsComma) {
        trailingComma = false;
        anyOutput = true;
      }
    }
  }
  if (trailingComma) {
    cg_printf("id(0)");
  }
  if (m_arrayElements && !pre) {
    cg_printf(".create()");
    anyOutput = true;
  }
  return anyOutput;
}
开发者ID:mayank245,项目名称:hiphop-php,代码行数:76,代码来源:expression_list.cpp


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