FileDocCategorySizeDatePackage
ControlFlowGraph.javaAPI DocJava SE 5 API16418Fri Aug 26 14:55:26 BST 2005com.sun.org.apache.bcel.internal.verifier.structurals

ControlFlowGraph

public class ControlFlowGraph extends Object
This class represents a control flow graph of a method.
version
$Id: ControlFlowGraph.java,v 1.1.1.1 2001/10/29 20:00:37 jvanzyl Exp $
author
Enver Haase

Fields Summary
private final MethodGen
method_gen
The MethofGen object we're working on.
private final Subroutines
subroutines
The Subroutines object for the method whose control flow is represented by this ControlFlowGraph.
private final ExceptionHandlers
exceptionhandlers
The ExceptionHandlers object for the method whose control flow is represented by this ControlFlowGraph.
private Hashtable
instructionContexts
All InstructionContext instances of this ControlFlowGraph.
Constructors Summary
public ControlFlowGraph(MethodGen method_gen)
A Control Flow Graph.

 //keys: InstructionHandle, values: InstructionContextImpl

	     	 
	  
		subroutines = new Subroutines(method_gen);
		exceptionhandlers = new ExceptionHandlers(method_gen);

		InstructionHandle[] instructionhandles = method_gen.getInstructionList().getInstructionHandles();
		for (int i=0; i<instructionhandles.length; i++){
			instructionContexts.put(instructionhandles[i], new InstructionContextImpl(instructionhandles[i]));
		}
		
		this.method_gen = method_gen;
	
Methods Summary
public InstructionContextcontextOf(com.sun.org.apache.bcel.internal.generic.InstructionHandle inst)
Returns the InstructionContext of a given instruction.

		InstructionContext ic = (InstructionContext) instructionContexts.get(inst);
		if (ic == null){
			throw new AssertionViolatedException("InstructionContext requested for an InstructionHandle that's not known!");
		}
		return ic;
	
public InstructionContext[]contextsOf(com.sun.org.apache.bcel.internal.generic.InstructionHandle[] insts)
Returns the InstructionContext[] of a given InstructionHandle[], in a naturally ordered manner.

		InstructionContext[] ret = new InstructionContext[insts.length];
		for (int i=0; i<insts.length; i++){
			ret[i] = contextOf(insts[i]);
		}
		return ret;
	
public InstructionContext[]getInstructionContexts()
Returns an InstructionContext[] with all the InstructionContext instances for the method whose control flow is represented by this ControlFlowGraph (NOT ORDERED!).

		InstructionContext[] ret = new InstructionContext[instructionContexts.values().size()];
		return (InstructionContext[]) instructionContexts.values().toArray(ret);
	
public booleanisDead(com.sun.org.apache.bcel.internal.generic.InstructionHandle i)
Returns true, if and only if the said instruction is not reachable; that means, if it not part of this ControlFlowGraph.

		return instructionContexts.containsKey(i);