Control-flow graph¶
The basic blocks of one method and the edges between them. See control-flow graph in the code guide.
Cfg
¶
The control-flow graph of one method.
The blocks are ordered by offset, and block 0 is where the method starts.
len(cfg) is the number of blocks.
blocks
property
¶
blocks: BasicBlockView
The basic blocks, as a read-only sequence that copies nothing.
entry
property
¶
entry: Optional[BasicBlock]
The block where the method starts, or None when the graph is empty.
block_at_offset
¶
block_at_offset(offset: int) -> Optional[BasicBlock]
The block that starts at this code-unit offset, or None when no block
starts there. Use it to follow a branch target to its block.
BasicBlock
¶
A run of instructions that is always entered at its first instruction and left at its last one.
first_insn
property
¶
Index in Method.instructions of the block's first instruction.
successors
property
¶
successors: list[CfgEdge]
The edges that leave the block. A block that returns or throws has none.
predecessors
property
¶
Indices in Cfg.blocks of the blocks with an edge to this one.
is_handler_entry
property
¶
True when the block is the start of a catch handler.
CfgEdge
¶
An edge from one basic block to another.
case_key
property
¶
The value a switch case matches, for a SWITCH_CASE edge. None for every
other kind.
catch_type
property
¶
Descriptor of the exception class the handler catches, such as
"Ljava/io/IOException;", for an EXCEPTION edge. None for every other kind,
including EXCEPTION_CATCH_ALL, which catches everything.
CfgEdgeKind
¶
Bases: Enum
The kind of edge between two basic blocks of a control-flow graph.
FALLTHROUGH
class-attribute
instance-attribute
¶
Execution runs on into the next block. The block's last instruction is not a branch, a return or a throw.
BRANCH_TAKEN
class-attribute
instance-attribute
¶
The condition of an if instruction holds, and it jumps.
BRANCH_NOT_TAKEN
class-attribute
instance-attribute
¶
The condition of an if instruction does not hold, and execution continues after
it.
SWITCH_CASE
class-attribute
instance-attribute
¶
One case of a switch. The edge's case_key is the value the case matches.
SWITCH_DEFAULT
class-attribute
instance-attribute
¶
No case of a switch matches, and execution continues after it.
EXCEPTION
class-attribute
instance-attribute
¶
From a block inside a try range to the handler of one exception class. The edge's
catch_type is the descriptor of that class.
EXCEPTION_CATCH_ALL
class-attribute
instance-attribute
¶
From a block inside a try range to a handler that catches every exception. Java
compiles a finally block to such a handler.