Package org.eclipse.jdt.internal.compiler.codegen

Examples of org.eclipse.jdt.internal.compiler.codegen.BranchLabel


    this.kind = -1;
  }

  public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
    // initialize break and continue labels
    this.breakLabel = new BranchLabel();
    this.continueLabel = new BranchLabel();
    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);   
View Full Code Here


        codeStream.store(this.indexVariable, false);
        codeStream.addVariable(this.indexVariable);
        break;
    }
    // label management
    BranchLabel actionLabel = new BranchLabel(codeStream);
    actionLabel.tagBits |= BranchLabel.USED;
    BranchLabel conditionLabel = new BranchLabel(codeStream);
    conditionLabel.tagBits |= BranchLabel.USED;
    this.breakLabel.initialize(codeStream);
    if (this.continueLabel == null) {
      // generate the condition (swapped for optimizing)
      conditionLabel.place();
      int conditionPC = codeStream.position;
      switch(this.kind) {
        case ARRAY :
          // inline the arraylength call
          // collectionVariable is already on execution stack
          codeStream.arraylength();
          codeStream.ifeq(this.breakLabel);
          break;
        case RAW_ITERABLE :
        case GENERIC_ITERABLE :
          codeStream.load(this.indexVariable);
          codeStream.invokeJavaUtilIteratorHasNext();
          codeStream.ifeq(this.breakLabel);
          break;
      }
      codeStream.recordPositionsFrom(conditionPC, this.elementVariable.sourceStart);
    } else {
      this.continueLabel.initialize(codeStream);
      this.continueLabel.tagBits |= BranchLabel.USED;
      // jump over the actionBlock
      codeStream.goto_(conditionLabel);
    }

    // generate the loop action
    actionLabel.place();

    // generate the loop action
    switch(this.kind) {
      case ARRAY :
        if (this.elementVariable.binding.resolvedPosition != -1) {
          codeStream.load(this.collectionVariable);
          if (this.continueLabel == null) {
            codeStream.iconst_0(); // no continue, thus simply hardcode offset 0
          } else {
            codeStream.load(this.indexVariable);
          }
          codeStream.arrayAt(this.collectionElementType.id);
          if (this.elementVariableImplicitWidening != -1) {
            codeStream.generateImplicitConversion(this.elementVariableImplicitWidening);
          }
          codeStream.store(this.elementVariable.binding, false);
          codeStream.addVisibleLocalVariable(this.elementVariable.binding);
          if (this.postCollectionInitStateIndex != -1) {
            codeStream.addDefinitelyAssignedVariables(
              currentScope,
              this.postCollectionInitStateIndex);
          }
        }
        break;
      case RAW_ITERABLE :
      case GENERIC_ITERABLE :
        codeStream.load(this.indexVariable);
        codeStream.invokeJavaUtilIteratorNext();
        if (this.elementVariable.binding.type.id != T_JavaLangObject) {
          if (this.elementVariableImplicitWidening != -1) {
            codeStream.checkcast(this.collectionElementType);
            codeStream.generateImplicitConversion(this.elementVariableImplicitWidening);
          } else {
            codeStream.checkcast(this.elementVariable.binding.type);
          }
        }
        if (this.elementVariable.binding.resolvedPosition == -1) {
          codeStream.pop();
        } else {
          codeStream.store(this.elementVariable.binding, false);
          codeStream.addVisibleLocalVariable(this.elementVariable.binding);
          if (this.postCollectionInitStateIndex != -1) {
            codeStream.addDefinitelyAssignedVariables(
              currentScope,
              this.postCollectionInitStateIndex);
          }
        }
        break;
    }

    if (!hasEmptyAction) {
      this.action.generateCode(this.scope, codeStream);
    }
    codeStream.removeVariable(this.elementVariable.binding);
    if (this.postCollectionInitStateIndex != -1) {
      codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.postCollectionInitStateIndex);
    }
    // continuation point
    if (this.continueLabel != null) {
      this.continueLabel.place();
      int continuationPC = codeStream.position;
      // generate the increments for next iteration
      switch(this.kind) {
        case ARRAY :
          if (!hasEmptyAction || this.elementVariable.binding.resolvedPosition >= 0) {
            codeStream.iinc(this.indexVariable.resolvedPosition, 1);
          }
          // generate the condition
          conditionLabel.place();
          codeStream.load(this.indexVariable);
          codeStream.load(this.maxVariable);
          codeStream.if_icmplt(actionLabel);
          break;
        case RAW_ITERABLE :
        case GENERIC_ITERABLE :
          // generate the condition
          conditionLabel.place();
          codeStream.load(this.indexVariable);
          codeStream.invokeJavaUtilIteratorHasNext();
          codeStream.ifne(actionLabel);
          break;
      }
View Full Code Here

      // generate code related to the activation of assertion for this class
      codeStream.generateClassLiteralAccessForType(
          classScope.outerMostClassScope().enclosingSourceType(),
          this.classLiteralSyntheticField);
      codeStream.invokeJavaLangClassDesiredAssertionStatus();
      BranchLabel falseLabel = new BranchLabel(codeStream);
      codeStream.ifne(falseLabel);
      codeStream.iconst_1();
      BranchLabel jumpLabel = new BranchLabel(codeStream);
      codeStream.decrStackSize(1);
      codeStream.goto_(jumpLabel);
      falseLabel.place();
      codeStream.iconst_0();
      jumpLabel.place();
      codeStream.fieldAccess(Opcodes.OPC_putstatic, this.assertionSyntheticFieldBinding, null /* default declaringClass */);
    }
    // generate static fields/initializers/enum constants
    final FieldDeclaration[] fieldDeclarations = declaringType.fields;
    BlockScope lastInitializerScope = null;
