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


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

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


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

ExpressionPtr Expression::replaceValue(ExpressionPtr rep, bool noWarn) {
  if (hasContext(Expression::RefValue) &&
      isRefable(true) && !rep->isRefable(true)) {
    /*
      An assignment isRefable, but the rhs may not be. Need this to
      prevent "bad pass by reference" errors.
    */
    auto el = std::make_shared<ExpressionList>(
      getScope(), getRange(), noWarn ?
      ExpressionList::ListKindWrappedNoWarn : ExpressionList::ListKindWrapped);
    el->addElement(rep);
    rep->clearContext(AssignmentRHS);
    rep = el;
  }
  if (rep->is(KindOfSimpleVariable) && !is(KindOfSimpleVariable)) {
    static_pointer_cast<SimpleVariable>(rep)->setAlwaysStash();
  }
  rep->copyContext(m_context & ~(DeadStore|AccessContext));

  if (rep->getScope() != getScope()) {
    rep->resetScope(getScope());
  }

  return rep;
}
开发者ID:HilayPatel,项目名称:hhvm,代码行数:25,代码来源:expression.cpp

示例3: replaceValue

ExpressionPtr Expression::replaceValue(ExpressionPtr rep) {
  if (hasContext(Expression::RefValue) &&
      isRefable(true) && !rep->isRefable(true)) {
    /*
      An assignment isRefable, but the rhs may not be. Need this to
      prevent "bad pass by reference" errors.
    */
    ExpressionListPtr el(new ExpressionList(getScope(), getRange(),
                                            ExpressionList::ListKindWrapped));
    el->addElement(rep);
    rep->clearContext(AssignmentRHS);
    rep = el;
  }
  if (rep->is(KindOfSimpleVariable) && !is(KindOfSimpleVariable)) {
    static_pointer_cast<SimpleVariable>(rep)->setAlwaysStash();
  }
  rep->copyContext(m_context & ~(DeadStore|AccessContext));
  if (TypePtr t1 = getType()) {
    if (TypePtr t2 = rep->getType()) {
      if (!Type::SameType(t1, t2)) {
        rep->setExpectedType(t1);
      }
    }
  }

  if (rep->getScope() != getScope()) {
    rep->resetScope(getScope());
  }

  return rep;
}
开发者ID:andyanx,项目名称:hhvm,代码行数:31,代码来源:expression.cpp

示例4: outputCPPArguments

void FunctionScope::outputCPPArguments(ExpressionListPtr params,
                                       CodeGenerator &cg,
                                       AnalysisResultPtr ar, int extraArg,
                                       bool variableArgument,
                                       int extraArgArrayId /* = -1 */) {
  int paramCount = params ? params->getOutputCount() : 0;
  ASSERT(extraArg <= paramCount);
  int iMax = paramCount - extraArg;
  bool extra = false;

  if (variableArgument) {
    if (paramCount == 0) {
      cg.printf("0");
    } else {
      cg.printf("%d, ", paramCount);
    }
  }
  int firstExtra = 0;
  for (int i = 0; i < paramCount; i++) {
    ExpressionPtr param = (*params)[i];
    cg.setItemIndex(i);
    if (i > 0) cg.printf(extra ? "." : ", ");
    if (!extra && (i == iMax || extraArg < 0)) {
      if (extraArgArrayId != -1) {
        if (cg.getOutput() == CodeGenerator::SystemCPP) {
          cg.printf("SystemScalarArrays::%s[%d]",
                    Option::SystemScalarArrayName, extraArgArrayId);
        } else {
          cg.printf("ScalarArrays::%s[%d]",
                    Option::ScalarArrayName, extraArgArrayId);
        }
        break;
      }
      extra = true;
      // Parameter arrays are always vectors.
      cg.printf("Array(ArrayInit(%d, true).", paramCount - i);
      firstExtra = i;
    }
    if (extra) {
      bool needRef = param->hasContext(Expression::RefValue) &&
                     !param->hasContext(Expression::NoRefWrapper) &&
                     param->isRefable();
      cg.printf("set%s(%d, ", needRef ? "Ref" : "", i - firstExtra);
      if (needRef) {
        // The parameter itself shouldn't be wrapped with ref() any more.
        param->setContext(Expression::NoRefWrapper);
      }
      param->outputCPP(cg, ar);
      cg.printf(")");
    } else {
      param->outputCPP(cg, ar);
    }
  }
  if (extra) {
    cg.printf(".create())");
  }
}
开发者ID:yigithub,项目名称:hiphop-php,代码行数:57,代码来源:function_scope.cpp

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

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

示例7: outputCPPArguments

void FunctionScope::outputCPPArguments(ExpressionListPtr params,
                                       CodeGenerator &cg,
                                       AnalysisResultPtr ar, int extraArg,
                                       bool variableArgument,
                                       int extraArgArrayId /* = -1 */,
                                       int extraArgArrayHash /* = -1 */,
                                       int extraArgArrayIndex /* = -1 */) {

  int paramCount = params ? params->getOutputCount() : 0;
  ASSERT(extraArg <= paramCount);
  int iMax = paramCount - extraArg;
  bool extra = false;

  if (variableArgument) {
    if (paramCount == 0) {
      cg_printf("0");
    } else {
      cg_printf("%d, ", paramCount);
    }
  }
  int firstExtra = 0;
  for (int i = 0; i < paramCount; i++) {
    ExpressionPtr param = (*params)[i];
    cg.setItemIndex(i);
    if (i > 0) cg_printf(extra ? "." : ", ");
    if (!extra && (i == iMax || extraArg < 0)) {
      if (extraArgArrayId != -1) {
        assert(extraArgArrayHash != -1 && extraArgArrayIndex != -1);
        ar->outputCPPScalarArrayId(cg, extraArgArrayId, extraArgArrayHash,
                                   extraArgArrayIndex);
        break;
      }
      extra = true;
      // Parameter arrays are always vectors.
      if (Option::GenArrayCreate &&
          cg.getOutput() != CodeGenerator::SystemCPP) {
        if (!params->hasNonArrayCreateValue(false, i)) {
          ar->m_arrayIntegerKeySizes.insert(paramCount - i);
          cg_printf("Array(");
          params->outputCPPUniqLitKeyArrayInit(cg, ar, paramCount - i,
                                               false, i);
          cg_printf(")");
          return;
        }
      }
      firstExtra = i;
      cg_printf("Array(ArrayInit(%d, true).", paramCount - i);
    }
    if (extra) {
      bool needRef = param->hasContext(Expression::RefValue) &&
                     !param->hasContext(Expression::NoRefWrapper) &&
                     param->isRefable();
      cg_printf("set%s(", needRef ? "Ref" : "");
      if (needRef) {
        // The parameter itself shouldn't be wrapped with ref() any more.
        param->setContext(Expression::NoRefWrapper);
      }
      param->outputCPP(cg, ar);
      cg_printf(")");
    } else {
      param->outputCPP(cg, ar);
    }
  }
  if (extra) {
    cg_printf(".create())");
  }
}
开发者ID:param108,项目名称:hiphop-php,代码行数:67,代码来源:function_scope.cpp


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