Examples of BranchLabel


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

  public FlowInfo analyseCode(
    BlockScope currentScope,
    FlowContext flowContext,
    FlowInfo flowInfo) {
    // initialize break and continue labels
    breakLabel = new BranchLabel();
    continueLabel = new BranchLabel();

    // process the element variable and collection
    this.collection.checkNPE(currentScope, flowContext, flowInfo);
    flowInfo = this.elementVariable.analyseCode(scope, flowContext, flowInfo);
    FlowInfo condInfo = this.collection.analyseCode(scope, flowContext, flowInfo.copy());
View Full Code Here

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

        }
        codeStream.store(this.indexVariable, false);
        break;
    }
    // label management
    BranchLabel actionLabel = new BranchLabel(codeStream);
    actionLabel.tagBits |= BranchLabel.USED;
    BranchLabel conditionLabel = new BranchLabel(codeStream);
    conditionLabel.tagBits |= BranchLabel.USED;
    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(breakLabel);
          break;
        case RAW_ITERABLE :
        case GENERIC_ITERABLE :
          codeStream.load(this.indexVariable);
          codeStream.invokeJavaUtilIteratorHasNext();
          codeStream.ifeq(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(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; // AspectJ Extension - 155763 - don't do this here
      // 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

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

      // generate code related to the activation of assertion for this class
      codeStream.generateClassLiteralAccessForType(
          classScope.outerMostClassScope().enclosingSourceType(),
        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.putstatic(this.assertionSyntheticFieldBinding);
    }
  }
View Full Code Here

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

   
    if (initFailureField != null) {
      // Changes to this exception handling code may require changes to
      // BcelClassWeaver.isInitFailureHandler()
      handlerLabel.placeEnd();
      BranchLabel endLabel = new BranchLabel(codeStream);
      codeStream.goto_(endLabel);
      handlerLabel.place();
      codeStream.astore_0(); // Bug #52394
      // CHECK THIS...
      codeStream.addVariable(new LocalVariableBinding("caughtException".toCharArray(),initFailureField.type,ClassFileConstants.AccPrivate,false));
        codeStream.aload_0();
      codeStream.putstatic(initFailureField);
      endLabel.place();
    }
   
  }
