Java Code Examples for org.eclipse.jdt.internal.compiler.lookup.TypeIds#T_int

The following examples show how to use org.eclipse.jdt.internal.compiler.lookup.TypeIds#T_int . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PrimitiveTypeImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static TypeKind getKind(BaseTypeBinding binding) {
	switch (binding.id) {
	case TypeIds.T_boolean:
		return TypeKind.BOOLEAN;
	case TypeIds.T_byte:
		return TypeKind.BYTE;
	case TypeIds.T_char:
		return TypeKind.CHAR;
	case TypeIds.T_double:
		return TypeKind.DOUBLE;
	case TypeIds.T_float:
		return TypeKind.FLOAT;
	case TypeIds.T_int:
		return TypeKind.INT;
	case TypeIds.T_long:
		return TypeKind.LONG;
	case TypeIds.T_short:
		return TypeKind.SHORT;
	default:
		throw new IllegalArgumentException("BaseTypeBinding of unexpected id " + binding.id); //$NON-NLS-1$
	}
}
 
Example 2
Source File: Util.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public static Object getNegativeAnnotationMemberValue(MemberValuePair memberValuePair, Constant constant) {
	if (constant == null) {
		memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
		return null;
	}
	switch (constant.typeID()) {
		case TypeIds.T_int :
			memberValuePair.valueKind = IMemberValuePair.K_INT;
			return new Integer(constant.intValue() * -1);
		case TypeIds.T_float :
			memberValuePair.valueKind = IMemberValuePair.K_FLOAT;
			return new Float(constant.floatValue() * -1.0f);
		case TypeIds.T_double :
			memberValuePair.valueKind = IMemberValuePair.K_DOUBLE;
			return new Double(constant.doubleValue() * -1.0);
		case TypeIds.T_long :
			memberValuePair.valueKind = IMemberValuePair.K_LONG;
			return new Long(constant.longValue() * -1L);
		default:
			memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
			return null;
	}
}
 
Example 3
Source File: BaseTypeBinding.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public TypeBinding unannotated() {
	if (!this.hasTypeAnnotations())
		return this;
	switch (this.id) {
		case TypeIds.T_boolean:
			return TypeBinding.BOOLEAN;
		case TypeIds.T_byte:
			return TypeBinding.BYTE;
		case TypeIds.T_char:
			return TypeBinding.CHAR;
		case TypeIds.T_double:
			return TypeBinding.DOUBLE;
		case TypeIds.T_float:
			return TypeBinding.FLOAT;
		case TypeIds.T_int:
			return TypeBinding.INT;
		case TypeIds.T_long:
			return TypeBinding.LONG;
		case TypeIds.T_short:
			return TypeBinding.SHORT;
		default:
			throw new IllegalStateException();
		}
}
 
Example 4
Source File: VariableBinding.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
public Object getConstantValue() {
	Constant c = this.binding.constant();
	if (c == null || c == Constant.NotAConstant) return null;
	switch (c.typeID()) {
		case TypeIds.T_boolean:
			return Boolean.valueOf(c.booleanValue());
		case TypeIds.T_byte:
			return new Byte(c.byteValue());
		case TypeIds.T_char:
			return new Character(c.charValue());
		case TypeIds.T_double:
			return new Double(c.doubleValue());
		case TypeIds.T_float:
			return new Float(c.floatValue());
		case TypeIds.T_int:
			return new Integer(c.intValue());
		case TypeIds.T_long:
			return new Long(c.longValue());
		case TypeIds.T_short:
			return new Short(c.shortValue());
		case TypeIds.T_JavaLangString:
			return c.stringValue();
	}
	return null;
}
 
