Package org.eclipse.jdt.internal.compiler.lookup

Examples of org.eclipse.jdt.internal.compiler.lookup.TypeBinding


            codeStream.recordPositionsFrom(pc, this.sourceStart);
            return;
          }
          // managing private access
          if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
            TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, this.actualReceiverType, true /* implicit this */);
            codeStream.fieldAccess(Opcodes.OPC_getstatic, codegenField, constantPoolDeclaringClass);
          } else {
            codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
          }
        } else {
          if (!valueRequired
              && (this.implicitConversion & TypeIds.UNBOXING) == 0
              && this.genericCast == null) {
            // if no valueRequired, optimize out entire gen
            codeStream.recordPositionsFrom(pc, this.sourceStart);
            return;
          }
          // managing enclosing instance access
          if ((this.bits & ASTNode.DepthMASK) != 0) {
            ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT);
            Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
            codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
          } else {
            generateReceiver(codeStream);
          }
          // managing private access
          if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
            TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, this.actualReceiverType, true /* implicit this */);
            codeStream.fieldAccess(Opcodes.OPC_getfield, codegenField, constantPoolDeclaringClass);
          } else {
            codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
          }
        }
 
View Full Code Here


  switch (this.bits & ASTNode.RestrictiveFlagMASK) {
    case Binding.FIELD : // assigning to a field
      FieldBinding codegenField = ((FieldBinding) this.binding).original();
      if (codegenField.isStatic()) {
        if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
          TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, this.actualReceiverType, true /* implicit this */);         
          codeStream.fieldAccess(Opcodes.OPC_getstatic, codegenField, constantPoolDeclaringClass);
        } else {
          codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
        }
      } else {
        if ((this.bits & ASTNode.DepthMASK) != 0) {
          ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT);
          Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
          codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
        } else {
          codeStream.aload_0();
        }
        codeStream.dup();
        if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
          TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, this.actualReceiverType, true /* implicit this */);
          codeStream.fieldAccess(Opcodes.OPC_getfield, codegenField, constantPoolDeclaringClass);
        } else {
          codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
        }
      }
 
View Full Code Here

      // check if postIncrement is the only usage of a private field
      reportOnlyUselesslyReadPrivateField(currentScope, fieldBinding, valueRequired);
      FieldBinding codegenField = fieldBinding.original();
      if (codegenField.isStatic()) {
        if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
          TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, this.actualReceiverType, true /* implicit this */);
          codeStream.fieldAccess(Opcodes.OPC_getstatic, codegenField, constantPoolDeclaringClass);
        } else {
          codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
        }
      } else {
        if ((this.bits & ASTNode.DepthMASK) != 0) {
          ReferenceBinding targetType = currentScope.enclosingSourceType().enclosingTypeAt((this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT);
          Object[] emulationPath = currentScope.getEmulationPath(targetType, true /*only exact match*/, false/*consider enclosing arg*/);
          codeStream.generateOuterAccess(emulationPath, this, targetType, currentScope);
        } else {
          codeStream.aload_0();
        }
        codeStream.dup();
        if ((this.syntheticAccessors == null) || (this.syntheticAccessors[SingleNameReference.READ] == null)) {
          TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenField, this.actualReceiverType, true /* implicit this */);
          codeStream.fieldAccess(Opcodes.OPC_getfield, codegenField, constantPoolDeclaringClass);
        } else {
          codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[SingleNameReference.READ], null /* default declaringClass */);
        }
      }
      TypeBinding operandType;
      if (this.genericCast != null) {
        codeStream.checkcast(this.genericCast);
        operandType = this.genericCast;
      } else {
        operandType = codegenField.type;
View Full Code Here

  /**
* @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 :
View Full Code Here

    switch (this.bits & ASTNode.RestrictiveFlagMASK) {
      case Binding.VARIABLE : // =========only variable============
      case Binding.VARIABLE | Binding.TYPE : //====both variable and type============
        if (this.binding instanceof VariableBinding) {
          VariableBinding variable = (VariableBinding) this.binding;
          TypeBinding variableType;
          if (this.binding instanceof LocalVariableBinding) {
            this.bits &= ~ASTNode.RestrictiveFlagMASK;  // clear bits
            this.bits |= Binding.LOCAL;
            if (!variable.isFinal() && (this.bits & ASTNode.DepthMASK) != 0) {
              scope.problemReporter().cannotReferToNonFinalOuterLocal((LocalVariableBinding)variable, this);
            }
            variableType = variable.type;
            this.constant = (this.bits & ASTNode.IsStrictlyAssigned) == 0 ? variable.constant() : Constant.NotAConstant;
          } else {
            // a field
            variableType = checkFieldAccess(scope);
          }
          // perform capture conversion if read access
          if (variableType != null) {
            this.resolvedType = variableType = (((this.bits & ASTNode.IsStrictlyAssigned) == 0)
                ? variableType.capture(scope, this.sourceEnd)
                : variableType);
            if ((variableType.tagBits & TagBits.HasMissingType) != 0) {
              if ((this.bits & Binding.LOCAL) == 0) {
                // only complain if field reference (for local, its type got flagged already)
                scope.problemReporter().invalidType(this, variableType);
              }
              return null;
            }
          }
          return variableType;
        }

        // thus it was a type
        this.bits &= ~ASTNode.RestrictiveFlagMASK;  // clear bits
        this.bits |= Binding.TYPE;
        //$FALL-THROUGH$
      case Binding.TYPE : //========only type==============
        this.constant = Constant.NotAConstant;
        //deprecated test
        TypeBinding type = (TypeBinding)this.binding;
        if (isTypeUseDeprecated(type, scope))
          scope.problemReporter().deprecatedType(type, this);
        type = scope.environment().convertToRawType(type, false /*do not force conversion of enclosing types*/);
        return this.resolvedType = type;
    }