View Full Code Here

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

  // PTWIMPL Generate aspectOf() method
  private void generatePerTypeWithinAspectOfMethod(ClassFile classFile) {
    final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
    generateMethod(classFile, aspectOfMethod, new BodyGenerator() {
      public void generate(CodeStream codeStream) {
        BranchLabel instanceFound = new BranchLabel(codeStream);

        ExceptionLabel anythingGoesWrong = new ExceptionLabel(codeStream, world
            .makeTypeBinding(UnresolvedType.JL_EXCEPTION));
        anythingGoesWrong.placeStart();
        codeStream.aload_0();
        codeStream.invokestatic(world.makeMethodBindingForCall(AjcMemberMaker.perTypeWithinGetInstance(typeX)));
        codeStream.astore_1();
        codeStream.aload_1();
        codeStream.ifnonnull(instanceFound);
        codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION));
        codeStream.dup();

        codeStream.ldc(typeX.getName());
        codeStream.aconst_null();

        codeStream.invokespecial(world.makeMethodBindingForCall(AjcMemberMaker.noAspectBoundExceptionInit2()));
        codeStream.athrow();
        instanceFound.place();
        codeStream.aload_1();

        codeStream.areturn();
        anythingGoesWrong.placeEnd();
        anythingGoesWrong.place();
View Full Code Here

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

  private void generatePerObjectAspectOfMethod(ClassFile classFile, final TypeBinding interfaceType) {
    final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
    generateMethod(classFile, aspectOfMethod, new BodyGenerator() {
      public void generate(CodeStream codeStream) {
        // body starts here
        BranchLabel wrongType = new BranchLabel(codeStream);
        BranchLabel popWrongType = new BranchLabel(codeStream);
        codeStream.aload_0();
        codeStream.instance_of(interfaceType);
        codeStream.ifeq(wrongType);
        codeStream.aload_0();
        codeStream.checkcast(interfaceType);
        codeStream.invokeinterface(world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceGet(typeX)));

        codeStream.dup();
        codeStream.ifnull(popWrongType);
        codeStream.areturn();

        popWrongType.place();
        codeStream.pop();

        wrongType.place();
        codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION));
        codeStream.dup();
View Full Code Here

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

  private void generatePerObjectHasAspectMethod(ClassFile classFile, final TypeBinding interfaceType) {
    final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
    generateMethod(classFile, hasAspectMethod, new BodyGenerator() {
      public void generate(CodeStream codeStream) {
        // body starts here
        BranchLabel wrongType = new BranchLabel(codeStream);
        codeStream.aload_0();
        codeStream.instance_of(interfaceType);
        codeStream.ifeq(wrongType);
        codeStream.aload_0();
        codeStream.checkcast(interfaceType);
        codeStream.invokeinterface(world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceGet(typeX)));
        codeStream.ifnull(wrongType);
        codeStream.iconst_1();
        codeStream.ireturn();

        wrongType.place();
        codeStream.iconst_0();
        codeStream.ireturn();
        // body ends here
      }
    });
View Full Code Here

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

  private void generatePerTypeWithinHasAspectMethod(ClassFile classFile) {
    final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
    generateMethod(classFile, hasAspectMethod, new BodyGenerator() {
      public void generate(CodeStream codeStream) {
        ExceptionLabel goneBang = new ExceptionLabel(codeStream, world.makeTypeBinding(UnresolvedType.JL_EXCEPTION));
        BranchLabel noInstanceExists = new BranchLabel(codeStream);
        BranchLabel leave = new BranchLabel(codeStream);
        goneBang.placeStart();
        codeStream.aload_0();
        codeStream.invokestatic(world.makeMethodBinding(AjcMemberMaker.perTypeWithinGetInstance(typeX)));
        codeStream.ifnull(noInstanceExists);
        codeStream.iconst_1();
        codeStream.goto_(leave);
        noInstanceExists.place();
        codeStream.iconst_0();
        leave.place();
        goneBang.placeEnd();
        codeStream.ireturn();
        goneBang.place();
        codeStream.astore_1();
        codeStream.iconst_0();
View Full Code Here

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

  private void generatePerObjectBindMethod(ClassFile classFile, final TypeBinding interfaceType) {
    final EclipseFactory world = EclipseFactory.fromScopeLookupEnvironment(this.scope);
    generateMethod(classFile, AjcMemberMaker.perObjectBind(world.fromBinding(binding)), new BodyGenerator() {
      public void generate(CodeStream codeStream) {
        // body starts here
        BranchLabel wrongType = new BranchLabel(codeStream);
        codeStream.aload_0();
        codeStream.instance_of(interfaceType);
        codeStream.ifeq(wrongType); // XXX this case might call for screaming
        codeStream.aload_0();
        codeStream.checkcast(interfaceType);
        codeStream.invokeinterface(world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceGet(typeX)));
        // XXX should do a check for null here and throw a NoAspectBound
        codeStream.ifnonnull(wrongType);

        codeStream.aload_0();
        codeStream.checkcast(interfaceType);
        codeStream.new_(binding);
        codeStream.dup();
        codeStream.invokespecial(new MethodBinding(0, "<init>".toCharArray(), TypeBinding.VOID, new TypeBinding[0],
            new ReferenceBinding[0], binding));
        codeStream.invokeinterface(world.makeMethodBindingForCall(AjcMemberMaker.perObjectInterfaceSet(typeX)));

        wrongType.place();
        codeStream.return_();
        // body ends here
      }
    });
  }
View Full Code Here

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

         * ajc$perSingletonInstance;
         */
        // body starts here (see end of each line for what it is doing!)
        FieldBinding fb = world.makeFieldBinding(AjcMemberMaker.perSingletonField(typeX));
        codeStream.getstatic(fb); // GETSTATIC
        BranchLabel isNonNull = new BranchLabel(codeStream);
        codeStream.ifnonnull(isNonNull); // IFNONNULL
        codeStream.new_(world.makeTypeBinding(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION)); // NEW
        codeStream.dup(); // DUP
        codeStream.ldc(typeX.getNameAsIdentifier()); // LDC
        codeStream.getstatic(initFailureField); // GETSTATIC
        codeStream.invokespecial(world.makeMethodBindingForCall(AjcMemberMaker.noAspectBoundExceptionInitWithCause())); // INVOKESPECIAL
        codeStream.athrow(); // ATHROW
        isNonNull.place();
        codeStream.getstatic(fb); // GETSTATIC
        codeStream.areturn(); // ARETURN
        // body ends here
      }
    });
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.