vasco.soot
Class DefaultJimpleRepresentation

java.lang.Object
  extended by vasco.soot.DefaultJimpleRepresentation
All Implemented Interfaces:
ProgramRepresentation<SootMethod,Unit>

public class DefaultJimpleRepresentation
extends Object
implements ProgramRepresentation<SootMethod,Unit>

A default program representation for Soot using the Jimple IR. This representation uses control-flow graphs of individual units including exceptional control flow, and resolves virtual calls using the default context-insensitive call graph.

Note: This class follows the Singleton pattern. The singleton object is available through v().

Author:
Rohan Padhye

Method Summary
 DirectedGraph<Unit> getControlFlowGraph(SootMethod method)
          Returns an ExceptionalUnitGraph for a given method.
 List<SootMethod> getEntryPoints()
          Returns a singleton list containing the main method.
 boolean isCall(Unit node)
          Returns true iff the Jimple statement contains an invoke expression.
 List<SootMethod> resolveTargets(SootMethod method, Unit node)
          Resolves virtual calls using the default call graph and returns a list of methods which are the targets of explicit edges.
static DefaultJimpleRepresentation v()
          Returns a reference to the singleton object of this class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getEntryPoints

public List<SootMethod> getEntryPoints()
Returns a singleton list containing the main method.

Specified by:
getEntryPoints in interface ProgramRepresentation<SootMethod,Unit>
Returns:
a list of program entry points (methods)
See Also:
Scene.getMainMethod()

getControlFlowGraph

public DirectedGraph<Unit> getControlFlowGraph(SootMethod method)
Returns an ExceptionalUnitGraph for a given method.

Specified by:
getControlFlowGraph in interface ProgramRepresentation<SootMethod,Unit>
Parameters:
method - the method whose CFG to return
Returns:
an intra-procedural control-flow-graph for a given procedure (method)

isCall

public boolean isCall(Unit node)
Returns true iff the Jimple statement contains an invoke expression.

Specified by:
isCall in interface ProgramRepresentation<SootMethod,Unit>
Parameters:
node - a node in the control-flow graph
Returns:
whether a given node contains a method call.

resolveTargets

public List<SootMethod> resolveTargets(SootMethod method,
                                       Unit node)
Resolves virtual calls using the default call graph and returns a list of methods which are the targets of explicit edges. TODO: Should we consider thread/clinit edges?

Specified by:
resolveTargets in interface ProgramRepresentation<SootMethod,Unit>
Parameters:
method - the method in which the call statement originates
node - the node containing the call statement
Returns:
a list of methods which are the target of this call, if their bodies are available, or else null in the case of native targets

v

public static DefaultJimpleRepresentation v()
Returns a reference to the singleton object of this class.