org.eclipse.jdt.internal.compiler.lookup.TypeIds Java Examples
The following examples show how to use
org.eclipse.jdt.internal.compiler.lookup.TypeIds.
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: TypeReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
/** Retrieve the null annotation that has been translated to the given nullTagBits. */ public Annotation findAnnotation(long nullTagBits) { if (this.annotations != null) { Annotation[] innerAnnotations = this.annotations[this.annotations.length-1]; if (innerAnnotations != null) { int annId = nullTagBits == TagBits.AnnotationNonNull ? TypeIds.T_ConfiguredAnnotationNonNull : TypeIds.T_ConfiguredAnnotationNullable; for (int i = 0; i < innerAnnotations.length; i++) { if (innerAnnotations[i] != null && innerAnnotations[i].resolvedType != null && innerAnnotations[i].resolvedType.id == annId) return innerAnnotations[i]; } } } return null; }
Example #2
Source File: LambdaExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public void returnsExpression(Expression expression, TypeBinding resultType) { if (this.original == this) // not in overload resolution context. return; if (this.body instanceof Expression) { this.original.valueCompatible = resultType != null && resultType.id != TypeIds.T_void; this.original.resultExpressions = new Expression[1]; this.original.resultExpressions[0] = expression; return; // void compatibility determined via statementExpression() } if (expression != null) { this.original.returnsValue = true; this.original.voidCompatible = false; this.original.valueCompatible = !this.original.returnsVoid; if (resultType != null) { Expression [] returnExpressions = this.original.resultExpressions; int resultsLength = returnExpressions.length; System.arraycopy(returnExpressions, 0, returnExpressions = new Expression[resultsLength + 1], 0, resultsLength); returnExpressions[resultsLength] = expression; this.original.resultExpressions = returnExpressions; } } else { this.original.returnsVoid = true; this.original.valueCompatible = false; this.original.voidCompatible = !this.original.returnsValue; } }
Example #3
Source File: LambdaExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public TypeBinding[] getMarkerInterfaces() { if (this.expectedType instanceof IntersectionCastTypeBinding) { Set markerBindings = new LinkedHashSet(); TypeBinding[] intersectionTypes = ((IntersectionCastTypeBinding)this.expectedType).intersectingTypes; for (int i = 0,max = intersectionTypes.length; i < max; i++) { TypeBinding typeBinding = intersectionTypes[i]; MethodBinding methodBinding = typeBinding.getSingleAbstractMethod(this.scope, true); // Why doesn't getSingleAbstractMethod do as the javadoc says, and return null // when it is not a SAM type if (!(methodBinding instanceof ProblemMethodBinding && ((ProblemMethodBinding)methodBinding).problemId()==ProblemReasons.NoSuchSingleAbstractMethod)) { continue; } if (typeBinding.id == TypeIds.T_JavaIoSerializable) { // Serializable is captured as a bitflag continue; } markerBindings.add(typeBinding); } if (markerBindings.size() > 0) { return (TypeBinding[])markerBindings.toArray(new TypeBinding[markerBindings.size()]); } } return null; }
Example #4
Source File: DefaultBindingResolver.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 #5
Source File: VariableBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 #6
Source File: Reference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
void reportOnlyUselesslyReadPrivateField(BlockScope currentScope, FieldBinding fieldBinding, boolean valueRequired) { if (valueRequired) { // access is relevant, turn compound use into real use: fieldBinding.compoundUseFlag = 0; fieldBinding.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; } else { if (fieldBinding.isUsedOnlyInCompound()) { fieldBinding.compoundUseFlag--; // consume one if (fieldBinding.compoundUseFlag == 0 // report only the last usage && fieldBinding.isOrEnclosedByPrivateType() && (this.implicitConversion & TypeIds.UNBOXING) == 0) // don't report if unboxing is involved (might cause NPE) { // compoundAssignment/postIncrement is the only usage of this field currentScope.problemReporter().unusedPrivateField(fieldBinding.sourceField()); fieldBinding.modifiers |= ExtraCompilerModifiers.AccLocallyUsed; // don't report again } } } }
Example #7
Source File: PrimitiveTypeImpl.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 #8
Source File: Util.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 #9
Source File: Sorting.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
private static int sortSuper(ReferenceBinding superclass, ReferenceBinding[] input, ReferenceBinding[] output, int o) { if (superclass.id != TypeIds.T_JavaLangObject) { // search superclass within input: int j = 0; for(j=0; j<input.length; j++) if (TypeBinding.equalsEquals(input[j], superclass)) break; if (j < input.length) // depth first traversal: o = sort(input, j, output, o); // otherwise assume super was already transferred. } return o; }
Example #10
Source File: BaseTypeBinding.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
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 #11
Source File: HandleBuilder.java From EasyMPermission with MIT License | 6 votes |
private MethodDeclaration generateCleanMethod(List<BuilderFieldData> builderFields, EclipseNode builderType, ASTNode source) { List<Statement> statements = new ArrayList<Statement>(); for (BuilderFieldData bfd : builderFields) { if (bfd.singularData != null && bfd.singularData.getSingularizer() != null) { bfd.singularData.getSingularizer().appendCleaningCode(bfd.singularData, builderType, statements); } } FieldReference thisUnclean = new FieldReference(CLEAN_FIELD_NAME, 0); thisUnclean.receiver = new ThisReference(0, 0); statements.add(new Assignment(thisUnclean, new FalseLiteral(0, 0), 0)); MethodDeclaration decl = new MethodDeclaration(((CompilationUnitDeclaration) builderType.top().get()).compilationResult); decl.selector = CLEAN_METHOD_NAME; decl.modifiers = ClassFileConstants.AccPrivate; decl.bits |= ECLIPSE_DO_NOT_TOUCH_FLAG; decl.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0); decl.statements = statements.toArray(new Statement[0]); decl.traverse(new SetGeneratedByVisitor(source), (ClassScope) null); return decl; }
Example #12
Source File: StackMapFrame.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 6 votes |
public int getNumberOfLocals() { if (this.numberOfLocals != -1) { return this.numberOfLocals; } int result = 0; final int length = this.locals == null ? 0 : this.locals.length; for(int i = 0; i < length; i++) { if (this.locals[i] != null) { switch(this.locals[i].id()) { case TypeIds.T_double : case TypeIds.T_long : i++; } result++; } } this.numberOfLocals = result; return result; }
Example #13
Source File: ReferenceExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public boolean sIsMoreSpecific(TypeBinding s, TypeBinding t, Scope scope) { if (super.sIsMoreSpecific(s, t, scope)) return true; if (this.exactMethodBinding == null || t.findSuperTypeOriginatingFrom(s) != null) return false; s = s.capture(this.enclosingScope, this.sourceEnd); MethodBinding sSam = s.getSingleAbstractMethod(this.enclosingScope, true); if (sSam == null || !sSam.isValidBinding()) return false; TypeBinding r1 = sSam.returnType; MethodBinding tSam = t.getSingleAbstractMethod(this.enclosingScope, true); if (tSam == null || !tSam.isValidBinding()) return false; TypeBinding r2 = tSam.returnType; if (r2.id == TypeIds.T_void) return true; if (r1.id == TypeIds.T_void) return false; // r1 <: r2 if (r1.isCompatibleWith(r2, scope)) return true; return r1.isBaseType() != r2.isBaseType() && r1.isBaseType() == this.exactMethodBinding.returnType.isBaseType(); }
Example #14
Source File: Expression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void generateOptimizedStringConcatenationCreation(BlockScope blockScope, CodeStream codeStream, int typeID) { codeStream.newStringContatenation(); codeStream.dup(); switch (typeID) { case T_JavaLangObject : case T_undefined : // in the case the runtime value of valueOf(Object) returns null, we have to use append(Object) instead of directly valueOf(Object) // append(Object) returns append(valueOf(Object)), which means that the null case is handled by the next case. codeStream.invokeStringConcatenationDefaultConstructor(); generateCode(blockScope, codeStream, true); codeStream.invokeStringConcatenationAppendForType(TypeIds.T_JavaLangObject); return; case T_JavaLangString : case T_null : if (this.constant != Constant.NotAConstant) { String stringValue = this.constant.stringValue(); if (stringValue.length() == 0) { // optimize ""+<str> codeStream.invokeStringConcatenationDefaultConstructor(); return; } codeStream.ldc(stringValue); } else { // null case is not a constant generateCode(blockScope, codeStream, true); codeStream.invokeStringValueOf(TypeIds.T_JavaLangObject); } break; default : generateCode(blockScope, codeStream, true); codeStream.invokeStringValueOf(typeID); } codeStream.invokeStringConcatenationStringConstructor(); }
Example #15
Source File: Expression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns the type of the expression after required implicit conversions. When expression type gets promoted * or inserted a generic cast, the converted type will differ from the resolved type (surface side-effects from * #computeConversion(...)). * @return the type after implicit conversion */ public TypeBinding postConversionType(Scope scope) { TypeBinding convertedType = this.resolvedType; int runtimeType = (this.implicitConversion & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4; switch (runtimeType) { case T_boolean : convertedType = TypeBinding.BOOLEAN; break; case T_byte : convertedType = TypeBinding.BYTE; break; case T_short : convertedType = TypeBinding.SHORT; break; case T_char : convertedType = TypeBinding.CHAR; break; case T_int : convertedType = TypeBinding.INT; break; case T_float : convertedType = TypeBinding.FLOAT; break; case T_long : convertedType = TypeBinding.LONG; break; case T_double : convertedType = TypeBinding.DOUBLE; break; default : } if ((this.implicitConversion & TypeIds.BOXING) != 0) { convertedType = scope.environment().computeBoxingType(convertedType); } return convertedType; }
Example #16
Source File: CombinedBinaryExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) { // keep implementation in sync with BinaryExpression#analyseCode if (this.referencesTable == null) { return super.analyseCode(currentScope, flowContext, flowInfo); } try { BinaryExpression cursor; if ((cursor = this.referencesTable[0]).resolvedType.id != TypeIds.T_JavaLangString) { cursor.left.checkNPE(currentScope, flowContext, flowInfo); } flowInfo = cursor.left.analyseCode(currentScope, flowContext, flowInfo). unconditionalInits(); for (int i = 0, end = this.arity; i < end; i ++) { if ((cursor = this.referencesTable[i]).resolvedType.id != TypeIds.T_JavaLangString) { cursor.right.checkNPE(currentScope, flowContext, flowInfo); } flowInfo = cursor.right. analyseCode(currentScope, flowContext, flowInfo). unconditionalInits(); } if (this.resolvedType.id != TypeIds.T_JavaLangString) { this.right.checkNPE(currentScope, flowContext, flowInfo); } return this.right.analyseCode(currentScope, flowContext, flowInfo). unconditionalInits(); } finally { // account for exception possibly thrown by arithmetics flowContext.recordAbruptExit(); } }
Example #17
Source File: ThrowStatement.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void resolve(BlockScope scope) { this.exceptionType = this.exception.resolveType(scope); recordExceptionsForEnclosingLambda(scope, this.exceptionType); if (this.exceptionType != null && this.exceptionType.isValidBinding()) { if (this.exceptionType == TypeBinding.NULL) { if (scope.compilerOptions().complianceLevel <= ClassFileConstants.JDK1_3){ // if compliant with 1.4, this problem will not be reported scope.problemReporter().cannotThrowNull(this.exception); } } else if (this.exceptionType.findSuperTypeOriginatingFrom(TypeIds.T_JavaLangThrowable, true) == null) { scope.problemReporter().cannotThrowType(this.exception, this.exceptionType); } this.exception.computeConversion(scope, this.exceptionType, this.exceptionType); } }
Example #18
Source File: FieldReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see org.eclipse.jdt.internal.compiler.ast.Expression#postConversionType(Scope) */ public TypeBinding postConversionType(Scope scope) { TypeBinding convertedType = this.resolvedType; if (this.genericCast != null) convertedType = this.genericCast; int runtimeType = (this.implicitConversion & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4; switch (runtimeType) { case T_boolean : convertedType = TypeBinding.BOOLEAN; break; case T_byte : convertedType = TypeBinding.BYTE; break; case T_short : convertedType = TypeBinding.SHORT; break; case T_char : convertedType = TypeBinding.CHAR; break; case T_int : convertedType = TypeBinding.INT; break; case T_float : convertedType = TypeBinding.FLOAT; break; case T_long : convertedType = TypeBinding.LONG; break; case T_double : convertedType = TypeBinding.DOUBLE; break; default : } if ((this.implicitConversion & TypeIds.BOXING) != 0) { convertedType = scope.environment().computeBoxingType(convertedType); } return convertedType; }
Example #19
Source File: ClassfileDigester.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
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 #20
Source File: QualifiedNameReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see org.eclipse.jdt.internal.compiler.ast.Expression#postConversionType(Scope) */ public TypeBinding postConversionType(Scope scope) { TypeBinding convertedType = this.resolvedType; TypeBinding requiredGenericCast = getGenericCast(this.otherBindings == null ? 0 : this.otherBindings.length); if (requiredGenericCast != null) convertedType = requiredGenericCast; int runtimeType = (this.implicitConversion & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4; switch (runtimeType) { case T_boolean : convertedType = TypeBinding.BOOLEAN; break; case T_byte : convertedType = TypeBinding.BYTE; break; case T_short : convertedType = TypeBinding.SHORT; break; case T_char : convertedType = TypeBinding.CHAR; break; case T_int : convertedType = TypeBinding.INT; break; case T_float : convertedType = TypeBinding.FLOAT; break; case T_long : convertedType = TypeBinding.LONG; break; case T_double : convertedType = TypeBinding.DOUBLE; break; default : } if ((this.implicitConversion & TypeIds.BOXING) != 0) { convertedType = scope.environment().computeBoxingType(convertedType); } return convertedType; }
Example #21
Source File: Expression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Returns an object which can be used to identify identical JSR sequence targets * (see TryStatement subroutine codegen) * or <code>null</null> if not reusable */ public Object reusableJSRTarget() { if (this.constant != Constant.NotAConstant && (this.implicitConversion & TypeIds.BOXING) == 0) { return this.constant; } return null; }
Example #22
Source File: CastExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Cast expression code generation * * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream * @param valueRequired boolean */ public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { int pc = codeStream.position; boolean annotatedCast = (this.type.bits & ASTNode.HasTypeAnnotations) != 0; boolean needRuntimeCheckcast = (this.bits & ASTNode.GenerateCheckcast) != 0; if (this.constant != Constant.NotAConstant) { if (valueRequired || needRuntimeCheckcast || annotatedCast) { // Added for: 1F1W9IG: IVJCOM:WINNT - Compiler omits casting check codeStream.generateConstant(this.constant, this.implicitConversion); if (needRuntimeCheckcast || annotatedCast) { codeStream.checkcast(this.type, this.resolvedType); } if (!valueRequired) { // the resolveType cannot be double or long codeStream.pop(); } } codeStream.recordPositionsFrom(pc, this.sourceStart); return; } this.expression.generateCode(currentScope, codeStream, annotatedCast || valueRequired || needRuntimeCheckcast); if (annotatedCast || (needRuntimeCheckcast && TypeBinding.notEquals(this.expression.postConversionType(currentScope), this.resolvedType.erasure()))) { // no need to issue a checkcast if already done as genericCast codeStream.checkcast(this.type, this.resolvedType); } if (valueRequired) { codeStream.generateImplicitConversion(this.implicitConversion); } else if (needRuntimeCheckcast) { boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0; switch (isUnboxing ? postConversionType(currentScope).id : this.resolvedType.id) { case T_long : case T_double : codeStream.pop2(); break; default : codeStream.pop(); break; } } codeStream.recordPositionsFrom(pc, this.sourceStart); }
Example #23
Source File: CastExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * Cast expressions will considered as useful if removing them all would actually bind to a different method * (no fine grain analysis on per casted argument basis, simply separate widening cast from narrowing ones) */ public static void checkNeedForArgumentCasts(BlockScope scope, Expression receiver, TypeBinding receiverType, MethodBinding binding, Expression[] arguments, TypeBinding[] argumentTypes, final InvocationSite invocationSite) { if (scope.compilerOptions().getSeverity(CompilerOptions.UnnecessaryTypeCheck) == ProblemSeverities.Ignore) return; int length = argumentTypes.length; // iterate over arguments, and retrieve original argument types (before cast) TypeBinding[] rawArgumentTypes = argumentTypes; for (int i = 0; i < length; i++) { Expression argument = arguments[i]; if (argument instanceof CastExpression) { // narrowing conversion on base type may change value, thus necessary if ((argument.bits & ASTNode.UnnecessaryCast) == 0 && argument.resolvedType.isBaseType()) { continue; } TypeBinding castedExpressionType = ((CastExpression)argument).expression.resolvedType; if (castedExpressionType == null) return; // cannot do better // obvious identity cast if (TypeBinding.equalsEquals(castedExpressionType, argumentTypes[i])) { scope.problemReporter().unnecessaryCast((CastExpression)argument); } else if (castedExpressionType == TypeBinding.NULL){ continue; // tolerate null argument cast } else if ((argument.implicitConversion & TypeIds.BOXING) != 0) { continue; // boxing has a side effect: (int) char is not boxed as simple char } else { if (rawArgumentTypes == argumentTypes) { System.arraycopy(rawArgumentTypes, 0, rawArgumentTypes = new TypeBinding[length], 0, length); } // retain original argument type rawArgumentTypes[i] = castedExpressionType; } } } // perform alternate lookup with original types if (rawArgumentTypes != argumentTypes) { checkAlternateBinding(scope, receiver, receiverType, binding, arguments, argumentTypes, rawArgumentTypes, invocationSite); } }
Example #24
Source File: ArrayReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void generatePostIncrement(BlockScope currentScope, CodeStream codeStream, CompoundAssignment postIncrement, boolean valueRequired) { this.receiver.generateCode(currentScope, codeStream, true); if (this.receiver instanceof CastExpression // ((type[])null)[0] && ((CastExpression)this.receiver).innermostCastedExpression().resolvedType == TypeBinding.NULL){ codeStream.checkcast(this.receiver.resolvedType); } this.position.generateCode(currentScope, codeStream, true); codeStream.dup2(); codeStream.arrayAt(this.resolvedType.id); if (valueRequired) { switch(this.resolvedType.id) { case TypeIds.T_long : case TypeIds.T_double : codeStream.dup2_x2(); break; default : codeStream.dup_x2(); break; } } codeStream.generateImplicitConversion(this.implicitConversion); codeStream.generateConstant( postIncrement.expression.constant, this.implicitConversion); codeStream.sendOperator(postIncrement.operator, this.implicitConversion & TypeIds.COMPILE_TYPE_MASK); codeStream.generateImplicitConversion( postIncrement.preAssignImplicitConversion); codeStream.arrayAtPut(this.resolvedType.id, false); }
Example #25
Source File: ArrayReference.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void generateCompoundAssignment(BlockScope currentScope, CodeStream codeStream, Expression expression, int operator, int assignmentImplicitConversion, boolean valueRequired) { this.receiver.generateCode(currentScope, codeStream, true); if (this.receiver instanceof CastExpression // ((type[])null)[0] && ((CastExpression)this.receiver).innermostCastedExpression().resolvedType == TypeBinding.NULL){ codeStream.checkcast(this.receiver.resolvedType); } this.position.generateCode(currentScope, codeStream, true); codeStream.dup2(); codeStream.arrayAt(this.resolvedType.id); int operationTypeID; switch(operationTypeID = (this.implicitConversion & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4) { case T_JavaLangString : case T_JavaLangObject : case T_undefined : codeStream.generateStringConcatenationAppend(currentScope, null, expression); break; default : // promote the array reference to the suitable operation type codeStream.generateImplicitConversion(this.implicitConversion); // generate the increment value (will by itself be promoted to the operation value) if (expression == IntLiteral.One) { // prefix operation codeStream.generateConstant(expression.constant, this.implicitConversion); } else { expression.generateCode(currentScope, codeStream, true); } // perform the operation codeStream.sendOperator(operator, operationTypeID); // cast the value back to the array reference type codeStream.generateImplicitConversion(assignmentImplicitConversion); } codeStream.arrayAtPut(this.resolvedType.id, valueRequired); }
Example #26
Source File: Eclipse.java From EasyMPermission with MIT License | 5 votes |
/** * 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 #27
Source File: MessageSend.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see org.eclipse.jdt.internal.compiler.ast.Expression#postConversionType(Scope) */ public TypeBinding postConversionType(Scope scope) { TypeBinding convertedType = this.resolvedType; if (this.valueCast != null) convertedType = this.valueCast; int runtimeType = (this.implicitConversion & TypeIds.IMPLICIT_CONVERSION_MASK) >> 4; switch (runtimeType) { case T_boolean : convertedType = TypeBinding.BOOLEAN; break; case T_byte : convertedType = TypeBinding.BYTE; break; case T_short : convertedType = TypeBinding.SHORT; break; case T_char : convertedType = TypeBinding.CHAR; break; case T_int : convertedType = TypeBinding.INT; break; case T_float : convertedType = TypeBinding.FLOAT; break; case T_long : convertedType = TypeBinding.LONG; break; case T_double : convertedType = TypeBinding.DOUBLE; break; default : } if ((this.implicitConversion & TypeIds.BOXING) != 0) { convertedType = scope.environment().computeBoxingType(convertedType); } return convertedType; }
Example #28
Source File: LambdaExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
public void addSyntheticArgument(LocalVariableBinding actualOuterLocalVariable) { if (this.original != this || this.binding == null) return; // Do not bother tracking outer locals for clones created during overload resolution. SyntheticArgumentBinding syntheticLocal = null; int newSlot = this.outerLocalVariables.length; for (int i = 0; i < newSlot; i++) { if (this.outerLocalVariables[i].actualOuterLocalVariable == actualOuterLocalVariable) return; } System.arraycopy(this.outerLocalVariables, 0, this.outerLocalVariables = new SyntheticArgumentBinding[newSlot + 1], 0, newSlot); this.outerLocalVariables[newSlot] = syntheticLocal = new SyntheticArgumentBinding(actualOuterLocalVariable); syntheticLocal.resolvedPosition = this.outerLocalVariablesSlotSize; // may need adjusting later if we need to generate an instance method for the lambda. syntheticLocal.declaringScope = this.scope; int parameterCount = this.binding.parameters.length; TypeBinding [] newParameters = new TypeBinding[parameterCount + 1]; newParameters[newSlot] = actualOuterLocalVariable.type; for (int i = 0, j = 0; i < parameterCount; i++, j++) { if (i == newSlot) j++; newParameters[j] = this.binding.parameters[i]; } this.binding.parameters = newParameters; switch (syntheticLocal.type.id) { case TypeIds.T_long : case TypeIds.T_double : this.outerLocalVariablesSlotSize += 2; break; default : this.outerLocalVariablesSlotSize++; break; } }
Example #29
Source File: LambdaExpression.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
private void mergeParameterNullAnnotations(BlockScope currentScope) { LookupEnvironment env = currentScope.environment(); TypeBinding[] ourParameters = this.binding.parameters; TypeBinding[] descParameters = this.descriptor.parameters; int len = Math.min(ourParameters.length, descParameters.length); for (int i = 0; i < len; i++) { long ourTagBits = ourParameters[i].tagBits & TagBits.AnnotationNullMASK; long descTagBits = descParameters[i].tagBits & TagBits.AnnotationNullMASK; if (ourTagBits == 0L) { if (descTagBits != 0L && !ourParameters[i].isBaseType()) { AnnotationBinding [] annotations = descParameters[i].getTypeAnnotations(); for (int j = 0, length = annotations.length; j < length; j++) { AnnotationBinding annotation = annotations[j]; if (annotation != null) { switch (annotation.getAnnotationType().id) { case TypeIds.T_ConfiguredAnnotationNullable : case TypeIds.T_ConfiguredAnnotationNonNull : ourParameters[i] = env.createAnnotatedType(ourParameters[i], new AnnotationBinding [] { annotation }); break; } } } } } else if (ourTagBits != descTagBits) { if (ourTagBits == TagBits.AnnotationNonNull) { // requested @NonNull not provided char[][] inheritedAnnotationName = null; if (descTagBits == TagBits.AnnotationNullable) inheritedAnnotationName = env.getNullableAnnotationName(); currentScope.problemReporter().illegalRedefinitionToNonNullParameter(this.arguments[i], this.descriptor.declaringClass, inheritedAnnotationName); } } } }
Example #30
Source File: MessageSend.java From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 | 5 votes |
/** * @see org.eclipse.jdt.internal.compiler.ast.Expression#computeConversion(org.eclipse.jdt.internal.compiler.lookup.Scope, org.eclipse.jdt.internal.compiler.lookup.TypeBinding, org.eclipse.jdt.internal.compiler.lookup.TypeBinding) */ public void computeConversion(Scope scope, TypeBinding runtimeTimeType, TypeBinding compileTimeType) { if (runtimeTimeType == null || compileTimeType == null) return; // set the generic cast after the fact, once the type expectation is fully known (no need for strict cast) if (this.binding != null && this.binding.isValidBinding()) { MethodBinding originalBinding = this.binding.original(); TypeBinding originalType = originalBinding.returnType; // extra cast needed if method return type is type variable if (originalType.leafComponentType().isTypeVariable()) { TypeBinding targetType = (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType()) ? compileTimeType // unboxing: checkcast before conversion : runtimeTimeType; this.valueCast = originalType.genericCast(targetType); } else if (this.binding == scope.environment().arrayClone && runtimeTimeType.id != TypeIds.T_JavaLangObject && scope.compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // from 1.5 source level on, array#clone() resolves to array type, but codegen to #clone()Object - thus require extra inserted cast this.valueCast = runtimeTimeType; } if (this.valueCast instanceof ReferenceBinding) { ReferenceBinding referenceCast = (ReferenceBinding) this.valueCast; if (!referenceCast.canBeSeenBy(scope)) { scope.problemReporter().invalidType(this, new ProblemReferenceBinding( CharOperation.splitOn('.', referenceCast.shortReadableName()), referenceCast, ProblemReasons.NotVisible)); } } } super.computeConversion(scope, runtimeTimeType, compileTimeType); }