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


C++ ExpressionPtr::isTemporary方法代码示例

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


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

示例1: preOutputCPP

bool AssignmentExpression::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
                                        int state) {
  if (m_variable->is(Expression::KindOfArrayElementExpression)) {
    ExpressionPtr exp = m_value;
    ExpressionPtr vv(
      static_pointer_cast<ArrayElementExpression>(m_variable)->getVariable());
    if ((vv->is(KindOfArrayElementExpression) ||
         vv->is(KindOfObjectPropertyExpression)) &&
        (vv->getContainedEffects() && (CreateEffect|AccessorEffect))) {
      /*
        We are in a case such as
          $a->b['c'] = ...;
          $a['b']['c'] = ...;
        Where evaluating m_variable may modify $a. Unless we can prove that
        the rhs is not referring to the same thing as $a, we must generate
        a temporary for it (note that we could do better with the following
        checks).
      */
      if (!(m_ref && exp->isRefable()) &&
          !exp->isTemporary() && !exp->isScalar() &&
          exp->getActualType() && !exp->getActualType()->isPrimitive() &&
          exp->getActualType()->getKindOf() != Type::KindOfString) {
        state |= Expression::StashAll;
      }
    }
  }

  return Expression::preOutputCPP(cg, ar, state);
}
开发者ID:jhockly,项目名称:RED-COLOR-IS-MY-FAVORITE-COLOR,代码行数:29,代码来源:assignment_expression.cpp

示例2: wrapValue

static void wrapValue(CodeGenerator &cg, AnalysisResultPtr ar,
                      ExpressionPtr exp, bool ref, bool array, bool varnr) {
  bool close = false;
  if (ref) {
    cg_printf("ref(");
    close = true;
  } else if (array && !exp->hasCPPTemp() &&
             !exp->isTemporary() && !exp->isScalar() &&
             exp->getActualType() && !exp->getActualType()->isPrimitive() &&
             exp->getActualType()->getKindOf() != Type::KindOfString) {
    cg_printf("wrap_variant(");
    close = true;
  } else if (varnr && exp->getCPPType()->isExactType()) {
    bool isScalar = exp->isScalar();
    if (!isScalar || !Option::UseScalarVariant) {
      cg_printf("VarNR(");
      close = true;
    } else if (isScalar) {
      ASSERT(!cg.hasScalarVariant());
      cg.setScalarVariant();
    }
  }
  exp->outputCPP(cg, ar);
  cg.clearScalarVariant();
  if (close) cg_printf(")");
}
开发者ID:HyeongKyu,项目名称:hiphop-php,代码行数:26,代码来源:assignment_expression.cpp

示例3: preOutputCPP

bool AssignmentExpression::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
                                        int state) {
  if (m_variable->is(Expression::KindOfArrayElementExpression)) {
    ExpressionPtr exp = m_value;
    if (!(m_ref && exp->isRefable()) &&
        !exp->isTemporary() && !exp->isScalar() &&
        exp->getActualType() && !exp->getActualType()->isPrimitive() &&
        exp->getActualType()->getKindOf() != Type::KindOfString) {
      state |= Expression::StashAll;
    }
  }
  return Expression::preOutputCPP(cg, ar, state);
}
开发者ID:brianmn,项目名称:hiphop-php_packaged,代码行数:13,代码来源:assignment_expression.cpp

示例4: wrapValue

static void wrapValue(CodeGenerator &cg, AnalysisResultPtr ar,
                      ExpressionPtr exp, bool ref, bool array) {
  bool close = false;
  if (ref) {
    cg_printf("ref(");
    close = true;
  } else if (array && !exp->hasCPPTemp() &&
             !exp->isTemporary() && !exp->isScalar() &&
             exp->getActualType() && !exp->getActualType()->isPrimitive() &&
             exp->getActualType()->getKindOf() != Type::KindOfString) {
    cg_printf("wrap_variant(");
    close = true;
  }
  exp->outputCPP(cg, ar);
  if (close) cg_printf(")");
}
开发者ID:jhockly,项目名称:RED-COLOR-IS-MY-FAVORITE-COLOR,代码行数:16,代码来源:assignment_expression.cpp

示例5: hasNonArrayCreateValue