Example 5
Source File: DefaultBindingResolver.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 6 votes vote down vote up
Object resolveConstantExpressionValue(Expression expression) {
	org.eclipse.jdt.internal.compiler.ast.ASTNode node = (org.eclipse.jdt.internal.compiler.ast.ASTNode) this.newAstToOldAst.get(expression);
	if (node instanceof org.eclipse.jdt.internal.compiler.ast.Expression) {
		org.eclipse.jdt.internal.compiler.ast.Expression compilerExpression = (org.eclipse.jdt.internal.compiler.ast.Expression) node;
		Constant constant = compilerExpression.constant;
		if (constant != null && constant != Constant.NotAConstant) {
			switch (constant.typeID()) {
				case TypeIds.T_int : return new Integer(constant.intValue());
				case TypeIds.T_byte : return new Byte(constant.byteValue());
				case TypeIds.T_short : return new Short(constant.shortValue());
				case TypeIds.T_char : return new Character(constant.charValue());
				case TypeIds.T_float : return new Float(constant.floatValue());
				case TypeIds.T_double : return new Double(constant.doubleValue());
				case TypeIds.T_boolean : return constant.booleanValue() ? Boolean.TRUE : Boolean.FALSE;
				case TypeIds.T_long : return new Long(constant.longValue());
				case TypeIds.T_JavaLangString : return constant.stringValue();
			}
			return null;
		}
	}
	return null;
}
 
Example 6
Source File: AnnotationValueImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@SuppressWarnings("unchecked") // Need to cast Object _value to a List<AnnotationValue>
@Override
public <R, P> R accept(AnnotationValueVisitor<R, P> v, P p) {
	switch (_kind) {
	case TypeIds.T_boolean:
		return v.visitBoolean((Boolean)_value, p);
	case TypeIds.T_byte:
		return v.visitByte((Byte)_value, p);
	case TypeIds.T_char:
		return v.visitChar((Character)_value, p);
	case TypeIds.T_double:
		return v.visitDouble((Double)_value, p);
	case TypeIds.T_float:
		return v.visitFloat((Float)_value, p);
	case TypeIds.T_int:
		return v.visitInt((Integer)_value, p);
	case TypeIds.T_JavaLangString:
		return v.visitString((String)_value, p);
	case TypeIds.T_long:
		return v.visitLong((Long)_value, p);
	case TypeIds.T_short:
		return v.visitShort((Short)_value, p);
	case T_EnumConstant:
		return v.visitEnumConstant((VariableElement)_value, p);
	case T_ClassObject:
		return v.visitType((TypeMirror)_value, p);
	case T_AnnotationMirror:
		return v.visitAnnotation((AnnotationMirror)_value, p);
	case T_ArrayType:
		return v.visitArray((List<AnnotationValue>)_value, p);
	default:
		return null;
	}
}
 
Example 7
Source File: ClassfileDigester.java    From takari-lifecycle with Eclipse Public License 1.0 5 votes vote down vote up
private void updateConstant(Constant constant) {
  updateInt(constant.typeID());
  updateString(constant.getClass().getName());
  switch (constant.typeID()) {
    case TypeIds.T_int:
      updateInt(constant.intValue());
      break;
    case TypeIds.T_byte:
      updateByte(constant.byteValue());
      break;
    case TypeIds.T_short:
      updateShort(constant.shortValue());
      break;
    case TypeIds.T_char:
      updateChar(constant.charValue());
      break;
    case TypeIds.T_long:
      updateLong(constant.longValue());
      break;
    case TypeIds.T_float:
      updateFloat(constant.floatValue());
      break;
    case TypeIds.T_double:
      updateDouble(constant.doubleValue());
      break;
    case TypeIds.T_boolean:
      updateBoolean(constant.booleanValue());
      break;
    case TypeIds.T_JavaLangString:
      updateString(constant.stringValue());
      break;
    default:
      throw new IllegalArgumentException("Unexpected constant typeID=" + constant.typeID());
  }
}
 
Example 8
Source File: VerificationTypeInfo.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public void setBinding(TypeBinding binding) {
	this.constantPoolName = binding.constantPoolName();
	final int typeBindingId = binding.id;
	this.id = typeBindingId;
	switch(typeBindingId) {
		case TypeIds.T_boolean :
		case TypeIds.T_byte :
		case TypeIds.T_char :
		case TypeIds.T_int :
		case TypeIds.T_short :
			this.tag = VerificationTypeInfo.ITEM_INTEGER;
			break;
		case TypeIds.T_float :
			this.tag = VerificationTypeInfo.ITEM_FLOAT;
			break;
		case TypeIds.T_long :
			this.tag = VerificationTypeInfo.ITEM_LONG;
			break;
		case TypeIds.T_double :
			this.tag = VerificationTypeInfo.ITEM_DOUBLE;
			break;
		case TypeIds.T_null :
			this.tag = VerificationTypeInfo.ITEM_NULL;
			break;
		default:
			this.tag =  VerificationTypeInfo.ITEM_OBJECT;
	}
}
 
