Package org.aspectj.apache.bcel.generic

Examples of org.aspectj.apache.bcel.generic.InstructionBranch


    InstructionHandle tryStart = il.append(InstructionConstants.ALOAD_0);

    il.append(Utility.createInvoke(factory, Constants.INVOKESTATIC, AjcMemberMaker.perTypeWithinGetInstance(aspectType)));
    il.append(InstructionConstants.ASTORE_1);
    il.append(InstructionConstants.ALOAD_1);
    InstructionBranch ifNonNull = InstructionFactory.createBranchInstruction(Constants.IFNONNULL, null);
    il.append(ifNonNull);
    il.append(factory.createNew(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName()));
    il.append(InstructionConstants.DUP);
    il.append(InstructionFactory.PUSH(classGen.getConstantPool(), aspectType.getName()));
    il.append(InstructionConstants.ACONST_NULL);
    il.append(factory.createInvoke(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName(), "<init>", Type.VOID, new Type[] {
        Type.STRING, new ObjectType("java.lang.Throwable") }, Constants.INVOKESPECIAL));
    il.append(InstructionConstants.ATHROW);
    InstructionHandle ifElse = il.append(InstructionConstants.ALOAD_1);
    ifNonNull.setTarget(ifElse);
    il.append(InstructionFactory.createReturn(Type.OBJECT));

    InstructionHandle handler = il.append(InstructionConstants.ASTORE_1);
    il.append(factory.createNew(AjcMemberMaker.NO_ASPECT_BOUND_EXCEPTION.getName()));
    il.append(InstructionConstants.DUP);
View Full Code Here


    classGen.addMethodGen(method);

    InstructionList il = method.getBody();
    InstructionHandle tryStart = il.append(InstructionConstants.ALOAD_0);
    il.append(Utility.createInvoke(factory, Constants.INVOKESTATIC, AjcMemberMaker.perTypeWithinGetInstance(aspectType)));
    InstructionBranch ifNull = InstructionFactory.createBranchInstruction(Constants.IFNULL, null);
    il.append(ifNull);
    il.append(InstructionConstants.ICONST_1);
    il.append(InstructionConstants.IRETURN);
    InstructionHandle ifElse = il.append(InstructionConstants.ICONST_0);
    ifNull.setTarget(ifElse);
    il.append(InstructionConstants.IRETURN);

    InstructionHandle handler = il.append(InstructionConstants.ASTORE_1);
    il.append(InstructionConstants.ICONST_0);
    il.append(InstructionConstants.IRETURN);
