2006-11-22 17:38:46 +00:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2002 - 2006 IBM Corporation.
|
|
|
|
* All rights reserved. This program and the accompanying materials
|
|
|
|
* are made available under the terms of the Eclipse Public License v1.0
|
|
|
|
* which accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* IBM Corporation - initial API and implementation
|
|
|
|
*******************************************************************************/
|
|
|
|
package com.ibm.wala.cfg;
|
|
|
|
|
|
|
|
import java.util.Collection;
|
2007-10-04 15:48:46 +00:00
|
|
|
import java.util.List;
|
2006-11-22 17:38:46 +00:00
|
|
|
|
|
|
|
import com.ibm.wala.classLoader.IMethod;
|
|
|
|
import com.ibm.wala.util.graph.NumberedGraph;
|
|
|
|
import com.ibm.wala.util.intset.BitVector;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* An interface that is common to the Shrike and SSA CFG implementations.
|
|
|
|
*/
|
2009-02-19 15:58:31 +00:00
|
|
|
public interface ControlFlowGraph<I, T extends IBasicBlock<I>> extends NumberedGraph<T> {
|
2006-11-22 17:38:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the entry basic block in the CFG
|
|
|
|
*/
|
2007-09-02 14:45:41 +00:00
|
|
|
public T entry();
|
2006-11-22 17:38:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the synthetic exit block for the cfg
|
|
|
|
*/
|
2007-09-02 14:45:41 +00:00
|
|
|
public T exit();
|
2006-11-22 17:38:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the indices of the catch blocks, as a bit vector
|
|
|
|
*/
|
|
|
|
public BitVector getCatchBlocks();
|
|
|
|
|
|
|
|
/**
|
2009-03-30 21:04:17 +00:00
|
|
|
* @param index an instruction index
|
2006-11-22 17:38:46 +00:00
|
|
|
* @return the basic block which contains this instruction.
|
|
|
|
*/
|
2007-09-02 14:45:41 +00:00
|
|
|
public T getBlockForInstruction(int index);
|
2006-11-22 17:38:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the instructions of this CFG, as an array.
|
|
|
|
*/
|
2009-02-19 15:58:31 +00:00
|
|
|
I[] getInstructions();
|
2006-11-22 17:38:46 +00:00
|
|
|
|
|
|
|
/**
|
2007-10-15 16:32:31 +00:00
|
|
|
* TODO: move this into IR?
|
2009-03-30 21:04:17 +00:00
|
|
|
*
|
|
|
|
* @param index an instruction index
|
|
|
|
* @return the program counter (bytecode index) corresponding to that instruction
|
2006-11-22 17:38:46 +00:00
|
|
|
*/
|
|
|
|
public int getProgramCounter(int index);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the Method this CFG represents
|
|
|
|
*/
|
|
|
|
public IMethod getMethod();
|
|
|
|
|
|
|
|
/**
|
2009-03-30 21:04:17 +00:00
|
|
|
* The order of blocks returned must indicate the exception-handling scope. So the first block is the first candidate catch block,
|
|
|
|
* and so on. With this invariant one can compute the exceptional control flow for a given exception type.
|
2006-11-22 17:38:46 +00:00
|
|
|
*
|
2009-03-30 21:04:17 +00:00
|
|
|
* @return the basic blocks which may be reached from b via exceptional control flow
|
2006-11-22 17:38:46 +00:00
|
|
|
*/
|
2007-10-04 15:48:46 +00:00
|
|
|
public List<T> getExceptionalSuccessors(T b);
|
2006-11-22 17:38:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The order of blocks returned should be arbitrary but deterministic.
|
2009-03-30 21:04:17 +00:00
|
|
|
*
|
|
|
|
* @return the basic blocks which may be reached from b via normal control flow
|
2006-11-22 17:38:46 +00:00
|
|
|
*/
|
2007-09-02 14:45:41 +00:00
|
|
|
public Collection<T> getNormalSuccessors(T b);
|
2009-03-30 21:04:17 +00:00
|
|
|
|
2006-11-22 17:38:46 +00:00
|
|
|
/**
|
|
|
|
* The order of blocks returned should be arbitrary but deterministic.
|
|
|
|
*
|
2009-03-30 21:04:17 +00:00
|
|
|
* @return the basic blocks from which b may be reached via exceptional control flow
|
2006-11-22 17:38:46 +00:00
|
|
|
*/
|
2007-09-02 14:45:41 +00:00
|
|
|
public Collection<T> getExceptionalPredecessors(T b);
|
2006-11-22 17:38:46 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* The order of blocks returned should be arbitrary but deterministic.
|
|
|
|
*
|
2009-03-30 21:04:17 +00:00
|
|
|
* @return the basic blocks from which b may be reached via normal control flow
|
2006-11-22 17:38:46 +00:00
|
|
|
*/
|
2007-09-02 14:45:41 +00:00
|
|
|
public Collection<T> getNormalPredecessors(T b);
|
2006-11-22 17:38:46 +00:00
|
|
|
}
|