Example 9
Source File: VerificationTypeInfo.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public VerificationTypeInfo(TypeBinding binding) {
	this.id = binding.id;
	switch(binding.id) {
		case TypeIds.T_boolean :
		case TypeIds.T_byte :
		case TypeIds.T_char :
		case TypeIds.T_int :
		case TypeIds.T_short :
			this.tag = VerificationTypeInfo.ITEM_INTEGER;
			break;
		case TypeIds.T_float :
			this.tag = VerificationTypeInfo.ITEM_FLOAT;
			break;
		case TypeIds.T_long :
			this.tag = VerificationTypeInfo.ITEM_LONG;
			break;
		case TypeIds.T_double :
			this.tag = VerificationTypeInfo.ITEM_DOUBLE;
			break;
		case TypeIds.T_null :
			this.tag = VerificationTypeInfo.ITEM_NULL;
			break;
		default:
			this.tag =  VerificationTypeInfo.ITEM_OBJECT;
			this.constantPoolName = binding.constantPoolName();
	}
}
 
Example 10
Source File: Constant.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Returns true if both constants have the same type and the same actual value
 * @param otherConstant
 */
public boolean hasSameValue(Constant otherConstant) {
	if (this == otherConstant)
		return true;
	int typeID;
	if ((typeID = typeID()) != otherConstant.typeID())
		return false;
	switch (typeID) {
		case TypeIds.T_boolean:
			return booleanValue() == otherConstant.booleanValue();
		case TypeIds.T_byte:
			return byteValue() == otherConstant.byteValue();
		case TypeIds.T_char:
			return charValue() == otherConstant.charValue();
		case TypeIds.T_double:
			return doubleValue() == otherConstant.doubleValue();
		case TypeIds.T_float:
			return floatValue() == otherConstant.floatValue();
		case TypeIds.T_int:
			return intValue() == otherConstant.intValue();
		case TypeIds.T_short:
			return shortValue() == otherConstant.shortValue();
		case TypeIds.T_long:
			return longValue() == otherConstant.longValue();
		case TypeIds.T_JavaLangString:
			String value = stringValue();
			return value == null
				? otherConstant.stringValue() == null
				: value.equals(otherConstant.stringValue());
	}
	return false;
}
 
Example 11
Source File: FieldInfo.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Return a wrapper that contains the constant of the field.
 * @return java.lang.Object
 */
public Object getWrappedConstantValue() {

	if (this.wrappedConstantValue == null) {
		if (hasConstant()) {
			Constant fieldConstant = getConstant();
			switch (fieldConstant.typeID()) {
				case TypeIds.T_int :
					this.wrappedConstantValue = new Integer(fieldConstant.intValue());
					break;
				case TypeIds.T_byte :
					this.wrappedConstantValue = new Byte(fieldConstant.byteValue());
					break;
				case TypeIds.T_short :
					this.wrappedConstantValue = new Short(fieldConstant.shortValue());
					break;
				case TypeIds.T_char :
					this.wrappedConstantValue = new Character(fieldConstant.charValue());
					break;
				case TypeIds.T_float :
					this.wrappedConstantValue = new Float(fieldConstant.floatValue());
					break;
				case TypeIds.T_double :
					this.wrappedConstantValue = new Double(fieldConstant.doubleValue());
					break;
				case TypeIds.T_boolean :
					this.wrappedConstantValue = Util.toBoolean(fieldConstant.booleanValue());
					break;
				case TypeIds.T_long :
					this.wrappedConstantValue = new Long(fieldConstant.longValue());
					break;
				case TypeIds.T_JavaLangString :
					this.wrappedConstantValue = fieldConstant.stringValue();
			}
		}
	}
	return this.wrappedConstantValue;
}
 