View Full Code Here

    }
  }

  private void handleBranchInstruction(Map<InstructionHandle, InstructionHandle> map, Instruction oldInstruction,
      Instruction newInstruction) {
    InstructionBranch oldBranchInstruction = (InstructionBranch) oldInstruction;
    InstructionBranch newBranchInstruction = (InstructionBranch) newInstruction;
    InstructionHandle oldTarget = oldBranchInstruction.getTarget(); // old
    // target

    // New target is in hash map
    newBranchInstruction.setTarget(remap(oldTarget, map));

    if (oldBranchInstruction instanceof InstructionSelect) {
      // Either LOOKUPSWITCH or TABLESWITCH
      InstructionHandle[] oldTargets = ((InstructionSelect) oldBranchInstruction).getTargets();
      InstructionHandle[] newTargets = ((InstructionSelect) newBranchInstruction).getTargets();
View Full Code Here

  /**
   * Process a branch instruction with respect to instructions that are about to be deleted. If the target for the branch is a
   * candidate for deletion, move it to the next valid instruction after the deleted target.
   */
  private void handleBranchInstruction(BranchHandle branchHandle, Set<InstructionHandle> handlesForDeletion) {
    InstructionBranch branchInstruction = (InstructionBranch) branchHandle.getInstruction();
    InstructionHandle target = branchInstruction.getTarget(); // old target

    if (handlesForDeletion.contains(target)) {
      do {
        target = target.getNext();
      } while (handlesForDeletion.contains(target));
      branchInstruction.setTarget(target);
    }

    if (branchInstruction instanceof InstructionSelect) {
      // Either LOOKUPSWITCH or TABLESWITCH
      InstructionSelect iSelect = (InstructionSelect) branchInstruction;
View Full Code Here

        if (((ExceptionRange) r).getHandler() == target) {
          return;
        }
      }
    } else if (targeter instanceof InstructionBranch) {
      InstructionBranch bi = (InstructionBranch) targeter;
      if (bi.getTarget() == target) {
        return;
      }
      if (targeter instanceof InstructionSelect) {
        InstructionSelect sel = (InstructionSelect) targeter;
        InstructionHandle[] itargets = sel.getTargets();
View Full Code Here

        printLabel(null, depth);
        out.print("  ");
        out.print("default: \t");
        out.print(labelMap.get(defaultTarget));
      } else if (inst instanceof InstructionBranch) {
        InstructionBranch brinst = (InstructionBranch) inst;
        out.print(Constants.OPCODE_NAMES[brinst.getOpcode()].toUpperCase());
        out.print(" ");
        out.print(labelMap.get(brinst.getTarget()));
      } else if (inst.isLocalVariableInstruction()) {
        // LocalVariableInstruction lvinst = (LocalVariableInstruction)
        // inst;
        out.print(inst.toString(false).toUpperCase());
        int index = inst.getIndex();
View Full Code Here

    }
  }

  private void handleBranchInstruction(Map<InstructionHandle, InstructionHandle> map, Instruction oldInstruction,
      Instruction newInstruction) {
    InstructionBranch oldBranchInstruction = (InstructionBranch) oldInstruction;
    InstructionBranch newBranchInstruction = (InstructionBranch) newInstruction;
    InstructionHandle oldTarget = oldBranchInstruction.getTarget(); // old
    // target

    // New target is in hash map
    newBranchInstruction.setTarget(remap(oldTarget, map));

    if (oldBranchInstruction instanceof InstructionSelect) {
      // Either LOOKUPSWITCH or TABLESWITCH
      InstructionHandle[] oldTargets = ((InstructionSelect) oldBranchInstruction).getTargets();
      InstructionHandle[] newTargets = ((InstructionSelect) newBranchInstruction).getTargets();
View Full Code Here

  /**
   * Process a branch instruction with respect to instructions that are about to be deleted. If the target for the branch is a
   * candidate for deletion, move it to the next valid instruction after the deleted target.
   */
  private void handleBranchInstruction(BranchHandle branchHandle, Set<InstructionHandle> handlesForDeletion) {
    InstructionBranch branchInstruction = (InstructionBranch) branchHandle.getInstruction();
    InstructionHandle target = branchInstruction.getTarget(); // old target

    if (handlesForDeletion.contains(target)) {
      do {
        target = target.getNext();
      } while (handlesForDeletion.contains(target));
      branchInstruction.setTarget(target);
    }

    if (branchInstruction instanceof InstructionSelect) {
      // Either LOOKUPSWITCH or TABLESWITCH
      InstructionSelect iSelect = (InstructionSelect) branchInstruction;
View Full Code Here

        if (((ExceptionRange) r).getHandler() == target) {
          return;
        }
      }
    } else if (targeter instanceof InstructionBranch) {
      InstructionBranch bi = (InstructionBranch) targeter;
      if (bi.getTarget() == target) {
        return;
      }
      if (targeter instanceof InstructionSelect) {
        InstructionSelect sel = (InstructionSelect) targeter;
        InstructionHandle[] itargets = sel.getTargets();
View Full Code Here

        printLabel(null, depth);
        out.print("  ");
        out.print("default: \t");
        out.print(labelMap.get(defaultTarget));
      } else if (inst instanceof InstructionBranch) {
        InstructionBranch brinst = (InstructionBranch) inst;
        out.print(Constants.OPCODE_NAMES[brinst.getOpcode()].toUpperCase());
        out.print(" ");
        out.print(labelMap.get(brinst.getTarget()));
      } else if (inst.isLocalVariableInstruction()) {
        // LocalVariableInstruction lvinst = (LocalVariableInstruction)
        // inst;
        out.print(inst.toString(false).toUpperCase());
        int index = inst.getIndex();
View Full Code Here

TOP

Related Classes of org.aspectj.apache.bcel.generic.InstructionBranch

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.