View Full Code Here

    this.kind = -1;
  }

  public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
    // initialize break and continue labels
    this.breakLabel = new BranchLabel();
    this.continueLabel = new BranchLabel();
    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);   
View Full Code Here

        codeStream.store(this.indexVariable, false);
        codeStream.addVariable(this.indexVariable);
        break;
    }
    // label management
    BranchLabel actionLabel = new BranchLabel(codeStream);
    actionLabel.tagBits |= BranchLabel.USED;
    BranchLabel conditionLabel = new BranchLabel(codeStream);
    conditionLabel.tagBits |= BranchLabel.USED;
    this.breakLabel.initialize(codeStream);
    if (this.continueLabel == null) {
      // generate the condition (swapped for optimizing)
      conditionLabel.place();
      int conditionPC = codeStream.position;
      switch(this.kind) {
        case ARRAY :
          // inline the arraylength call
          // collectionVariable is already on execution stack
          codeStream.arraylength();
          codeStream.ifeq(this.breakLabel);
          break;
        case RAW_ITERABLE :
        case GENERIC_ITERABLE :
          codeStream.load(this.indexVariable);
          codeStream.invokeJavaUtilIteratorHasNext();
          codeStream.ifeq(this.breakLabel);
          break;
      }
      codeStream.recordPositionsFrom(conditionPC, this.elementVariable.sourceStart);
    } else {
      this.continueLabel.initialize(codeStream);
      this.continueLabel.tagBits |= BranchLabel.USED;
      // jump over the actionBlock
      codeStream.goto_(conditionLabel);
    }

    // generate the loop action
    actionLabel.place();

    // generate the loop action
    switch(this.kind) {
      case ARRAY :
        if (this.elementVariable.binding.resolvedPosition != -1) {
          codeStream.load(this.collectionVariable);
          if (this.continueLabel == null) {
            codeStream.iconst_0(); // no continue, thus simply hardcode offset 0
          } else {
            codeStream.load(this.indexVariable);
          }
          codeStream.arrayAt(this.collectionElementType.id);
          if (this.elementVariableImplicitWidening != -1) {
            codeStream.generateImplicitConversion(this.elementVariableImplicitWidening);
          }
          codeStream.store(this.elementVariable.binding, false);
          codeStream.addVisibleLocalVariable(this.elementVariable.binding);
          if (this.postCollectionInitStateIndex != -1) {
            codeStream.addDefinitelyAssignedVariables(
              currentScope,
              this.postCollectionInitStateIndex);
          }
        }
        break;
      case RAW_ITERABLE :
      case GENERIC_ITERABLE :
        codeStream.load(this.indexVariable);
        codeStream.invokeJavaUtilIteratorNext();
        if (this.elementVariable.binding.type.id != T_JavaLangObject) {
          if (this.elementVariableImplicitWidening != -1) {
            codeStream.checkcast(this.collectionElementType);
            codeStream.generateImplicitConversion(this.elementVariableImplicitWidening);
          } else {
            codeStream.checkcast(this.elementVariable.binding.type);
          }
        }
        if (this.elementVariable.binding.resolvedPosition == -1) {
          codeStream.pop();
        } else {
          codeStream.store(this.elementVariable.binding, false);
          codeStream.addVisibleLocalVariable(this.elementVariable.binding);
          if (this.postCollectionInitStateIndex != -1) {
            codeStream.addDefinitelyAssignedVariables(
              currentScope,
              this.postCollectionInitStateIndex);
          }
        }
        break;
    }

    if (!hasEmptyAction) {
      this.action.generateCode(this.scope, codeStream);
    }
    codeStream.removeVariable(this.elementVariable.binding);
    if (this.postCollectionInitStateIndex != -1) {
      codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.postCollectionInitStateIndex);
    }
    // continuation point
    if (this.continueLabel != null) {
      this.continueLabel.place();
      int continuationPC = codeStream.position;
      // generate the increments for next iteration
      switch(this.kind) {
        case ARRAY :
          if (!hasEmptyAction || this.elementVariable.binding.resolvedPosition >= 0) {
            codeStream.iinc(this.indexVariable.resolvedPosition, 1);
          }
          // generate the condition
          conditionLabel.place();
          codeStream.load(this.indexVariable);
          codeStream.load(this.maxVariable);
          codeStream.if_icmplt(actionLabel);
          break;
        case RAW_ITERABLE :
        case GENERIC_ITERABLE :
          // generate the condition
          conditionLabel.place();
          codeStream.load(this.indexVariable);
          codeStream.invokeJavaUtilIteratorHasNext();
          codeStream.ifne(actionLabel);
          break;
      }
View Full Code Here

      // generate code related to the activation of assertion for this class
      codeStream.generateClassLiteralAccessForType(
          classScope.outerMostClassScope().enclosingSourceType(),
          this.classLiteralSyntheticField);
      codeStream.invokeJavaLangClassDesiredAssertionStatus();
      BranchLabel falseLabel = new BranchLabel(codeStream);
      codeStream.ifne(falseLabel);
      codeStream.iconst_1();
      BranchLabel jumpLabel = new BranchLabel(codeStream);
      codeStream.decrStackSize(1);
      codeStream.goto_(jumpLabel);
      falseLabel.place();
      codeStream.iconst_0();
      jumpLabel.place();
      codeStream.fieldAccess(Opcodes.OPC_putstatic, this.assertionSyntheticFieldBinding, null /* default declaringClass */);
    }
    // generate static fields/initializers/enum constants
    final FieldDeclaration[] fieldDeclarations = declaringType.fields;
    BlockScope lastInitializerScope = null;