Example 12
Source File: Util.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
public static Object getAnnotationMemberValue(MemberValuePair memberValuePair, Constant constant) {
	if (constant == null) {
		memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
		return null;
	}
	switch (constant.typeID()) {
		case TypeIds.T_int :
			memberValuePair.valueKind = IMemberValuePair.K_INT;
			return new Integer(constant.intValue());
		case TypeIds.T_byte :
			memberValuePair.valueKind = IMemberValuePair.K_BYTE;
			return new Byte(constant.byteValue());
		case TypeIds.T_short :
			memberValuePair.valueKind = IMemberValuePair.K_SHORT;
			return new Short(constant.shortValue());
		case TypeIds.T_char :
			memberValuePair.valueKind = IMemberValuePair.K_CHAR;
			return new Character(constant.charValue());
		case TypeIds.T_float :
			memberValuePair.valueKind = IMemberValuePair.K_FLOAT;
			return new Float(constant.floatValue());
		case TypeIds.T_double :
			memberValuePair.valueKind = IMemberValuePair.K_DOUBLE;
			return new Double(constant.doubleValue());
		case TypeIds.T_boolean :
			memberValuePair.valueKind = IMemberValuePair.K_BOOLEAN;
			return Boolean.valueOf(constant.booleanValue());
		case TypeIds.T_long :
			memberValuePair.valueKind = IMemberValuePair.K_LONG;
			return new Long(constant.longValue());
		case TypeIds.T_JavaLangString :
			memberValuePair.valueKind = IMemberValuePair.K_STRING;
			return constant.stringValue();
		default:
			memberValuePair.valueKind = IMemberValuePair.K_UNKNOWN;
			return null;
	}
}
 
Example 13
Source File: Member.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
/**
 * Converts a field constant from the compiler's representation
 * to the Java Model constant representation (Number or String).
 */
protected static Object convertConstant(Constant constant) {
	if (constant == null)
		return null;
	if (constant == Constant.NotAConstant) {
		return null;
	}
	switch (constant.typeID()) {
		case TypeIds.T_boolean :
			return constant.booleanValue() ? Boolean.TRUE : Boolean.FALSE;
		case TypeIds.T_byte :
			return new Byte(constant.byteValue());
		case TypeIds.T_char :
			return new Character(constant.charValue());
		case TypeIds.T_double :
			return new Double(constant.doubleValue());
		case TypeIds.T_float :
			return new Float(constant.floatValue());
		case TypeIds.T_int :
			return new Integer(constant.intValue());
		case TypeIds.T_long :
			return new Long(constant.longValue());
		case TypeIds.T_short :
			return new Short(constant.shortValue());
		case TypeIds.T_JavaLangString :
			return constant.stringValue();
		default :
			return null;
	}
}
 
Example 14
Source File: VariableElementImpl.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 5 votes vote down vote up
@Override
public Object getConstantValue() {
	VariableBinding variableBinding = (VariableBinding) _binding;
	Constant constant = variableBinding.constant();
	if (constant == null || constant == Constant.NotAConstant) return null;
	TypeBinding type = variableBinding.type;
	switch (type.id) {
		case TypeIds.T_boolean:
			return constant.booleanValue();
		case TypeIds.T_byte:
			return constant.byteValue();
		case TypeIds.T_char:
			return constant.charValue();
		case TypeIds.T_double:
			return constant.doubleValue();
		case TypeIds.T_float:
			return constant.floatValue();
		case TypeIds.T_int:
			return constant.intValue();
		case TypeIds.T_JavaLangString:
			return constant.stringValue();
		case TypeIds.T_long:
			return constant.longValue();
		case TypeIds.T_short:
			return constant.shortValue();
	}
	return null;
}
 
Example 15
Source File: Eclipse.java    From EasyMPermission with MIT License 5 votes vote down vote up
/**
 * Returns the actual value of the given Literal or Literal-like node.
 */
