class documentation
Control flow graph builder.
A control flow graph builder is an ast.NodeVisitor that can walk through a program's AST and iteratively build the corresponding CFG.
| Method | __init__ |
Undocumented |
| Method | add |
Add a new exit to a block. |
| Method | add |
Add a statement to a block. |
| Method | build |
Build a CFG from an AST. |
| Method | build |
Build a CFG from some Python source file. |
| Method | build |
Build a CFG from some Python source code. |
| Method | clean |
Remove the useless (empty) blocks from a CFG. |
| Method | goto |
Undocumented |
| Method | new |
Create a new block with a new id. |
| Method | new_ |
Create a new sub-CFG for a class definition and add it to the function CFGs of the CFG being built. |
| Method | new_function |
Create a new sub-CFG for a function definition and add it to the function CFGs of the CFG being built. |
| Method | new |
Create a new block for a loop's guard if the current block is not empty. Links the current block to the new loop guard. |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Method | visit_ |
Undocumented |
| Class Variable | __all__ |
Undocumented |
| Instance Variable | after |
Undocumented |
| Instance Variable | cfg |
Undocumented |
| Instance Variable | curr |
Undocumented |
| Instance Variable | current |
Undocumented |
| Instance Variable | current |
Undocumented |
| Instance Variable | enter |
Undocumented |
| Instance Variable | separate |
Undocumented |
Add a new exit to a block.
| Parameters | |
| block | A block to which an exit must be added. |
| nextblock | The block to which control jumps from the new exit. |
| exitcase | An AST node representing the 'case' (or condition) leading to the exit from the block in the program. |
Add a statement to a block.
| Parameters | |
| block | A Block object to which a statement must be added. |
| statement | An AST node representing the statement that must be added to the current block. |
Build a CFG from an AST.
| Parameters | |
| name | The name of the CFG being built. |
| tree | The root of the AST from which the CFG must be built. |
| asynchr | Undocumented |
| entry | Value for the id of the entry block of the CFG. |
| flattened | if use k-v format for all CFGs while hiding its nested information. Key will be fully-qualified names. |
| async | Boolean indicating whether the CFG being built represents an asynchronous function or not. When the CFG of a Python program is being built, it is considered like a synchronous 'main' function. |
| Returns | |
| The CFG produced from the AST. | |
Build a CFG from some Python source file.
| Parameters | |
| name | The name of the CFG being built. |
| filepath | The path to the file containing the Python source code to build the CFG from. |
| flattened | if use k-v format for all CFGs while hiding its nested information. Key will be fully-qualified names. |
| Returns | |
| The CFG produced from the source file. | |
Build a CFG from some Python source code.
| Parameters | |
| name | The name of the CFG being built. |
| src | A string containing the source code to build the CFG from. |
| flattened | if use k-v format for all CFGs while hiding its nested information. Key will be fully-qualified names. |
| Returns | |
| The CFG produced from the source code. | |
Remove the useless (empty) blocks from a CFG.
| Parameters | |
| block | The block from which to start traversing the CFG to clean it. |
| visited | A list of blocks that already have been visited by clean_cfg (recursive function). |
Create a new sub-CFG for a class definition and add it to the function CFGs of the CFG being built.
| Parameters | |
| node | The AST node containing the function definition. |
| asynchr | Boolean indicating whether the function for which the CFG is being built is asynchronous or not. |
Create a new sub-CFG for a function definition and add it to the function CFGs of the CFG being built.
| Parameters | |
| node | The AST node containing the function definition. |
| asynchr | Undocumented |
| enclosing | Undocumented |
| async | Boolean indicating whether the function for which the CFG is being built is asynchronous or not. |