Ejemplo n.º 1
0
static ExpressionPtr makeIsNull(AnalysisResultConstPtr ar,
                                LocationPtr loc, ExpressionPtr exp,
                                bool invert) {
  /* Replace "$x === null" with an is_null call; this requires slightly
   * less work at runtime. */
  ExpressionListPtr expList =
    ExpressionListPtr(new ExpressionList(exp->getScope(), loc));
  expList->insertElement(exp);

  SimpleFunctionCallPtr call
    (new SimpleFunctionCall(exp->getScope(), loc,
                            "is_null", false, expList, ExpressionPtr()));

  call->setValid();
  call->setActualType(Type::Boolean);
  call->setupScopes(ar);

  ExpressionPtr result(call);
  if (invert) {
    result = ExpressionPtr(new UnaryOpExpression(
                             exp->getScope(), loc,
                             result, '!', true));
  }

  return result;
}
Ejemplo n.º 2
0
static ExpressionPtr makeIsNull(LocationPtr loc, ExpressionPtr exp,
                                bool invert) {
  /* Replace "$x === null" with an is_null call; this requires slightly
   * less work at runtime. */
  ExpressionListPtr expList =
    ExpressionListPtr(new ExpressionList(loc,
      Expression::KindOfExpressionList));
  expList->insertElement(exp);

  SimpleFunctionCallPtr call
    (new SimpleFunctionCall(loc, Expression::KindOfSimpleFunctionCall,
                            "is_null", expList, ExpressionPtr()));

  call->setValid();
  call->setActualType(Type::Boolean);

  ExpressionPtr result(call);
  if (invert) {
    result = ExpressionPtr(new UnaryOpExpression(
                             loc, Expression::KindOfUnaryOpExpression,
                             result, '!', true));
  }

  return result;
}
Ejemplo n.º 3
0
ExpressionPtr AssignmentExpression::makeIdCall(AnalysisResultPtr ar) {
  ExpressionListPtr arg =
    ExpressionListPtr(new ExpressionList(getLocation(),
                                         Expression::KindOfExpressionList));
  arg->insertElement(m_value);
  SimpleFunctionCallPtr result =
    SimpleFunctionCallPtr(
      new SimpleFunctionCall(getLocation(),
                             Expression::KindOfSimpleFunctionCall,
                             "id", arg, NULL));
  result->setFunctionAndClassScope(ar->findHelperFunction("id"),
                                   ClassScopePtr());
  result->setValid();
  result->setNoPrefix();
  result->setActualType(m_value->getActualType());
  result->setExpectedType(m_expectedType);
  return result;
}