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


C++ UnaryOpExpressionPtr::getFront方法代码示例

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


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

示例1: rewriteUnary

/**
 * If the unary operation is not PHP specific, but something a query
 * processor can handle (+ - ! ~), then rewrite the operand to something
 * the query processor can evaluate (such as a query parameter reference)
 * and rewrite the entire expression to use the rewritten operand.
 * If the rewritten operand is the same as the original operand, just
 * return the expression as is.
 */
ExpressionPtr CaptureExtractor::rewriteUnary(UnaryOpExpressionPtr ue) {
  assert (ue != nullptr);
  if (!ue->getFront()) return nullptr;
  switch (ue->getOp()) {
    case '+':
    case '-':
    case '!':
    case '~':
      break; // Could be something the query processor can handle
    default:
      return newQueryParamRef(ue);
  }
  auto expr = ue->getExpression();
  auto newExpr = rewrite(expr);
  if (expr == newExpr) return ue;
  return std::make_shared<UnaryOpExpression>(
    ue->getScope(), ue->getRange(), newExpr, ue->getOp(), true);
}
开发者ID:shuc324,项目名称:hhvm,代码行数:26,代码来源:capture_extractor.cpp

示例2: canonicalizeNode


//.........这里部分代码省略.........
    }
    break;

  case Expression::KindOfBinaryOpExpression: {
    BinaryOpExpressionPtr bop = spc(BinaryOpExpression, e);

    int rop = getOpForAssignmentOp(bop->getOp());
    if (rop) {
      ExpressionPtr lhs = bop->getExp1();
      ExpressionPtr rep;
      if (bop->getContext() & Expression::DeadStore) {
        Construct::recomputeEffects();
        ExpressionPtr rhs = bop->getExp2()->clone();
        lhs = lhs->clone();
        lhs->clearContext(Expression::LValue);
        lhs->clearContext(Expression::NoLValueWrapper);
        lhs->clearContext(Expression::OprLValue);
        rep = ExpressionPtr
          (new BinaryOpExpression(e->getLocation(),
                                  Expression::KindOfBinaryOpExpression,
                                  lhs, rhs, rop));

      } else {
        ExpressionPtr alt;
        int interf = findInterf(lhs, true, alt);
        if (interf == SameAccess &&
            alt->is(Expression::KindOfAssignmentExpression)) {
          ExpressionPtr op0 = spc(AssignmentExpression,alt)->getValue();
          if (op0->is(Expression::KindOfScalarExpression)) {
            ExpressionPtr op1 = bop->getExp2();
            ExpressionPtr rhs
              (new BinaryOpExpression(e->getLocation(),
                                      Expression::KindOfBinaryOpExpression,
                                      op0->clone(), op1->clone(), rop));

            lhs = lhs->clone();
            lhs->clearContext(Expression::OprLValue);
            rep = ExpressionPtr
              (new AssignmentExpression(e->getLocation(),
                                        Expression::KindOfAssignmentExpression,
                                        lhs, rhs, false));
          }
        }
      }
      if (rep) {
        ExpressionPtr c = canonicalizeRecur(rep);
        return c ? c : rep;
      }
      add(m_bucketMap[0], e);
    } else {
      getCanonical(e);
    }
    break;
  }

  case Expression::KindOfUnaryOpExpression:
    {
      UnaryOpExpressionPtr uop = spc(UnaryOpExpression, e);
      switch (uop->getOp()) {
      case T_INC:
      case T_DEC:
        if (uop->getContext() & Expression::DeadStore) {
          Construct::recomputeEffects();
          ExpressionPtr val = uop->getExpression()->clone();
          val->clearContext(Expression::LValue);
          val->clearContext(Expression::NoLValueWrapper);
          val->clearContext(Expression::OprLValue);
          if (uop->getFront()) {
            ExpressionPtr inc
              (new ScalarExpression(uop->getLocation(),
                                    Expression::KindOfScalarExpression,
                                    T_LNUMBER, string("1")));

            val = ExpressionPtr
              (new BinaryOpExpression(uop->getLocation(),
                                      Expression::KindOfBinaryOpExpression,
                                      val, inc,
                                      uop->getOp() == T_INC ? '+' : '-'));

          }

          ExpressionPtr r = canonicalizeRecur(val);
          return r ? r : val;
        }
        add(m_bucketMap[0], e);
        break;
      default:
        getCanonical(e);
        break;
      }
      break;
    }

  default:
    getCanonical(e);
    break;
  }

  return ExpressionPtr();
}
开发者ID:scottmac,项目名称:hiphop-dev,代码行数:101,代码来源:alias_manager.cpp


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