bool ExpressionList::hasNonArrayCreateValue(
  bool arrayElements /* = true */, unsigned int start /* = 0 */) const {
  for (unsigned int i = start; i < m_exps.size(); i++) {
    ExpressionPtr value = m_exps[i];
    if (arrayElements) {
      ArrayPairExpressionPtr ap =
        dynamic_pointer_cast<ArrayPairExpression>(m_exps[i]);
      value = ap->getValue();
    }
    ASSERT(value);
    if (value->hasContext(RefValue) ||
        (value->hasEffect() && !value->isTemporary())) {
      return true;
    }
  }
  return false;
}
开发者ID:eliotsolomon,项目名称:hiphop-php,代码行数:17,代码来源:expression_list.cpp

示例6: preOutputCPP

bool ExpressionList::preOutputCPP(CodeGenerator &cg, AnalysisResultPtr ar,
                                  int state) {
  if (m_kind == ListKindParam && !m_arrayElements) {
    return Expression::preOutputCPP(cg, ar, state|StashKidVars);
  }

  unsigned n = m_exps.size();
  bool inExpression = cg.inExpression();
  if (!inExpression && (state & FixOrder)) {
    return true;
  }

  cg.setInExpression(false);
  bool ret = false;
  if (m_arrayElements) {
    /*
     * would like to do:
     *  ret = Expression::preOutputCPP(cg, ar, state);
     * but icc has problems with the generated code.
     */
    ret = hasEffect();
  } else if (n > 1 && m_kind == ListKindLeft) {
    ret = true;
  } else {
    for (unsigned int i = 0; i < n; i++) {
      if (m_exps[i]->preOutputCPP(cg, ar, 0)) {
        ret = true;
        break;
      }
    }
    if (!ret) {
      ExpressionPtr e = m_exps[n - 1];
      if (hasContext(LValue) && !hasAnyContext(RefValue|InvokeArgument) &&
          !(e->hasContext(LValue) &&
            !e->hasAnyContext(RefValue|InvokeArgument))) {
        ret = true;
      } else if (hasContext(RefValue) &&
                 !e->hasAllContext(LValue|ReturnContext) &&
                 !e->hasContext(RefValue)) {
        ret = true;
      }
    }
  }

  if (!inExpression) return ret;

  cg.setInExpression(true);
  if (!ret) {
    if (state & FixOrder) {
      preOutputStash(cg, ar, state);
      return true;
    }
    return false;
  }

  cg.wrapExpressionBegin();
  if (m_arrayElements) {
    setCPPTemp(genCPPTemp(cg, ar));
    outputCPPInternal(cg, ar, true, true);
  } else {
    unsigned ix = isUnused() ? (unsigned)-1 :
      m_kind == ListKindLeft ? 0 : n - 1;
    for (unsigned int i = 0; i < n; i++) {
      ExpressionPtr e = m_exps[i];
      e->preOutputCPP(cg, ar, i == ix ? state : 0);
      if (i != ix) {
        if (e->outputCPPUnneeded(cg, ar)) {
          cg_printf(";\n");
        }
        e->setCPPTemp("/**/");
        continue;
      }
      /*
        We inlined a by-value function into the rhs of a by-ref assignment.
      */
      bool noRef = hasContext(RefValue) &&
        !e->hasAllContext(LValue|ReturnContext) &&
        !e->hasContext(RefValue) &&
        !e->isTemporary() &&
        Type::IsMappedToVariant(e->getActualType());
      /*
        If we need a non-const reference, but the expression is
        going to generate a const reference, fix it
      */
      bool lvSwitch =
        hasContext(LValue) && !hasAnyContext(RefValue|InvokeArgument) &&
        !(e->hasContext(LValue) &&
          !e->hasAnyContext(RefValue|InvokeArgument));

      if (e->hasAllContext(LValue|ReturnContext) && i + 1 == n) {
        e->clearContext(ReturnContext);
      }

      if (noRef || lvSwitch || (!i && n > 1)) {
        e->Expression::preOutputStash(cg, ar, state | FixOrder | StashAll);
        if (!(state & FixOrder)) {
          cg_printf("id(%s);\n", e->cppTemp().c_str());
        }
      }
      if (e->hasCPPTemp() &&
//.........这里部分代码省略.........
开发者ID:DenisBazhan,项目名称:hiphop-php,代码行数:101,代码来源:expression_list.cpp


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