private ConstantValue evaluateUnaryExpr( Expression opParam, Type resultType, UnaryArithmeticOperation operation) { // Evaluate the subexpression ConstantValue paramValue = opParam.accept(this, null); // Make the integer promotion final ConstantType resultConstantType = typeFactory.newConstantType(resultType); paramValue = paramValue.castTo(resultConstantType); // Perform the operation switch (operation) { case IDENTITY: return paramValue; case NEGATION: return paramValue.negate(); case BITWISE_NOT: return paramValue.bitwiseNot(); default: throw new RuntimeException("unexpected unary arithmetic operation '" + operation + "'"); } }