public static Object calculateValue(Expression e) {
	if (e instanceof Literal) {
		((Literal)e).computeConstant();
		switch (e.constant.typeID()) {
		case TypeIds.T_int: return e.constant.intValue();
		case TypeIds.T_byte: return e.constant.byteValue();
		case TypeIds.T_short: return e.constant.shortValue();
		case TypeIds.T_char: return e.constant.charValue();
		case TypeIds.T_float: return e.constant.floatValue();
		case TypeIds.T_double: return e.constant.doubleValue();
		case TypeIds.T_boolean: return e.constant.booleanValue();
		case TypeIds.T_long: return e.constant.longValue();
		case TypeIds.T_JavaLangString: return e.constant.stringValue();
		default: return null;
		}
	} else if (e instanceof ClassLiteralAccess) {
		return Eclipse.toQualifiedName(((ClassLiteralAccess)e).type.getTypeName());
	} else if (e instanceof SingleNameReference) {
		return new String(((SingleNameReference)e).token);
	} else if (e instanceof QualifiedNameReference) {
		String qName = Eclipse.toQualifiedName(((QualifiedNameReference)e).tokens);
		int idx = qName.lastIndexOf('.');
		return idx == -1 ? qName : qName.substring(idx+1);
	}
	
	return null;
}
 
Example 16
Source File: ClassFileReader.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
private boolean hasStructuralFieldChanges(FieldInfo currentFieldInfo, FieldInfo otherFieldInfo) {
	// generic signature
	if (!CharOperation.equals(currentFieldInfo.getGenericSignature(), otherFieldInfo.getGenericSignature()))
		return true;
	if (currentFieldInfo.getModifiers() != otherFieldInfo.getModifiers())
		return true;
	if ((currentFieldInfo.getTagBits() & TagBits.AnnotationDeprecated) != (otherFieldInfo.getTagBits() & TagBits.AnnotationDeprecated))
		return true;
	if (hasStructuralAnnotationChanges(currentFieldInfo.getAnnotations(), otherFieldInfo.getAnnotations()))
		return true;
	if (!CharOperation.equals(currentFieldInfo.getName(), otherFieldInfo.getName()))
		return true;
	if (!CharOperation.equals(currentFieldInfo.getTypeName(), otherFieldInfo.getTypeName()))
		return true;
	if (currentFieldInfo.hasConstant() != otherFieldInfo.hasConstant())
		return true;
	if (currentFieldInfo.hasConstant()) {
		Constant currentConstant = currentFieldInfo.getConstant();
		Constant otherConstant = otherFieldInfo.getConstant();
		if (currentConstant.typeID() != otherConstant.typeID())
			return true;
		if (!currentConstant.getClass().equals(otherConstant.getClass()))
			return true;
		switch (currentConstant.typeID()) {
			case TypeIds.T_int :
				return currentConstant.intValue() != otherConstant.intValue();
			case TypeIds.T_byte :
				return currentConstant.byteValue() != otherConstant.byteValue();
			case TypeIds.T_short :
				return currentConstant.shortValue() != otherConstant.shortValue();
			case TypeIds.T_char :
				return currentConstant.charValue() != otherConstant.charValue();
			case TypeIds.T_long :
				return currentConstant.longValue() != otherConstant.longValue();
			case TypeIds.T_float :
				return currentConstant.floatValue() != otherConstant.floatValue();
			case TypeIds.T_double :
				return currentConstant.doubleValue() != otherConstant.doubleValue();
			case TypeIds.T_boolean :
				return currentConstant.booleanValue() != otherConstant.booleanValue();
			case TypeIds.T_JavaLangString :
				return !currentConstant.stringValue().equals(otherConstant.stringValue());
		}
	}
	return false;
}
 
