Examples of FieldBinding


Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding

/**
* Check and/or redirect the field access to the delegate receiver if any
*/
public TypeBinding checkFieldAccess(BlockScope scope) {
  FieldBinding fieldBinding = (FieldBinding) this.binding;
  MethodScope methodScope = scope.methodScope();
  // check for forward references
  if (this.indexOfFirstFieldBinding == 1
      && methodScope.enclosingSourceType() == fieldBinding.original().declaringClass
      && methodScope.lastVisibleFieldID >= 0
      && fieldBinding.id >= methodScope.lastVisibleFieldID
      && (!fieldBinding.isStatic() || methodScope.isStatic)) {
    scope.problemReporter().forwardReference(this, 0, methodScope.enclosingSourceType());
  }
  this.bits &= ~ASTNode.RestrictiveFlagMASK; // clear bits
  this.bits |= Binding.FIELD;
  return getOtherFieldBindings(scope);
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding

*/
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)
  FieldBinding field = null;
  int length = this.otherBindings == null ? 0 : this.otherBindings.length;
  if (length == 0) {
    if ((this.bits & Binding.FIELD) != 0 && this.binding != null && this.binding.isValidBinding()) {
      field = (FieldBinding) this.binding;
    }
  } else {
    field  = this.otherBindings[length-1];
  }
  if (field != null) {
    FieldBinding originalBinding = field.original();
    TypeBinding originalType = originalBinding.type;
      // extra cast needed if method return type has type variable
    if (originalBinding != field
        && originalType != field.type
          && runtimeTimeType.id != TypeIds.T_JavaLangObject
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding

  super.computeConversion(scope, runtimeTimeType, compileTimeType);
}

public void generateAssignment(BlockScope currentScope, CodeStream codeStream, Assignment assignment, boolean valueRequired) {
  int pc = codeStream.position;
  FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
  codeStream.recordPositionsFrom(pc , this.sourceStart);
  assignment.expression.generateCode(currentScope, codeStream, true);
  fieldStore(codeStream, lastFieldBinding, this.syntheticWriteAccessor, valueRequired);
  // equivalent to valuesRequired[maxOtherBindings]
  if (valueRequired) {
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding

  if (this.constant != Constant.NotAConstant) {
    if (valueRequired) {
      codeStream.generateConstant(this.constant, this.implicitConversion);
    }
  } else {
    FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
    if (lastFieldBinding != null) {
      boolean isStatic = lastFieldBinding.isStatic();
      Constant fieldConstant = lastFieldBinding.constant();
      if (fieldConstant != Constant.NotAConstant) {
        if (!isStatic){
          codeStream.invokeObjectGetClass();
          codeStream.pop();
        }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding

  Expression expression,
  int operator,
  int assignmentImplicitConversion,
  boolean valueRequired) {
   
  FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
  SyntheticMethodBinding accessor =
    this.syntheticReadAccessors == null
      ? null
      : this.syntheticReadAccessors[this.syntheticReadAccessors.length - 1];
  if (lastFieldBinding.isStatic()) {
    if (accessor == null) {
      codeStream.getstatic(lastFieldBinding);
    } else {
      codeStream.invokestatic(accessor);
    }
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding

  BlockScope currentScope,
  CodeStream codeStream,
  CompoundAssignment postIncrement,
  boolean valueRequired) {
   
  FieldBinding lastFieldBinding = generateReadSequence(currentScope, codeStream);
  SyntheticMethodBinding accessor =
    this.syntheticReadAccessors == null
      ? null
      : this.syntheticReadAccessors[this.syntheticReadAccessors.length - 1];
  if (lastFieldBinding.isStatic()) {
    if (accessor == null) {
      codeStream.getstatic(lastFieldBinding);
    } else {
      codeStream.invokestatic(accessor);
    }
  } else {
    codeStream.dup();
    if (accessor == null) {
      codeStream.getfield(lastFieldBinding);
    } else {
      codeStream.invokestatic(accessor);
    }
  }
  // duplicate the old field value
  if (valueRequired) {
    if (lastFieldBinding.isStatic()) {
      if ((lastFieldBinding.type == TypeBinding.LONG)
        || (lastFieldBinding.type == TypeBinding.DOUBLE)) {
        codeStream.dup2();
      } else {
        codeStream.dup();
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding

*/
public FieldBinding generateReadSequence(BlockScope currentScope, CodeStream codeStream) {
  // determine the rank until which we now we do not need any actual value for the field access
  int otherBindingsCount = this.otherCodegenBindings == null ? 0 : this.otherCodegenBindings.length;
  boolean needValue = otherBindingsCount == 0 || !this.otherBindings[0].isStatic();
  FieldBinding lastFieldBinding = null;
  TypeBinding lastGenericCast = null;
  boolean complyTo14 = currentScope.compilerOptions().complianceLevel >= ClassFileConstants.JDK1_4;

  switch (this.bits & ASTNode.RestrictiveFlagMASK) {
    case Binding.FIELD :
      lastFieldBinding = (FieldBinding) this.codegenBinding;
      lastGenericCast = this.genericCast;
      // if first field is actually constant, we can inline it
      if (lastFieldBinding.constant() != Constant.NotAConstant) {
        break;
      }
      if ((needValue && !lastFieldBinding.isStatic()) || lastGenericCast != null) {
        int pc = codeStream.position;
        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);
        }
        codeStream.recordPositionsFrom(pc, this.sourceStart);
      }
      break;
    case Binding.LOCAL : // reading the first local variable
      if (!needValue) break; // no value needed
      LocalVariableBinding localBinding = (LocalVariableBinding) this.codegenBinding;
      // regular local variable read
      Constant localConstant = localBinding.constant();
      if (localConstant != Constant.NotAConstant) {
        codeStream.generateConstant(localConstant, 0);
        // no implicit conversion
      } else {
        // outer local?
        if ((this.bits & ASTNode.DepthMASK) != 0) {
          // outer local can be reached either through a synthetic arg or a synthetic field
          VariableBinding[] path = currentScope.getEmulationPath(localBinding);
          codeStream.generateOuterAccess(path, this, localBinding, currentScope);
        } else {
          codeStream.load(localBinding);
        }
      }
  }
         
  // all intermediate field accesses are read accesses
  // only the last field binding is a write access
  int positionsLength = this.sourcePositions.length;
  if (this.otherCodegenBindings != null) {
    for (int i = 0; i < otherBindingsCount; i++) {
      int pc = codeStream.position;
      FieldBinding nextField = this.otherCodegenBindings[i];
      TypeBinding nextGenericCast = this.otherGenericCasts == null ? null : this.otherGenericCasts[i];
      if (lastFieldBinding != null) {
        needValue = !nextField.isStatic();
        Constant fieldConstant = lastFieldBinding.constant();
        if (fieldConstant != Constant.NotAConstant) {
          if (i > 0 && !lastFieldBinding.isStatic()) {
            codeStream.invokeObjectGetClass(); // perform null check
            codeStream.pop();
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding

      }
    }

    currentType = declaringType;

    FieldBinding fb = null;
    if (member.getName().startsWith(NameMangler.PREFIX)) {
      fb = new SyntheticFieldBinding(member.getName().toCharArray(), makeTypeBinding(member.getReturnType()),
          member.getModifiers() | Flags.AccSynthetic, currentType, Constant.NotAConstant, -1); // index filled in later
    } else {
      fb = new FieldBinding(member.getName().toCharArray(), makeTypeBinding(member.getReturnType()), member.getModifiers(),
          currentType, Constant.NotAConstant);
    }
    typeVariableToTypeBinding.clear();
    currentType = null;
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding

}

public TypeBinding getOtherFieldBindings(BlockScope scope) {
  // At this point restrictiveFlag may ONLY have two potential value : FIELD LOCAL (i.e cast <<(VariableBinding) binding>> is valid)
  int length = this.tokens.length;
  FieldBinding field;
  if ((this.bits & Binding.FIELD) != 0) {
    field = (FieldBinding) this.binding;
    if (!field.isStatic()) {
      //must check for the static status....
      if (this.indexOfFirstFieldBinding > //accessing to a field using a type as "receiver" is allowed only with static field
           || scope.methodScope().isStatic) {   // the field is the first token of the qualified reference....
        scope.problemReporter().staticFieldAccessToNonStaticVariable(this, field);
        return null;
       }
    } else {
      // indirect static reference ?
      if (this.indexOfFirstFieldBinding > 1
          && field.declaringClass != this.actualReceiverType
          && field.declaringClass.canBeSeenBy(scope)) {
        scope.problemReporter().indirectAccessToStaticField(this, field);
      }
    }
    // only last field is actually a write access if any
    if (isFieldUseDeprecated(field, scope, (this.bits & ASTNode.IsStrictlyAssigned) != 0 && this.indexOfFirstFieldBinding == length))
      scope.problemReporter().deprecatedField(field, this);
  } else {
    field = null;
  }
  TypeBinding type = ((VariableBinding) this.binding).type;
  int index = this.indexOfFirstFieldBinding;
  if (index == length) { //  restrictiveFlag == FIELD
    this.constant = ((FieldBinding) this.binding).constant();
    // perform capture conversion if read access
    return (type != null && (this.bits & ASTNode.IsStrictlyAssigned) == 0)
        ? type.capture(scope, this.sourceEnd)
        : type;
  }
  // allocation of the fieldBindings array  and its respective constants
  int otherBindingsLength = length - index;
  this.otherCodegenBindings = this.otherBindings = new FieldBinding[otherBindingsLength];
  this.otherDepths = new int[otherBindingsLength];
 
  // fill the first constant (the one of the binding)
  this.constant = ((VariableBinding) this.binding).constant();
  // save first depth, since will be updated by visibility checks of other bindings
  int firstDepth = (this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT;
  // iteration on each field 
  while (index < length) {
    char[] token = this.tokens[index];
    if (type == null)
      return null; // could not resolve type prior to this point

    this.bits &= ~ASTNode.DepthMASK; // flush previous depth if any   
    FieldBinding previousField = field;
    field = scope.getField(type.capture(scope, (int)this.sourcePositions[index]), token, this);
    int place = index - this.indexOfFirstFieldBinding;
    this.otherBindings[place] = field;
    this.otherDepths[place] = (this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT;
    if (field.isValidBinding()) {
      // set generic cast of for previous field (if any)
      if (previousField != null) {
        TypeBinding fieldReceiverType = type;
        TypeBinding receiverErasure = type.erasure();
        if (receiverErasure instanceof ReferenceBinding) {
          if (receiverErasure.findSuperTypeWithSameErasure(field.declaringClass) == null) {
            fieldReceiverType = field.declaringClass; // handle indirect inheritance thru variable secondary bound
          }
        }       
        FieldBinding originalBinding = previousField.original();
          if ((originalBinding.type.tagBits &  TagBits.HasTypeVariable) != 0 && fieldReceiverType.id != TypeIds.T_JavaLangObject) {
            setGenericCast(index-1,originalBinding.type.genericCast(fieldReceiverType)); // type cannot be base-type even in boxing case
          }
        }
      // only last field is actually a write access if any
View Full Code Here

Examples of org.aspectj.org.eclipse.jdt.internal.compiler.lookup.FieldBinding

        //  AspectJ Extension
    if (index < 0) {
      if (fieldBinding.alwaysNeedsAccessMethod(false)) {
        SyntheticMethodBinding newBinding = fieldBinding.getAccessMethod(false);
        setSyntheticAccessor(fieldBinding,index,newBinding);
        FieldBinding originalField = fieldBinding.original();
        if (originalField != fieldBinding) {
          setCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index, originalField);
        }
        return;
      }
    } else {
      if (fieldBinding.alwaysNeedsAccessMethod(true)) {
        SyntheticMethodBinding newBinding = fieldBinding.getAccessMethod(true);
        setSyntheticAccessor(fieldBinding,index,newBinding);
        FieldBinding originalField = fieldBinding.original();
        if (originalField != fieldBinding) {
          setCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index, originalField);
        }
        return;
      }
    }
    // End AspectJ Extension

  if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) != 0return;
  // index == 0 denotes the first fieldBinding, index > 0 denotes one of the 'otherBindings', index < 0 denotes a write access (to last binding)
  if (fieldBinding.constant() != Constant.NotAConstant)
    return;

  // if field from parameterized type got found, use the original field at codegen time
  FieldBinding originalField = fieldBinding.original();
  if (originalField != fieldBinding) {
    setCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index, originalField);
  }
 
  if (fieldBinding.isPrivate()) { // private access
      FieldBinding someCodegenBinding = getCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index);
    if (someCodegenBinding.declaringClass != currentScope.enclosingSourceType()) {
        setSyntheticAccessor(fieldBinding, index,
                ((SourceTypeBinding) someCodegenBinding.declaringClass).addSyntheticMethod(someCodegenBinding, index >= 0 /*read-access?*/));
      currentScope.problemReporter().needToEmulateFieldAccess(someCodegenBinding, this, index >= 0 /*read-access?*/);
      return;
    }
  } else if (fieldBinding.isProtected()){
      int depth = (index == 0 || (index < 0 && this.otherDepths == null))
          ? (this.bits & ASTNode.DepthMASK) >> ASTNode.DepthSHIFT
           : this.otherDepths[index < 0 ? this.otherDepths.length-1 : index-1];
   
    // implicit protected access
    if (depth > 0 && (fieldBinding.declaringClass.getPackage() != currentScope.enclosingSourceType().getPackage())) {
        FieldBinding someCodegenBinding = getCodegenBinding(index < 0 ? (this.otherBindings == null ? 0 : this.otherBindings.length) : index);
        setSyntheticAccessor(fieldBinding, index,
                ((SourceTypeBinding) currentScope.enclosingSourceType().enclosingTypeAt(depth)).addSyntheticMethod(someCodegenBinding, index >= 0 /*read-access?*/));
      currentScope.problemReporter().needToEmulateFieldAccess(someCodegenBinding, this, index >= 0 /*read-access?*/);
      return;
    }
 
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.