|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.android.tools.lint.checks.ControlFlowGraph
public class ControlFlowGraph
A ControlFlowGraph is a graph containing a node for each instruction in a method, and an edge for each possible control flow; usually just "next" for the instruction following the current instruction, but in the case of a branch such as an "if", multiple edges to each successive location, or with a "goto", a single edge to the jumped-to instruction.
It also adds edges for abnormal control flow, such as the possibility of a method call throwing a runtime exception.
Nested Class Summary | |
---|---|
static class |
ControlFlowGraph.Node
A ControlFlowGraph.Node is a node in the control flow graph for a method, pointing to
the instruction and its possible successors |
Constructor Summary | |
---|---|
ControlFlowGraph()
|
Method Summary | |
---|---|
protected void |
add(org.objectweb.asm.tree.AbstractInsnNode from,
org.objectweb.asm.tree.AbstractInsnNode to)
Adds an exception flow to this graph |
static ControlFlowGraph |
create(ControlFlowGraph initial,
org.objectweb.asm.tree.ClassNode classNode,
org.objectweb.asm.tree.MethodNode method)
Creates a new ControlFlowGraph and populates it with the flow
control for the given method. |
protected void |
exception(org.objectweb.asm.tree.AbstractInsnNode from,
org.objectweb.asm.tree.AbstractInsnNode to)
Adds an exception flow to this graph |
protected void |
exception(org.objectweb.asm.tree.AbstractInsnNode from,
org.objectweb.asm.tree.TryCatchBlockNode tcb)
Adds an exception try block node to this graph |
ControlFlowGraph.Node |
getNode(org.objectweb.asm.tree.AbstractInsnNode instruction)
Looks up (and if necessary) creates a graph node for the given instruction |
boolean |
isConnected(org.objectweb.asm.tree.AbstractInsnNode from,
org.objectweb.asm.tree.AbstractInsnNode to)
Checks whether there is a path from the given instruction to the given instruction node |
boolean |
isConnected(ControlFlowGraph.Node from,
ControlFlowGraph.Node to)
Checks whether there is a path from the given source node to the given destination node |
java.lang.String |
toDot(java.util.Set<ControlFlowGraph.Node> highlight)
Generates dot output of the graph. |
java.lang.String |
toString()
|
java.lang.String |
toString(ControlFlowGraph.Node start)
Creates a human readable version of the graph |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ControlFlowGraph()
Method Detail |
---|
@NonNull public static ControlFlowGraph create(@Nullable ControlFlowGraph initial, @NonNull org.objectweb.asm.tree.ClassNode classNode, @NonNull org.objectweb.asm.tree.MethodNode method) throws org.objectweb.asm.tree.analysis.AnalyzerException
ControlFlowGraph
and populates it with the flow
control for the given method. If the optional initial
parameter is
provided with an existing graph, then the graph is simply populated, not
created. This allows subclassing of the graph instance, if necessary.
initial
- usually null, but can point to an existing instance of a
ControlFlowGraph
in which that graph is reused (but
populated with new edges)classNode
- the class containing the method to be analyzedmethod
- the method to be analyzed
ControlFlowGraph
with nodes for the control flow in the
given method
org.objectweb.asm.tree.analysis.AnalyzerException
- if the underlying bytecode library is unable to
analyze the method bytecodepublic boolean isConnected(@NonNull ControlFlowGraph.Node from, @NonNull ControlFlowGraph.Node to)
public boolean isConnected(@NonNull org.objectweb.asm.tree.AbstractInsnNode from, @NonNull org.objectweb.asm.tree.AbstractInsnNode to)
protected void add(@NonNull org.objectweb.asm.tree.AbstractInsnNode from, @NonNull org.objectweb.asm.tree.AbstractInsnNode to)
protected void exception(@NonNull org.objectweb.asm.tree.AbstractInsnNode from, @NonNull org.objectweb.asm.tree.AbstractInsnNode to)
protected void exception(@NonNull org.objectweb.asm.tree.AbstractInsnNode from, @NonNull org.objectweb.asm.tree.TryCatchBlockNode tcb)
@NonNull public ControlFlowGraph.Node getNode(@NonNull org.objectweb.asm.tree.AbstractInsnNode instruction)
instruction
- the instruction
@NonNull public java.lang.String toString(@Nullable ControlFlowGraph.Node start)
start
- the starting instruction, or null if not known or to use the
first instruction
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String toDot(@Nullable java.util.Set<ControlFlowGraph.Node> highlight)
$ dot -Tps graph1.gv -o graph1.psto generate a postscript file, which you can then view with "gv graph1.ps". (There are also some online web sites where you can paste in dot graphs and see the visualization right there in the browser.)
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |