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

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


        // could occur if !valueRequired but compliance >= 1.4
        codeStream.pop();
      }
    } else {
      if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
        TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());
        if (isStatic) {
          codeStream.fieldAccess(Opcodes.OPC_getstatic, codegenBinding, constantPoolDeclaringClass);
        } else {
          codeStream.fieldAccess(Opcodes.OPC_getfield, codegenBinding, constantPoolDeclaringClass);
        }
      } else {
        codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
      }
      // required cast must occur even if no value is required
      if (this.genericCast != null) codeStream.checkcast(this.genericCast);
      if (valueRequired) {
        codeStream.generateImplicitConversion(this.implicitConversion);
      } else {
        boolean isUnboxing = (this.implicitConversion & TypeIds.UNBOXING) != 0;
        // conversion only generated if unboxing
        if (isUnboxing) codeStream.generateImplicitConversion(this.implicitConversion);
        switch (isUnboxing ? postConversionType(currentScope).id : codegenBinding.type.id) {
          case T_long :
          case T_double :
            codeStream.pop2();
            break;
          default :
            codeStream.pop();
        }
      }
    }
  } else {
    if (isThisReceiver) {
      if (isStatic){
        // if no valueRequired, still need possible side-effects of <clinit> invocation, if field belongs to different class
        if (this.binding.original().declaringClass != this.actualReceiverType.erasure()) {
          MethodBinding accessor = this.syntheticAccessors == null ? null : this.syntheticAccessors[FieldReference.READ];
          if (accessor == null) {
            TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());
            codeStream.fieldAccess(Opcodes.OPC_getstatic, codegenBinding, constantPoolDeclaringClass);
          } else {
            codeStream.invoke(Opcodes.OPC_invokestatic, accessor, null /* default declaringClass */);
          }
          switch (codegenBinding.type.id) {
View Full Code Here


  reportOnlyUselesslyReadPrivateField(currentScope, this.binding, valueRequired);
  FieldBinding codegenBinding = this.binding.original();
  this.receiver.generateCode(currentScope, codeStream, !(isStatic = codegenBinding.isStatic()));
  if (isStatic) {
    if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
      TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());
      codeStream.fieldAccess(Opcodes.OPC_getstatic, codegenBinding, constantPoolDeclaringClass);
    } else {
      codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
    }
  } else {
    codeStream.dup();
    if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
      TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());
      codeStream.fieldAccess(Opcodes.OPC_getfield, codegenBinding, constantPoolDeclaringClass);
    } else {
      codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
    }
  }
 
