Beispiel #1
0
  private IType computeType(IASTNode point) {
    if (isTypeDependent()) return new TypeOfDependentExpression(this);

    ICPPFunction overload = getOverload(point);
    if (overload != null) return ExpressionTypes.typeFromFunctionCall(overload);

    switch (fOperator) {
      case op_sizeof:
      case op_sizeofParameterPack:
        return CPPVisitor.get_SIZE_T(point);
      case op_typeid:
        return CPPVisitor.get_type_info(point);
      case op_throw:
        return CPPSemantics.VOID_TYPE;
      case op_amper:
        if (fAddressOfQualifiedNameBinding instanceof ICPPMember) {
          ICPPMember member = (ICPPMember) fAddressOfQualifiedNameBinding;
          if (!member.isStatic()) {
            try {
              return new CPPPointerToMemberType(
                  member.getType(), member.getClassOwner(), false, false, false);
            } catch (DOMException e) {
              return e.getProblem();
            }
          }
        }
        return new CPPPointerType(fArgument.getTypeOrFunctionSet(point));
      case op_star:
        IType type = fArgument.getTypeOrFunctionSet(point);
        type = prvalueTypeWithResolvedTypedefs(type);
        if (type instanceof IPointerType) {
          return glvalueType(((IPointerType) type).getType());
        }
        if (type instanceof ISemanticProblem) {
          return type;
        }
        return new ProblemType(ISemanticProblem.TYPE_UNKNOWN_FOR_EXPRESSION);
      case op_noexcept:
      case op_not:
        return CPPBasicType.BOOLEAN;
      case op_postFixDecr:
      case op_postFixIncr:
        return prvalueType(fArgument.getTypeOrFunctionSet(point));
      case op_minus:
      case op_plus:
      case op_tilde:
        final IType t1 = prvalueType(fArgument.getTypeOrFunctionSet(point));
        final IType t2 = SemanticUtil.getNestedType(t1, TDEF);
        final IType t3 = CPPArithmeticConversion.promoteCppType(t2);
        return (t3 == null || t3 == t2) ? t1 : t3;
    }
    return fArgument.getTypeOrFunctionSet(point);
  }
Beispiel #2
0
  private ICPPFunction computeOverload(IASTNode point) {
    OverloadableOperator op = OverloadableOperator.fromUnaryExpression(fOperator);
    if (op == null) return null;

    if (fArgument.isTypeDependent()) return null;

    if (fAddressOfQualifiedNameBinding instanceof ICPPMember) {
      ICPPMember member = (ICPPMember) fAddressOfQualifiedNameBinding;
      if (!member.isStatic()) return null;
    }

    IType type = fArgument.getTypeOrFunctionSet(point);
    type = SemanticUtil.getNestedType(type, TDEF | REF | CVTYPE);
    if (!CPPSemantics.isUserDefined(type)) return null;

    ICPPEvaluation[] args;
    if (fOperator == op_postFixDecr || fOperator == op_postFixIncr) {
      args = new ICPPEvaluation[] {fArgument, ZERO_EVAL};
    } else {
      args = new ICPPEvaluation[] {fArgument};
    }
    return CPPSemantics.findOverloadedOperator(point, args, type, op, LookupMode.LIMITED_GLOBALS);
  }