Example usage for org.aspectj.apache.bcel.generic InstructionHandle getInstruction

List of usage examples for org.aspectj.apache.bcel.generic InstructionHandle getInstruction

Introduction

In this page you can find the example usage for org.aspectj.apache.bcel.generic InstructionHandle getInstruction.

Prototype

public final Instruction getInstruction() 

Source Link

Usage

From source file:br.jabuti.graph.datastructure.dug.CFG.java

License:Open Source License

/**
 * This method removes unconditional branch instructions that are alone in a node
 *//*  ww  w  .j ava2  s. c  o m*/
private void cleanUp(MethodGen meth) {
    for (int i = size() - 1; i >= 0; i--) {
        CFGNode gfcn = (CFGNode) elementAt(i);

        InstructionHandle start = br.jabuti.util.InstructCtrl.findInstruction(meth, gfcn.getStart());
        InstructionHandle end = br.jabuti.util.InstructCtrl.findInstruction(meth, gfcn.getEnd());
        Instruction is = start.getInstruction(), ie = end.getInstruction();
        if (is == ie) {
            if (is instanceof GotoInstruction)
                jumpOverNode(gfcn, false); // removes gfcn but set next
        }
    }
}

From source file:br.jabuti.util.InstructCtrl.java

License:Open Source License

/** Computes the set of instructions that can be executed after a 
 given instruction./*w ww .  j a  va 2 s.  c  o m*/
        
 @param x The instruction for which is wanted the set of possible
 followers
 @return The set of instructions that can be executed after the instruction
 got as argument
 */
static public InstructionHandle[] nextToExec(InstructionHandle x) {
    Vector v = new Vector();
    InstructionHandle pr = x.getNext();
    Instruction inst = x.getInstruction();

    if (pr != null) {
        if (!(inst instanceof UnconditionalBranch || inst instanceof Select || inst instanceof ReturnInstruction
                || inst instanceof RET)) {
            v.add(pr);
        }
    }
    if (inst instanceof Select) {
        InstructionHandle[] targ = ((Select) inst).getTargets();

        for (int i = 0; i < targ.length; i++) {
            v.add(targ[i]);
        }
    }
    if (inst instanceof BranchInstruction) {
        v.add(((BranchInstruction) inst).getTarget());
    }
    return (InstructionHandle[]) v.toArray(new InstructionHandle[0]);
}