Type toType = castedVal.getType(); Type fromType = castedVal.operand.getType(); if (!numericPromotionPriority.containsKey(fromType)) return false;
return new TypedValue.CastValue(Type.getObjectType(typeInsn.desc), (TypedValue)value); return new TypedValue.CastValue(Type.LONG_TYPE, (TypedValue)value); case L2I: case F2I: case D2I: return new TypedValue.CastValue(Type.INT_TYPE, (TypedValue)value); case I2F: case L2F: case D2F: return new TypedValue.CastValue(Type.FLOAT_TYPE, (TypedValue)value); case I2D: case L2D: case F2D: return new TypedValue.CastValue(Type.DOUBLE_TYPE, (TypedValue)value); case INEG: return new TypedValue.UnaryMathOpValue(TypedValue.UnaryMathOpValue.UnaryOp.neg, Type.INT_TYPE, (TypedValue)value);
@Override public ColumnExpressions<?> castValue(TypedValue.CastValue val, SymbExPassDown in) throws TypedValueVisitorException { // We need to handle casts between primitive types carefully // because JPQL doesn't really support them directly if (val.isPrimitive()) { throw new TypedValueVisitorException("Casts of primitive values are not support in JPQL"); } // TODO: Check if cast is consistent with the reader // SQLColumnValues toReturn = val.operand.visit(this, in); // if (!toReturn.reader.isCastConsistent(val.getType().getInternalName())) // throw new TypedValueVisitorException("Attempting to cast to an inconsistent type"); return val.operand.visit(this, SymbExPassDown.with(val, in.isExpectingConditional)); }
@Override public CastValue withNewChildren(TypedValue newOperand) { return new CastValue(type, newOperand); } }