View Full Code Here

  reportOnlyUselesslyReadPrivateField(currentScope, this.binding, valueRequired);
  FieldBinding codegenBinding = this.binding.original();
  this.receiver.generateCode(currentScope, codeStream, !(isStatic = codegenBinding.isStatic()));
  if (isStatic) {
    if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
      TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());
      codeStream.fieldAccess(Opcodes.OPC_getstatic, codegenBinding, constantPoolDeclaringClass);
    } else {
      codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
    }
  } else {
    codeStream.dup();
    if (this.syntheticAccessors == null || this.syntheticAccessors[FieldReference.READ] == null) {
      TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis());
      codeStream.fieldAccess(Opcodes.OPC_getfield, codegenBinding, constantPoolDeclaringClass);
    } else {
      codeStream.invoke(Opcodes.OPC_invokestatic, this.syntheticAccessors[FieldReference.READ], null /* default declaringClass */);
    }
  }
  TypeBinding operandType;
  if (this.genericCast != null) {
    codeStream.checkcast(this.genericCast);
    operandType = this.genericCast;
  } else {
    operandType = codegenBinding.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

      return null;
    }
  }
  // handle indirect inheritance thru variable secondary bound
  // receiver may receive generic cast, as part of implicit conversion
  TypeBinding oldReceiverType = this.actualReceiverType;
  this.actualReceiverType = this.actualReceiverType.getErasureCompatibleType(fieldBinding.declaringClass);
  this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType);
  if (this.actualReceiverType != oldReceiverType && this.receiver.postConversionType(scope) != this.actualReceiverType) { // record need for explicit cast at codegen since receiver could not handle it
    this.bits |= NeedReceiverGenericCast;
  }
  if (isFieldUseDeprecated(fieldBinding, scope, this.bits)) {
    scope.problemReporter().deprecatedField(fieldBinding, this);
  }
  boolean isImplicitThisRcv = this.receiver.isImplicitThis();
  this.constant = isImplicitThisRcv ? fieldBinding.constant() : Constant.NotAConstant;
  if (fieldBinding.isStatic()) {
    // static field accessed through receiver? legal but unoptimal (optional warning)
    if (!(isImplicitThisRcv
        || (this.receiver instanceof NameReference
          && (((NameReference) this.receiver).bits & Binding.TYPE) != 0))) {
      scope.problemReporter().nonStaticAccessToStaticField(this, fieldBinding);
    }
    ReferenceBinding declaringClass = this.binding.declaringClass;
    if (!isImplicitThisRcv
        && declaringClass != this.actualReceiverType
        && declaringClass.canBeSeenBy(scope)) {
      scope.problemReporter().indirectAccessToStaticField(this, fieldBinding);
    }
    // check if accessing enum static field in initializer
    if (declaringClass.isEnum()) {
      MethodScope methodScope = scope.methodScope();
      SourceTypeBinding sourceType = scope.enclosingSourceType();
      if (this.constant == Constant.NotAConstant
          && !methodScope.isStatic
          && (sourceType == declaringClass || sourceType.superclass == declaringClass) // enum constant body
          && methodScope.isInsideInitializerOrConstructor()) {
        scope.problemReporter().enumStaticFieldUsedDuringInitialization(this.binding, this);
      }
    }
  }
  TypeBinding fieldType = fieldBinding.type;
  if (fieldType != null) {
    if ((this.bits & ASTNode.IsStrictlyAssigned) == 0) {
      fieldType = fieldType.capture(scope, this.sourceEnd)// perform capture conversion if read access
    }
    this.resolvedType = fieldType;
    if ((fieldType.tagBits & TagBits.HasMissingType) != 0) {
      scope.problemReporter().invalidType(this, fieldType);
      return null;
View Full Code Here

  private Object createAnnotationInstance(TreeLogger logger,
      Expression expression) {
    Annotation annotation = (Annotation) expression;

    // Determine the annotation class
    TypeBinding resolvedType = annotation.resolvedType;
    Class<?> classLiteral = getClassLiteral(logger, resolvedType);
    if (classLiteral == null) {
      return null;
    }

    Class<? extends java.lang.annotation.Annotation> clazz = classLiteral.asSubclass(java.lang.annotation.Annotation.class);

    // Build the map of identifiers to values.
    Map<String, Object> identifierToValue = new HashMap<String, Object>();
    for (MemberValuePair mvp : annotation.memberValuePairs()) {
      // Method name
      String identifier = String.valueOf(mvp.name);

      // Value
      Expression expressionValue = mvp.value;
      TypeBinding expectedElementValueType = mvp.binding.returnType;
      Object elementValue = getAnnotationElementValue(logger,
          expectedElementValueType, expressionValue);
      if (elementValue == null) {
        return null;
      }

      /*
       * If the expected value is supposed to be an array then the element value
       * had better be an array.
       */
      assert (expectedElementValueType.isArrayType() == false || expectedElementValueType.isArrayType()
          && elementValue.getClass().isArray());

      identifierToValue.put(identifier, elementValue);
    }

View Full Code Here

    return resultType;
  }

  private JClassType[] createTypeParameterBounds(TreeLogger logger,
      TypeVariableBinding tvBinding) {
    TypeBinding firstBound = tvBinding.firstBound;
    if (firstBound == null) {
      // No bounds were specified, so we default to Object. We assume that the
      // superclass field of a TypeVariableBinding object is a Binding
      // for a java.lang.Object, and we use this binding to find the
      // JClassType for java.lang.Object. To be sure that our assumption
View Full Code Here

    logger = logger.branch(TreeLogger.SPAM, "Resolving annotation '"
        + jannotation.printExpression(0, new StringBuffer()).toString() + "'",
        null);

    // Determine the annotation class
    TypeBinding resolvedType = jannotation.resolvedType;
    Class<?> classLiteral = getClassLiteral(logger, resolvedType);
    if (classLiteral == null) {
      return false;
    }
View Full Code Here

    //
    field.addModifierBits(Shared.bindingToModifierBits(jfield.binding));

    // Set the field type.
    //
    TypeBinding jfieldType = jfield.binding.type;

    JType fieldType = resolveType(logger, jfieldType);
    if (fieldType == null) {
      // Unresolved type.
      //
View Full Code Here

      if (!resolveBoundsForTypeParameters(logger, method,
          jmethod.typeParameters())) {
        return false;
      }

      TypeBinding jreturnType = ((MethodDeclaration) jmethod).returnType.resolvedType;
      JType returnType = resolveType(logger, jreturnType);
      if (returnType == null) {
        // Unresolved type.
        //
        return false;
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.