@Override public Boolean visitPrimitiveType(final PrimitiveType t, final TypeReference s) { final JvmType jt = t.getSimpleType(); final JvmType js = s.getSimpleType(); switch (js) { case Boolean: return jt == JvmType.Boolean; case Byte: return jt != JvmType.Character && jt.isIntegral() && jt.bitWidth() <= js.bitWidth(); case Character: return jt == JvmType.Character; case Short: if (jt == JvmType.Character) { return false; } // fall through case Integer: case Long: return jt.isIntegral() && jt.bitWidth() <= js.bitWidth(); case Float: case Double: return jt.isIntegral() || jt.bitWidth() <= js.bitWidth(); case Void: return jt == JvmType.Void; default: return Boolean.FALSE; } }
@Override public Boolean visitPrimitiveType(final PrimitiveType t, final TypeReference s) { final JvmType jt = t.getSimpleType(); final JvmType js = s.getSimpleType(); switch (js) { case Boolean: return jt == JvmType.Boolean; case Byte: return js != JvmType.Character && jt.isIntegral() && jt.bitWidth() <= js.bitWidth(); case Character: return jt == JvmType.Character; case Short: if (jt == JvmType.Character) { return false; } // fall through case Integer: case Long: return jt.isIntegral() && jt.bitWidth() <= js.bitWidth(); case Float: case Double: return jt.isIntegral() || jt.bitWidth() <= js.bitWidth(); case Void: return s.getSimpleType() == JvmType.Void; default: return Boolean.FALSE; } }
@Override public Boolean visitPrimitiveType(final PrimitiveType t, final TypeReference s) { final JvmType jt = t.getSimpleType(); final JvmType js = s.getSimpleType(); switch (js) { case Boolean: return jt == JvmType.Boolean; case Byte: return js != JvmType.Character && jt.isIntegral() && jt.bitWidth() <= js.bitWidth(); case Character: return jt == JvmType.Character; case Short: if (jt == JvmType.Character) { return false; } // fall through case Integer: case Long: return jt.isIntegral() && jt.bitWidth() <= js.bitWidth(); case Float: case Double: return jt.isIntegral() || jt.bitWidth() <= js.bitWidth(); case Void: return s.getSimpleType() == JvmType.Void; default: return Boolean.FALSE; } }
public static boolean hasImplicitNumericConversion(final TypeReference target, final TypeReference source) { VerifyArgument.notNull(source, "source"); VerifyArgument.notNull(target, "target"); if (target == source) { return true; } if (!target.isPrimitive() || !source.isPrimitive()) { return false; } final JvmType targetJvmType = target.getSimpleType(); final JvmType sourceJvmType = source.getSimpleType(); if (targetJvmType == sourceJvmType) { return true; } if (sourceJvmType == JvmType.Boolean) { return false; } switch (targetJvmType) { case Float: case Double: return sourceJvmType.bitWidth() <= targetJvmType.bitWidth(); case Byte: case Short: case Integer: case Long: return sourceJvmType.isIntegral() && sourceJvmType.bitWidth() <= targetJvmType.bitWidth(); } return false; }
public static boolean hasImplicitNumericConversion(final TypeReference target, final TypeReference source) { VerifyArgument.notNull(source, "source"); VerifyArgument.notNull(target, "target"); if (target == source) { return true; } if (!target.isPrimitive() || !source.isPrimitive()) { return false; } final JvmType targetJvmType = target.getSimpleType(); final JvmType sourceJvmType = source.getSimpleType(); if (targetJvmType == sourceJvmType) { return true; } if (sourceJvmType == JvmType.Boolean) { return false; } switch (targetJvmType) { case Float: case Double: return sourceJvmType.bitWidth() <= targetJvmType.bitWidth(); case Byte: case Short: case Integer: case Long: return sourceJvmType.isIntegral() && sourceJvmType.bitWidth() <= targetJvmType.bitWidth(); } return false; }
public static boolean hasImplicitNumericConversion(final TypeReference target, final TypeReference source) { VerifyArgument.notNull(source, "source"); VerifyArgument.notNull(target, "target"); if (target == source) { return true; } if (!target.isPrimitive() || !source.isPrimitive()) { return false; } final JvmType targetJvmType = target.getSimpleType(); final JvmType sourceJvmType = source.getSimpleType(); if (targetJvmType == sourceJvmType) { return true; } if (sourceJvmType == JvmType.Boolean) { return false; } switch (targetJvmType) { case Float: case Double: return sourceJvmType.bitWidth() <= targetJvmType.bitWidth(); case Byte: case Short: case Integer: case Long: return sourceJvmType.isIntegral() && sourceJvmType.bitWidth() <= targetJvmType.bitWidth(); } return false; }
case Double: { if (sourceJvmType.isIntegral()) { return sourceJvmType.bitWidth() >= targetJvmType.bitWidth() ? ConversionType.IMPLICIT_LOSSY : ConversionType.IMPLICIT; return sourceJvmType.bitWidth() <= targetJvmType.bitWidth() ? ConversionType.IMPLICIT : ConversionType.EXPLICIT; case Long: { if (sourceJvmType.isIntegral() && sourceJvmType.bitWidth() <= targetJvmType.bitWidth()) {
if (targetResult.getType().getSimpleType().bitWidth() < 32) { final AstBuilder astBuilder = context.getUserData(Keys.AST_BUILDER);
if (targetResult.getType().getSimpleType().bitWidth() < 32) { final AstBuilder astBuilder = context.getUserData(Keys.AST_BUILDER);
if (targetResult.getType().getSimpleType().bitWidth() < 32) { final AstBuilder astBuilder = context.getUserData(Keys.AST_BUILDER);