class CFGBuilder(ast.NodeVisitor): (source)
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 | new |
Create a new block with a new id. |
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 |
Instance Variable | after |
Undocumented |
Instance Variable | cfg |
Undocumented |
Instance Variable | curr |
Undocumented |
Instance Variable | current |
Undocumented |
Instance Variable | current |
Undocumented |
Add a new exit to a block. Args: 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. Args: 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. Args: name: The name of the CFG being built. tree: The root of the AST from which the CFG must be built. 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. entry_id: Value for the id of the entry block of the CFG. Returns: The CFG produced from the AST.
Build a CFG from some Python source file. Args: name: The name of the CFG being built. filepath: The path to the file containing the Python source code to build the CFG from. Returns: The CFG produced from the source file.
Build a CFG from some Python source code. Args: name: The name of the CFG being built. src: A string containing the source code to build the CFG from. Returns: The CFG produced from the source code.
Remove the useless (empty) blocks from a CFG. Args: 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 function definition and add it to the function CFGs of the CFG being built. Args: node: The AST node containing the function definition. async: Boolean indicating whether the function for which the CFG is being built is asynchronous or not.