Package org.aspectj.apache.bcel.generic

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


   *     "use Utility.copyInstruction to work-around bug in Select.copy()";
   * </pre>
   */
  public static Instruction copyInstruction(Instruction i) {
    if (i instanceof InstructionSelect) {
      InstructionSelect freshSelect = (InstructionSelect) i;

      // Create a new targets array that looks just like the existing one
      InstructionHandle[] targets = new InstructionHandle[freshSelect.getTargets().length];
      for (int ii = 0; ii < targets.length; ii++) {
        targets[ii] = freshSelect.getTargets()[ii];
      }

      // Create a new select statement with the new targets array

      return new SwitchBuilder(freshSelect.getMatchs(), targets, freshSelect.getTarget()).getInstruction();
    } else {
      return i.copy(); // Use clone for shallow copy...
    }
  }
View Full Code Here


          // assert this is a GOTO
          // this was a return instruction we previously replaced
        } else {
          branch.setTarget(newTarget);
          if (branch instanceof InstructionSelect) {
            InstructionSelect select = (InstructionSelect) branch;
            InstructionHandle[] oldTargets = select.getTargets();
            for (int k = oldTargets.length - 1; k >= 0; k--) {
              select.setTarget(k, srcToDest.get(oldTargets[k]));
            }
          }
        }
      }
View Full Code Here

      branchInstruction.setTarget(target);
    }

    if (branchInstruction instanceof InstructionSelect) {
      // Either LOOKUPSWITCH or TABLESWITCH
      InstructionSelect iSelect = (InstructionSelect) branchInstruction;
      InstructionHandle[] targets = iSelect.getTargets();
      for (int k = targets.length - 1; k >= 0; k--) {
        InstructionHandle oneTarget = targets[k];
        if (handlesForDeletion.contains(oneTarget)) {
          do {
            oneTarget = oneTarget.getNext();
          } while (handlesForDeletion.contains(oneTarget));
          iSelect.setTarget(k, oneTarget);
          oneTarget.addTargeter(branchInstruction);
        }
      }
    }
  }
View Full Code Here

    }
    InstructionHandle target = ih.getTarget();
    assertInBody(target, body, from);
    assertTargetedBy(target, inst, from);
    if (inst instanceof InstructionSelect) {
      InstructionSelect sel = (InstructionSelect) inst;
      InstructionHandle[] itargets = sel.getTargets();
      for (int k = itargets.length - 1; k >= 0; k--) {
        assertInBody(itargets[k], body, from);
        assertTargetedBy(itargets[k], inst, from);
      }
    }
View Full Code Here

      InstructionBranch bi = (InstructionBranch) targeter;
      if (bi.getTarget() == target) {
        return;
      }
      if (targeter instanceof InstructionSelect) {
        InstructionSelect sel = (InstructionSelect) targeter;
        InstructionHandle[] itargets = sel.getTargets();
        for (int k = itargets.length - 1; k >= 0; k--) {
          if (itargets[k] == target) {
            return;
          }
        }
View Full Code Here

      if (inst.isConstantPoolInstruction()) {
        out.print(Constants.OPCODE_NAMES[inst.opcode].toUpperCase());
        out.print(" ");
        out.print(pool.constantToString(pool.getConstant(inst.getIndex())));
      } else if (inst instanceof InstructionSelect) {
        InstructionSelect sinst = (InstructionSelect) inst;
        out.println(Constants.OPCODE_NAMES[sinst.opcode].toUpperCase());
        int[] matches = sinst.getMatchs();
        InstructionHandle[] targets = sinst.getTargets();
        InstructionHandle defaultTarget = sinst.getTarget();
        for (int i = 0, len = matches.length; i < len; i++) {
          printDepth(depth);
          printLabel(null, depth);
          out.print("  ");
          out.print(matches[i]);
View Full Code Here

          // assert this is a GOTO
          // this was a return instruction we previously replaced
        } else {
          branch.setTarget(newTarget);
          if (branch instanceof InstructionSelect) {
            InstructionSelect select = (InstructionSelect) branch;
            InstructionHandle[] oldTargets = select.getTargets();
            for (int k = oldTargets.length - 1; k >= 0; k--) {
              select.setTarget(k, srcToDest.get(oldTargets[k]));
            }
          }
        }
      }
View Full Code Here

        InstructionBranch freshBranch = (InstructionBranch) freshI;
        InstructionHandle oldTarget = oldBranch.getTarget();
        oldTarget.removeTargeter(oldBranch);
        oldTarget.addTargeter(freshBranch);
        if (freshBranch instanceof InstructionSelect) {
          InstructionSelect oldSelect = (InstructionSelect) oldI;
          InstructionSelect freshSelect = (InstructionSelect) freshI;
          InstructionHandle[] oldTargets = freshSelect.getTargets();
          for (int k = oldTargets.length - 1; k >= 0; k--) {
            oldTargets[k].removeTargeter(oldSelect);
            oldTargets[k].addTargeter(freshSelect);
          }
        }
View Full Code Here

   *     &quot;use Utility.copyInstruction to work-around bug in Select.copy()&quot;;
   * </pre>
   */
  public static Instruction copyInstruction(Instruction i) {
    if (i instanceof InstructionSelect) {
      InstructionSelect freshSelect = (InstructionSelect) i;

      // Create a new targets array that looks just like the existing one
      InstructionHandle[] targets = new InstructionHandle[freshSelect.getTargets().length];
      for (int ii = 0; ii < targets.length; ii++) {
        targets[ii] = freshSelect.getTargets()[ii];
      }

      // Create a new select statement with the new targets array

      return new SwitchBuilder(freshSelect.getMatchs(), targets, freshSelect.getTarget()).getInstruction();
    } else {
      return i.copy(); // Use clone for shallow copy...
    }
  }
View Full Code Here

      branchInstruction.setTarget(target);
    }

    if (branchInstruction instanceof InstructionSelect) {
      // Either LOOKUPSWITCH or TABLESWITCH
      InstructionSelect iSelect = (InstructionSelect) branchInstruction;
      InstructionHandle[] targets = iSelect.getTargets();
      for (int k = targets.length - 1; k >= 0; k--) {
        InstructionHandle oneTarget = targets[k];
        if (handlesForDeletion.contains(oneTarget)) {
          do {
            oneTarget = oneTarget.getNext();
          } while (handlesForDeletion.contains(oneTarget));
          iSelect.setTarget(k, oneTarget);
          oneTarget.addTargeter(branchInstruction);
        }
      }
    }
  }
View Full Code Here

TOP

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

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.