Example 17
Source File: TypeReference.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public static final TypeReference baseTypeReference(int baseType, int dim, Annotation [][] dimAnnotations) {

	if (dim == 0) {
		switch (baseType) {
			case (TypeIds.T_void) :
				return new SingleTypeReference(TypeBinding.VOID.simpleName, 0);
			case (TypeIds.T_boolean) :
				return new SingleTypeReference(TypeBinding.BOOLEAN.simpleName, 0);
			case (TypeIds.T_char) :
				return new SingleTypeReference(TypeBinding.CHAR.simpleName, 0);
			case (TypeIds.T_float) :
				return new SingleTypeReference(TypeBinding.FLOAT.simpleName, 0);
			case (TypeIds.T_double) :
				return new SingleTypeReference(TypeBinding.DOUBLE.simpleName, 0);
			case (TypeIds.T_byte) :
				return new SingleTypeReference(TypeBinding.BYTE.simpleName, 0);
			case (TypeIds.T_short) :
				return new SingleTypeReference(TypeBinding.SHORT.simpleName, 0);
			case (TypeIds.T_int) :
				return new SingleTypeReference(TypeBinding.INT.simpleName, 0);
			default : //T_long
				return new SingleTypeReference(TypeBinding.LONG.simpleName, 0);
		}
	}
	switch (baseType) {
		case (TypeIds.T_void) :
			return new ArrayTypeReference(TypeBinding.VOID.simpleName, dim, dimAnnotations, 0);
		case (TypeIds.T_boolean) :
			return new ArrayTypeReference(TypeBinding.BOOLEAN.simpleName, dim, dimAnnotations, 0);
		case (TypeIds.T_char) :
			return new ArrayTypeReference(TypeBinding.CHAR.simpleName, dim, dimAnnotations, 0);
		case (TypeIds.T_float) :
			return new ArrayTypeReference(TypeBinding.FLOAT.simpleName, dim, dimAnnotations, 0);
		case (TypeIds.T_double) :
			return new ArrayTypeReference(TypeBinding.DOUBLE.simpleName, dim, dimAnnotations, 0);
		case (TypeIds.T_byte) :
			return new ArrayTypeReference(TypeBinding.BYTE.simpleName, dim, dimAnnotations, 0);
		case (TypeIds.T_short) :
			return new ArrayTypeReference(TypeBinding.SHORT.simpleName, dim, dimAnnotations, 0);
		case (TypeIds.T_int) :
			return new ArrayTypeReference(TypeBinding.INT.simpleName, dim, dimAnnotations, 0);
		default : //T_long
			return new ArrayTypeReference(TypeBinding.LONG.simpleName, dim, dimAnnotations, 0);
	}
}
 
Example 18
Source File: Expression.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
/**
 * Base types need that the widening is explicitly done by the compiler using some bytecode like i2f.
 * Also check unsafe type operations.
 */
public void computeConversion(Scope scope, TypeBinding runtimeType, TypeBinding compileTimeType) {
	if (runtimeType == null || compileTimeType == null)
		return;
	if (this.implicitConversion != 0) return; // already set independently

	// it is possible for a Byte to be unboxed to a byte & then converted to an int
	// but it is not possible for a byte to become Byte & then assigned to an Integer,
	// or to become an int before boxed into an Integer
	if (runtimeType != TypeBinding.NULL && runtimeType.isBaseType()) {
		if (!compileTimeType.isBaseType()) {
			TypeBinding unboxedType = scope.environment().computeBoxingType(compileTimeType);
			this.implicitConversion = TypeIds.UNBOXING;
			scope.problemReporter().autoboxing(this, compileTimeType, runtimeType);
			compileTimeType = unboxedType;
		}
	} else if (compileTimeType != TypeBinding.NULL && compileTimeType.isBaseType()) {
		TypeBinding boxedType = scope.environment().computeBoxingType(runtimeType);
		if (TypeBinding.equalsEquals(boxedType, runtimeType)) // Object o = 12;
			boxedType = compileTimeType;
		this.implicitConversion = TypeIds.BOXING | (boxedType.id << 4) + compileTimeType.id;
		scope.problemReporter().autoboxing(this, compileTimeType, scope.environment().computeBoxingType(boxedType));
		return;
	} else if (this.constant != Constant.NotAConstant && this.constant.typeID() != TypeIds.T_JavaLangString) {
		this.implicitConversion = TypeIds.BOXING;
		return;
	}
	int compileTimeTypeID, runtimeTypeID;
	if ((compileTimeTypeID = compileTimeType.id) >= TypeIds.T_LastWellKnownTypeId) { // e.g. ? extends String  ==> String (103227); >= TypeIds.T_LastWellKnownTypeId implies TypeIds.NoId
		compileTimeTypeID = compileTimeType.erasure().id == TypeIds.T_JavaLangString ? TypeIds.T_JavaLangString : TypeIds.T_JavaLangObject;
	} else if (runtimeType.isPrimitiveType() && compileTimeType instanceof ReferenceBinding && !compileTimeType.isBoxedPrimitiveType()) {
		compileTimeTypeID = TypeIds.T_JavaLangObject; // treatment is the same as for jlO.
	}

	switch (runtimeTypeID = runtimeType.id) {
		case T_byte :
		case T_short :
		case T_char :
			if (compileTimeTypeID == TypeIds.T_JavaLangObject) {
				this.implicitConversion |= (runtimeTypeID << 4) + compileTimeTypeID;
			} else {
				this.implicitConversion |= (TypeIds.T_int << 4) + compileTimeTypeID;
			}
			break;
		case T_JavaLangString :
		case T_float :
		case T_boolean :
		case T_double :
		case T_int : //implicitConversion may result in i2i which will result in NO code gen
		case T_long :
			this.implicitConversion |= (runtimeTypeID << 4) + compileTimeTypeID;
			break;
		default : // regular object ref
//				if (compileTimeType.isRawType() && runtimeTimeType.isBoundParameterizedType()) {
//				    scope.problemReporter().unsafeRawExpression(this, compileTimeType, runtimeTimeType);
//				}
	}
}
 
