Examples of FlowInfo


Examples of org.eclipse.jdt.internal.compiler.flow.FlowInfo

  this.type = type;
  type.bits |= ASTNode.IgnoreRawTypeCheck; // no need to worry about raw type usage
}

public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
  FlowInfo result = this.expression
    .analyseCode(currentScope, flowContext, flowInfo)
    .unconditionalInits();
  this.expression.checkNPEbyUnboxing(currentScope, flowContext, flowInfo);
  // account for pot. CCE:
  flowContext.recordAbruptExit();
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.flow.FlowInfo

      }
      // check if final blank field
      if (lastFieldBinding.isBlankFinal()
            && this.otherBindings != null // the last field binding is only assigned
           && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)) {
        FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(lastFieldBinding.declaringClass.original(), flowInfo);
        if (!fieldInits.isDefinitelyAssigned(lastFieldBinding)) {
          currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this);
        }
      }
      break;
    case Binding.LOCAL :
      // first binding is a local variable
      LocalVariableBinding localBinding;
      if (!flowInfo
        .isDefinitelyAssigned(localBinding = (LocalVariableBinding) this.binding)) {
        currentScope.problemReporter().uninitializedLocalVariable(localBinding, this);
      }
      if ((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0)  {
        localBinding.useFlag = LocalVariableBinding.USED;
      } else if (localBinding.useFlag == LocalVariableBinding.UNUSED) {
        localBinding.useFlag = LocalVariableBinding.FAKE_USED;
      }
      if (needValue) {
        checkInternalNPE(currentScope, flowContext, flowInfo, true);
      }
  }

  if (needValue) {
    manageEnclosingInstanceAccessIfNecessary(currentScope, flowInfo);
    // only for first binding
  }
  // all intermediate field accesses are read accesses
  if (this.otherBindings != null) {
    for (int i = 0; i < otherBindingsCount-1; i++) {
      lastFieldBinding = this.otherBindings[i];
      needValue = !this.otherBindings[i+1].isStatic();
      if (needValue || complyTo14) {
        manageSyntheticAccessIfNecessary(currentScope, lastFieldBinding, i + 1, flowInfo);
      }
    }
    lastFieldBinding = this.otherBindings[otherBindingsCount-1];
  }

  if (isCompound) {
    if (otherBindingsCount == 0
        && lastFieldBinding.isBlankFinal()
        && currentScope.needBlankFinalFieldInitializationCheck(lastFieldBinding)) {
      FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(lastFieldBinding.declaringClass, flowInfo);
      if (!fieldInits.isDefinitelyAssigned(lastFieldBinding)) {
        currentScope.problemReporter().uninitializedBlankFinalField(lastFieldBinding, this);
      }
    }
    manageSyntheticAccessIfNecessary(currentScope, lastFieldBinding, otherBindingsCount, flowInfo);
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.flow.FlowInfo

      FieldBinding fieldBinding = (FieldBinding) this.binding;
      if (this.indexOfFirstFieldBinding == 1) { // was an implicit reference to the first field binding
        // check if reading a final blank field
        if (fieldBinding.isBlankFinal()
            && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) {
          FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.original(), flowInfo);
          if (!fieldInits.isDefinitelyAssigned(fieldBinding)) {
            currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
          }
        }
      }
      break;
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.flow.FlowInfo

    int initialComplaintLevel = (flowInfo.reachMode() & FlowInfo.UNREACHABLE) != 0 ? Statement.COMPLAINED_FAKE_REACHABLE : Statement.NOT_COMPLAINED;

    // process the element variable and collection
    this.collection.checkNPE(currentScope, flowContext, flowInfo);
    flowInfo = this.elementVariable.analyseCode(this.scope, flowContext, flowInfo);   
    FlowInfo condInfo = this.collection.analyseCode(this.scope, flowContext, flowInfo.copy());
    LocalVariableBinding elementVarBinding = this.elementVariable.binding;

    // element variable will be assigned when iterating
    condInfo.markAsDefinitelyAssigned(elementVarBinding);

    this.postCollectionInitStateIndex = currentScope.methodScope().recordInitializationStates(condInfo);


    // process the action
    LoopingFlowContext loopingContext =
      new LoopingFlowContext(flowContext, flowInfo, this, this.breakLabel,
        this.continueLabel, this.scope, true);
    UnconditionalFlowInfo actionInfo =
      condInfo.nullInfoLessUnconditionalCopy();
    actionInfo.markAsDefinitelyUnknown(elementVarBinding);
    if (currentScope.compilerOptions().isAnnotationBasedNullAnalysisEnabled) {
      // this currently produces an unavoidable warning against all @NonNull element vars:
      int nullStatus = this.elementVariable.checkAssignmentAgainstNullAnnotation(currentScope, flowContext,
                              elementVarBinding, FlowInfo.UNKNOWN, this.collection, this.collectionElementType);
      // TODO (stephan):   once we have JSR 308 fetch nullStatus from the collection element type
      //                and feed the result into the above check (instead of FlowInfo.UNKNOWN)
      if ((elementVarBinding.type.tagBits & TagBits.IsBaseType) == 0) {
        actionInfo.markNullStatus(elementVarBinding, nullStatus);
      }
    }
    FlowInfo exitBranch;
    if (!(this.action == null || (this.action.isEmptyBlock()
        && currentScope.compilerOptions().complianceLevel <= ClassFileConstants.JDK1_3))) {

      if (this.action.complainIfUnreachable(actionInfo, this.scope, initialComplaintLevel, true) < Statement.COMPLAINED_UNREACHABLE) {
        actionInfo = this.action.analyseCode(this.scope, loopingContext, actionInfo).unconditionalCopy();
      }

      // code generation can be optimized when no need to continue in the loop
      exitBranch = flowInfo.unconditionalCopy().
          addInitializationsFrom(condInfo.initsWhenFalse());
      // TODO (maxime) no need to test when false: can optimize (same for action being unreachable above)
      if ((actionInfo.tagBits & loopingContext.initsOnContinue.tagBits &
          FlowInfo.UNREACHABLE_OR_DEAD) != 0) {
        this.continueLabel = null;
      } else {
        actionInfo = actionInfo.mergedWith(loopingContext.initsOnContinue);
        loopingContext.complainOnDeferredFinalChecks(this.scope, actionInfo);
        exitBranch.addPotentialInitializationsFrom(actionInfo);
      }
    } else {
      exitBranch = condInfo.initsWhenFalse();
    }

    // we need the variable to iterate the collection even if the
    // element variable is not used
    final boolean hasEmptyAction = this.action == null
    || this.action.isEmptyBlock()
    || ((this.action.bits & IsUsefulEmptyStatement) != 0);

    switch(this.kind) {
      case ARRAY :
        if (!hasEmptyAction
            || elementVarBinding.resolvedPosition != -1) {
          this.collectionVariable.useFlag = LocalVariableBinding.USED;
          if (this.continueLabel != null) {
            this.indexVariable.useFlag = LocalVariableBinding.USED;
            this.maxVariable.useFlag = LocalVariableBinding.USED;
          }
        }
        break;
      case RAW_ITERABLE :
      case GENERIC_ITERABLE :
        this.indexVariable.useFlag = LocalVariableBinding.USED;
        break;
    }
    //end of loop
    loopingContext.complainOnDeferredNullChecks(currentScope, actionInfo);

    FlowInfo mergedInfo = FlowInfo.mergedOptimizedBranches(
        (loopingContext.initsOnBreak.tagBits &
            FlowInfo.UNREACHABLE) != 0 ?
                loopingContext.initsOnBreak :
                  flowInfo.addInitializationsFrom(loopingContext.initsOnBreak), // recover upstream null info
                  false,
                  exitBranch,
                  false,
                  true /*for(;;){}while(true); unreachable(); */);
    mergedInfo.resetAssignmentInfo(this.elementVariable.binding);
    this.mergedInitStateIndex = currentScope.methodScope().recordInitializationStates(mergedInfo);
    return mergedInfo;
  }
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.flow.FlowInfo

    switch (this.bits & ASTNode.RestrictiveFlagMASK) {
      case Binding.FIELD : // reading a field
        FieldBinding fieldBinding = (FieldBinding) this.binding;
        if (fieldBinding.isBlankFinal()
            && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) {
          FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.original(), flowInfo);
          if (!fieldInits.isDefinitelyAssigned(fieldBinding)) {
            currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
          }
        }
        manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/);
        break;
 
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.flow.FlowInfo

        manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/);
      }
      // check if reading a final blank field
      FieldBinding fieldBinding = (FieldBinding) this.binding;
      if (fieldBinding.isBlankFinal() && currentScope.needBlankFinalFieldInitializationCheck(fieldBinding)) {
        FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(fieldBinding.declaringClass.original(), flowInfo);
        if (!fieldInits.isDefinitelyAssigned(fieldBinding)) {
          currentScope.problemReporter().uninitializedBlankFinalField(fieldBinding, this);
        }
      }
      break;
    case Binding.LOCAL : // reading a local variable
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.flow.FlowInfo

  boolean isOptimizedFalseAssertion = cst != Constant.NotAConstant && cst.booleanValue() == false;
  int tagBitsSave = flowContext.tagBits;
  flowContext.tagBits |= FlowContext.HIDE_NULL_COMPARISON_WARNING;
  if (!passOnTrue)
    flowContext.tagBits |= FlowContext.INSIDE_NEGATION; // this affects syntactic analysis for fields in EqualExpression
  FlowInfo conditionFlowInfo = argument.analyseCode(currentScope, flowContext, flowInfo.copy());
  flowContext.extendTimeToLiveForNullCheckedField(2); // survive this assert as a MessageSend and as a Statement
  flowContext.tagBits = tagBitsSave;

  UnconditionalFlowInfo assertWhenPassInfo;
  FlowInfo assertWhenFailInfo;
  boolean isOptimizedPassing;
  boolean isOptimizedFailing;
  if (passOnTrue) {
    assertWhenPassInfo = conditionFlowInfo.initsWhenTrue().unconditionalInits();
    assertWhenFailInfo = conditionFlowInfo.initsWhenFalse();
    isOptimizedPassing = isOptimizedTrueAssertion;
    isOptimizedFailing = isOptimizedFalseAssertion;
  } else {
    assertWhenPassInfo = conditionFlowInfo.initsWhenFalse().unconditionalInits();
    assertWhenFailInfo = conditionFlowInfo.initsWhenTrue();
    isOptimizedPassing = isOptimizedFalseAssertion;
    isOptimizedFailing = isOptimizedTrueAssertion;
  }
  if (isOptimizedPassing) {
    assertWhenFailInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD);
  }
  if (!isOptimizedFailing) {
    // if assertion is not failing for sure, only then it makes sense to carry the flow info ahead.
    // if the code does reach ahead, it means the assert didn't cause an exit, and so
    // the expression inside it shouldn't change the prior flowinfo
    // viz. org.eclipse.core.runtime.Assert.isLegal(false && o != null)
   
    // keep the merge from the initial code for the definite assignment
    // analysis, tweak the null part to influence nulls downstream
    flowInfo = flowInfo.mergedWith(assertWhenFailInfo.nullInfoLessUnconditionalCopy()).
      addInitializationsFrom(assertWhenPassInfo.discardInitializationInfo());
  }
  return flowInfo;
}
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.flow.FlowInfo

  // compound assignment extra work
  if (isCompound) { // check the variable part is initialized if blank final
    if (this.binding.isBlankFinal()
      && this.receiver.isThis()
      && currentScope.needBlankFinalFieldInitializationCheck(this.binding)) {
      FlowInfo fieldInits = flowContext.getInitsForFinalBlankInitializationCheck(this.binding.declaringClass.original(), flowInfo);
      if (!fieldInits.isDefinitelyAssigned(this.binding)) {
        currentScope.problemReporter().uninitializedBlankFinalField(this.binding, this);
        // we could improve error msg here telling "cannot use compound assignment on final blank field"
      }
    }
    manageSyntheticAccessIfNecessary(currentScope, flowInfo, true /*read-access*/);
 
View Full Code Here

Examples of org.eclipse.jdt.internal.compiler.flow.FlowInfo

  public static FlowInfo markPassedToOutside(BlockScope scope, Expression expression, FlowInfo flowInfo, FlowContext flowContext, boolean owned) { 
   
    FakedTrackingVariable trackVar = getCloseTrackingVariable(expression, flowInfo, flowContext);
    if (trackVar != null) {
      // insert info that the tracked resource *may* be closed (by the target method, i.e.)
      FlowInfo infoResourceIsClosed = owned ? flowInfo : flowInfo.copy();
      int flag = owned ? OWNED_BY_OUTSIDE : SHARED_WITH_OUTSIDE;
      do {
        trackVar.globalClosingState |= flag;
        if (scope.methodScope() != trackVar.methodScope)
          trackVar.globalClosingState |= CLOSED_IN_NESTED_METHOD;
        infoResourceIsClosed.markAsDefinitelyNonNull(trackVar.binding);
      } while ((trackVar = trackVar.innerTracker) != null);
      if (owned) {
        return infoResourceIsClosed; // don't let downstream signal any problems on this flow
      } else {
        return FlowInfo.conditional(flowInfo, infoResourceIsClosed); // only report potential problems on this flow
View Full Code Here

Examples of soot.toolkits.graph.interaction.FlowInfo

                            copy(filterUnitToAfterFlow.get(s), savedFlow);
                        }
                        else {
                            copy(afterFlow, savedFlow);
                        }
                        FlowInfo fi = new FlowInfo(savedFlow, s, false);
                        if (InteractionHandler.v().getStopUnitList() != null && InteractionHandler.v().getStopUnitList().contains(s)){
                            InteractionHandler.v().handleStopAtNodeEvent(s);
                        }
                        InteractionHandler.v().handleAfterAnalysisEvent(fi);
                    }
                    flowThrough(afterFlow, s, beforeFlow);
                    if (Options.v().interactive_mode()){
                        A bSavedFlow = newInitialFlow();
                        if (filterUnitToBeforeFlow != null){
                            bSavedFlow = filterUnitToBeforeFlow.get(s);
                            copy(filterUnitToBeforeFlow.get(s), bSavedFlow);
                        }
                        else {
                            copy(beforeFlow, bSavedFlow);
                        }
                        FlowInfo fi = new FlowInfo(bSavedFlow, s, true);
                        InteractionHandler.v().handleBeforeAnalysisEvent(fi);
                    }
                }

                // Update queue appropriately
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.