View Full Code Here

      // generate code related to the activation of assertion for this class
      codeStream.generateClassLiteralAccessForType(
          classScope.outerMostClassScope().enclosingSourceType(),
          this.classLiteralSyntheticField);
      codeStream.invokeJavaLangClassDesiredAssertionStatus();
      BranchLabel falseLabel = new BranchLabel(codeStream);
      codeStream.ifne(falseLabel);
      codeStream.iconst_1();
      BranchLabel jumpLabel = new BranchLabel(codeStream);
      codeStream.decrStackSize(1);
      codeStream.goto_(jumpLabel);
      falseLabel.place();
      codeStream.iconst_0();
      jumpLabel.place();
      codeStream.fieldAccess(Opcodes.OPC_putstatic, this.assertionSyntheticFieldBinding, null /* default declaringClass */);
    }
    // generate static fields/initializers/enum constants
    final FieldDeclaration[] fieldDeclarations = declaringType.fields;
    int sourcePosition = -1;
View Full Code Here

    this.kind = -1;
  }

  public FlowInfo analyseCode(BlockScope currentScope, FlowContext flowContext, FlowInfo flowInfo) {
    // initialize break and continue labels
    this.breakLabel = new BranchLabel();
    this.continueLabel = new BranchLabel();
    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);   
