A basic block in a control flow graph.
All instructions (generally, AST nodes) in a basic block are either executed or none are (with the exception of blocks interrupted by exceptions). These instructions are executed in a straight-line manner.
Method | __init__ |
Undocumented |
Method | add |
Adds an exit from this block to block . |
Method | add |
Undocumented |
Method | can |
Undocumented |
Method | can |
Undocumented |
Method | compact |
Undocumented |
Method | exits |
Whether this block exits to block . |
Method | get |
Gets the value of a label on the BasicBlock. |
Method | has |
Returns whether this BasicBlock has the specified label. |
Method | index |
Returns the index of the Instruction in this BasicBlock. |
Method | is |
Whether this block is empty. |
Method | merge |
Merge this block with its one successor. |
Method | prune |
Prunes the empty block from its control flow graph. |
Method | raises |
Whether this block exits to block in the case of an exception. |
Method | remove |
Removes the exit from this block to block . |
Method | set |
Sets the value of a label on the BasicBlock. |
Instance Variable | branches |
A map from booleans to the basic block reachable by making the branch decision indicated by that boolean. |
Instance Variable | control |
Maps from id(control_flow_node) to the ControlFlowNode's index in self.control_flow_nodes. Only available once the block is compacted. |
Instance Variable | control |
A list of the ControlFlowNodes contained in this basic block. Each ControlFlowNode corresponds to a single Instruction. |
Instance Variable | except |
Undocumented |
Instance Variable | exits |
These basic blocks may only be exited to at the end of the execution of this basic block. |
Instance Variable | exits |
These basic blocks may be exited to at any point during the execution of this basic block. |
Instance Variable | graph |
The control flow graph which this basic block is a part of. |
Instance Variable | identities |
A list of (node, label) pairs that refer to this basic block. This starts as (self.node, self.label), but old identities are preserved during merging and pruning. Allows lookup of blocks by node and label, e... |
Instance Variable | label |
A label for the basic block. |
Instance Variable | labels |
Labels, used for example by data flow analyses. Maps from label name to value. |
Instance Variable | next |
Indicates which basic blocks may be executed after this basic block. |
Instance Variable | node |
The AST node this basic block is associated with. |
Instance Variable | prev |
Indicates which basic blocks may lead to the execution of this basic block in a Python program. |
Instance Variable | prunable |
Whether this basic block may be pruned from the control flow graph if empty. Set to False for special blocks, such as enter and exit blocks. |
Instance Variable | reraise |
Undocumented |
Adds an exit from this block to block
.
Prunes the empty block from its control flow graph.
A block is prunable if it has no control flow nodes and has not been marked as unprunable (e.g. because it's the exit block, or a return block, etc).
Returns | |
The block removed by the prune operation. That is, self. |
A map from booleans to the basic block reachable by making the branch decision indicated by that boolean.
Maps from id(control_flow_node) to the ControlFlowNode's index in self.control_flow_nodes. Only available once the block is compacted.
A list of the ControlFlowNodes contained in this basic block. Each ControlFlowNode corresponds to a single Instruction.
A list of (node, label) pairs that refer to this basic block. This starts as (self.node, self.label), but old identities are preserved during merging and pruning. Allows lookup of blocks by node and label, e.g. for finding the after block of a particular if statement.