Example 19
Source File: MemberValuePairBinding.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
static Object buildDOMValue(final Object internalObject, BindingResolver resolver) {
	if (internalObject == null)
		return null;

	if (internalObject instanceof Constant) {
		Constant constant = (Constant) internalObject;
		switch (constant.typeID()) {
			case TypeIds.T_boolean:
				return Boolean.valueOf(constant.booleanValue());
			case TypeIds.T_byte:
				return new Byte(constant.byteValue());
			case TypeIds.T_char:
				return new Character(constant.charValue());
			case TypeIds.T_double:
				return new Double(constant.doubleValue());
			case TypeIds.T_float:
				return new Float(constant.floatValue());
			case TypeIds.T_int:
				return new Integer(constant.intValue());
			case TypeIds.T_long:
				return new Long(constant.longValue());
			case TypeIds.T_short:
				return new Short(constant.shortValue());
			default:
				// TypeIds.T_JavaLangString:
				return constant.stringValue();
		}
	} else if (internalObject instanceof org.eclipse.jdt.internal.compiler.lookup.TypeBinding) {
		return resolver.getTypeBinding((org.eclipse.jdt.internal.compiler.lookup.TypeBinding) internalObject);
	} else if (internalObject instanceof org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding) {
		return resolver.getAnnotationInstance((org.eclipse.jdt.internal.compiler.lookup.AnnotationBinding) internalObject);
	} else if (internalObject instanceof org.eclipse.jdt.internal.compiler.lookup.FieldBinding) {
		return resolver.getVariableBinding((org.eclipse.jdt.internal.compiler.lookup.FieldBinding) internalObject);
	} else if (internalObject instanceof Object[]) {
		Object[] elements = (Object[]) internalObject;
		int length = elements.length;
		Object[] values = length == 0 ? EmptyArray : new Object[length];
		for (int i = 0; i < length; i++)
			values[i] = buildDOMValue(elements[i], resolver);
		return values;
	}
	return null;
}
 
Example 20
Source File: VerificationTypeInfo.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 4 votes vote down vote up
public void replaceWithElementType() {
	if (this.constantPoolName[1] == 'L') {
		this.constantPoolName = CharOperation.subarray(this.constantPoolName, 2,  this.constantPoolName.length - 1);
	} else {
		this.constantPoolName = CharOperation.subarray(this.constantPoolName, 1, this.constantPoolName.length);
		if (this.constantPoolName.length == 1) {
			switch(this.constantPoolName[0]) {
				case 'I' :
					this.id = TypeIds.T_int;
					break;
				case 'B' :
					this.id = TypeIds.T_byte;
					break;
				case 'S' :
					this.id = TypeIds.T_short;
					break;
				case 'C' :
					this.id = TypeIds.T_char;
					break;
				case 'J' :
					this.id = TypeIds.T_long;
					break;
				case 'F' :
					this.id = TypeIds.T_float;
					break;
				case 'D' :
					this.id = TypeIds.T_double;
					break;
				case 'Z' :
					this.id = TypeIds.T_boolean;
					break;
				case 'N' :
					this.id = TypeIds.T_null;
					break;
				case 'V' :
					this.id = TypeIds.T_void;
					break;
			}
		}
	}
}