private ConstantValue evaluateShiftExpr( Expression lhs, Expression rhs, Type resultType, ShiftOperation operation) { // Evaluate subexpressions ConstantValue valueLhs = lhs.accept(this, null); ConstantValue valueRhs = rhs.accept(this, null); // Make integer promotions final ConstantType leftPromotedType = typeFactory.newConstantType(resultType); final ConstantType rightPromotedType = typeFactory.newConstantType(rhs.getType().get().promote()); valueLhs = valueLhs.castTo(leftPromotedType); valueRhs = valueRhs.castTo(rightPromotedType); // Perform the operation switch (operation) { case LEFT_SHIFT: return valueLhs.shiftLeft(valueRhs); case RIGHT_SHIFT: return valueLhs.shiftRight(valueRhs); default: throw new RuntimeException("unexpected shift operation kind '" + operation + "'"); } }