View Full Code Here

        codeStream.store(this.indexVariable, false);
        codeStream.addVariable(this.indexVariable);
        break;
    }
    // label management
    BranchLabel actionLabel = new BranchLabel(codeStream);
    actionLabel.tagBits |= BranchLabel.USED;
    BranchLabel conditionLabel = new BranchLabel(codeStream);
    conditionLabel.tagBits |= BranchLabel.USED;
    this.breakLabel.initialize(codeStream);
    if (this.continueLabel == null) {
      // generate the condition (swapped for optimizing)
      conditionLabel.place();
      int conditionPC = codeStream.position;
      switch(this.kind) {
        case ARRAY :
          // inline the arraylength call
          // collectionVariable is already on execution stack
          codeStream.arraylength();
          codeStream.ifeq(this.breakLabel);
          break;
        case RAW_ITERABLE :
        case GENERIC_ITERABLE :
          codeStream.load(this.indexVariable);
          codeStream.invokeJavaUtilIteratorHasNext();
          codeStream.ifeq(this.breakLabel);
          break;
      }
      codeStream.recordPositionsFrom(conditionPC, this.elementVariable.sourceStart);
    } else {
      this.continueLabel.initialize(codeStream);
      this.continueLabel.tagBits |= BranchLabel.USED;
      // jump over the actionBlock
      codeStream.goto_(conditionLabel);
    }

    // generate the loop action
    actionLabel.place();

    // generate the loop action
    switch(this.kind) {
      case ARRAY :
        if (this.elementVariable.binding.resolvedPosition != -1) {
          codeStream.load(this.collectionVariable);
          if (this.continueLabel == null) {
            codeStream.iconst_0(); // no continue, thus simply hardcode offset 0
          } else {
            codeStream.load(this.indexVariable);
          }
          codeStream.arrayAt(this.collectionElementType.id);
          if (this.elementVariableImplicitWidening != -1) {
            codeStream.generateImplicitConversion(this.elementVariableImplicitWidening);
          }
          codeStream.store(this.elementVariable.binding, false);
          codeStream.addVisibleLocalVariable(this.elementVariable.binding);
          if (this.postCollectionInitStateIndex != -1) {
            codeStream.addDefinitelyAssignedVariables(
              currentScope,
              this.postCollectionInitStateIndex);
          }
        }
        break;
      case RAW_ITERABLE :
      case GENERIC_ITERABLE :
        codeStream.load(this.indexVariable);
        codeStream.invokeJavaUtilIteratorNext();
        if (this.elementVariable.binding.type.id != T_JavaLangObject) {
          if (this.elementVariableImplicitWidening != -1) {
            codeStream.checkcast(this.collectionElementType);
            codeStream.generateImplicitConversion(this.elementVariableImplicitWidening);
          } else {
            codeStream.checkcast(this.elementVariable.binding.type);
          }
        }
        if (this.elementVariable.binding.resolvedPosition == -1) {
          codeStream.pop();
        } else {
          codeStream.store(this.elementVariable.binding, false);
          codeStream.addVisibleLocalVariable(this.elementVariable.binding);
          if (this.postCollectionInitStateIndex != -1) {
            codeStream.addDefinitelyAssignedVariables(
              currentScope,
              this.postCollectionInitStateIndex);
          }
        }
        break;
    }

    if (!hasEmptyAction) {
      this.action.generateCode(this.scope, codeStream);
    }
    codeStream.removeVariable(this.elementVariable.binding);
    if (this.postCollectionInitStateIndex != -1) {
      codeStream.removeNotDefinitelyAssignedVariables(currentScope, this.postCollectionInitStateIndex);
    }
    // continuation point
    if (this.continueLabel != null) {
      this.continueLabel.place();
      int continuationPC = codeStream.position;
      // generate the increments for next iteration
      switch(this.kind) {
        case ARRAY :
          if (!hasEmptyAction || this.elementVariable.binding.resolvedPosition >= 0) {
            codeStream.iinc(this.indexVariable.resolvedPosition, 1);
          }
          // generate the condition
          conditionLabel.place();
          codeStream.load(this.indexVariable);
          codeStream.load(this.maxVariable);
          codeStream.if_icmplt(actionLabel);
          break;
        case RAW_ITERABLE :
        case GENERIC_ITERABLE :
          // generate the condition
          conditionLabel.place();
          codeStream.load(this.indexVariable);
          codeStream.invokeJavaUtilIteratorHasNext();
          codeStream.ifne(actionLabel);
          break;
      }
View Full Code Here

      // generate code related to the activation of assertion for this class
      codeStream.generateClassLiteralAccessForType(
          classScope.outerMostClassScope().enclosingSourceType(),
          this.classLiteralSyntheticField);
      codeStream.invokeJavaLangClassDesiredAssertionStatus();
      BranchLabel falseLabel = new BranchLabel(codeStream);
      codeStream.ifne(falseLabel);
      codeStream.iconst_1();
      BranchLabel jumpLabel = new BranchLabel(codeStream);
      codeStream.decrStackSize(1);
      codeStream.goto_(jumpLabel);
      falseLabel.place();
      codeStream.iconst_0();
      jumpLabel.place();
      codeStream.fieldAccess(Opcodes.OPC_putstatic, this.assertionSyntheticFieldBinding, null /* default declaringClass */);
    }
    // generate static fields/initializers/enum constants
    final FieldDeclaration[] fieldDeclarations = declaringType.fields;
    int sourcePosition = -1;
View Full Code Here

TOP

Related Classes of org.eclipse.jdt.internal.compiler.codegen.BranchLabel

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.