View Full Code Here

          codeStream.dup();
          break;
      }
    }
    if (syntheticWriteAccessor == null) {
      TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, fieldBinding, receiverType, isImplicitThisReceiver);
      codeStream.fieldAccess(Opcodes.OPC_putstatic, fieldBinding, constantPoolDeclaringClass);
    } else {
      codeStream.invoke(Opcodes.OPC_invokestatic, syntheticWriteAccessor, null /* default declaringClass */);
    }
  } else { // Stack:  [owner][new field value]  ---> [new field value][owner][new field value]
    if (valueRequired) {
      switch (fieldBinding.type.id) {
        case TypeIds.T_long :
        case TypeIds.T_double :
          codeStream.dup2_x1();
          break;
        default :
          codeStream.dup_x1();
          break;
      }
    }
    if (syntheticWriteAccessor == null) {
      TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, fieldBinding, receiverType, isImplicitThisReceiver);
      codeStream.fieldAccess(Opcodes.OPC_putfield, fieldBinding, constantPoolDeclaringClass);
    } else {
      codeStream.invoke(Opcodes.OPC_invokestatic, syntheticWriteAccessor, null /* default declaringClass */);
    }
  }
 
View Full Code Here

  this.constant = Constant.NotAConstant;
  if (this.receiver instanceof CastExpression  // no cast check for ((type[])null)[0]
      && ((CastExpression)this.receiver).innermostCastedExpression() instanceof NullLiteral) {
    this.receiver.bits |= ASTNode.DisableUnnecessaryCastCheck; // will check later on
  }
  TypeBinding arrayType = this.receiver.resolveType(scope);
  if (arrayType != null) {
    this.receiver.computeConversion(scope, arrayType, arrayType);
    if (arrayType.isArrayType()) {
      TypeBinding elementType = ((ArrayBinding) arrayType).elementsType();
      this.resolvedType = ((this.bits & ASTNode.IsStrictlyAssigned) == 0) ? elementType.capture(scope, this.sourceEnd) : elementType;
    } else {
      scope.problemReporter().referenceMustBeArrayTypeAt(arrayType, this);
    }
  }
  TypeBinding positionType = this.position.resolveTypeExpecting(scope, TypeBinding.INT);
  if (positionType != null) {
    this.position.computeConversion(scope, TypeBinding.INT, positionType);
  }
  return this.resolvedType;
}
View Full Code Here

      } else {
        // method with empty body should not be flagged as static.
        this.bits &= ~ASTNode.CanBeStatic;
      }
      // check for missing returning path
      TypeBinding returnTypeBinding = this.binding.returnType;
      if ((returnTypeBinding == TypeBinding.VOID) || isAbstract()) {
        if ((flowInfo.tagBits & FlowInfo.UNREACHABLE_OR_DEAD) == 0) {
          this.bits |= ASTNode.NeedFreeReturn;
        }
      } else {
View Full Code Here

* Complain if assigned expression is cast, but not actually used as such, e.g. Object o = (List) object;
*/
public static void checkNeedForAssignedCast(BlockScope scope, TypeBinding expectedType, CastExpression rhs) {
  if (scope.compilerOptions().getSeverity(CompilerOptions.UnnecessaryTypeCheck) == ProblemSeverities.Ignore) return;

  TypeBinding castedExpressionType = rhs.expression.resolvedType;
  //  int i = (byte) n; // cast still had side effect
  // double d = (float) n; // cast to float is unnecessary
  if (castedExpressionType == null || rhs.resolvedType.isBaseType()) return;
  //if (castedExpressionType.id == T_null) return; // tolerate null expression cast
  if (castedExpressionType.isCompatibleWith(expectedType)) {
    scope.problemReporter().unnecessaryCast(rhs);
  }
}
View Full Code Here

  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()) {
    FieldBinding originalBinding = this.binding.original();
    TypeBinding originalType = originalBinding.type;
      // extra cast needed if field type is type variable
    if (originalType.leafComponentType().isTypeVariable()) {
        TypeBinding targetType = (!compileTimeType.isBaseType() && runtimeTimeType.isBaseType())
          ? compileTimeType  // unboxing: checkcast before conversion
          : runtimeTimeType;
          this.genericCast = originalBinding.type.genericCast(targetType);
          if (this.genericCast instanceof ReferenceBinding) {
        ReferenceBinding referenceCast = (ReferenceBinding) this.genericCast;
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.lookup.TypeBinding

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.