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_class |
Create a new sub-CFG for a class definition and add it to the class CFGs of the CFG being built. |
Method | new |
Create a new function 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 | new |
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 |
Instance Variable | cfg |
Undocumented |
Instance Variable | current |
Undocumented |
Instance Variable | current |
Undocumented |
Instance Variable | is |
Undocumented |
Property | loop |
Undocumented |
Property | try |
Undocumented |
Instance Variable | _callbuf |
Undocumented |
Instance Variable | _treebuf |
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.
Parameters | |
block:Block | Undocumented |
nextblock:Block | Undocumented |
exitcase:Union[ | Undocumented |
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.
Parameters | |
block:Block | Undocumented |
statement:Union[ | Undocumented |
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.
Parameters | |
name:str | Undocumented |
tree:Module | Undocumented |
asynchr:bool | Undocumented |
entryint | Undocumented |
Returns | |
CFG | Undocumented |
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).
Parameters | |
block:Block | Undocumented |
visited:Set[ | Undocumented |
Create a new block with a new id. Returns: A Block object with a new unique id.
Returns | |
Block | Undocumented |
Create a new sub-CFG for a class definition and add it to the class CFGs of the CFG being built. Args: node: The AST node containing the class definition. async: Boolean indicating whether the class for which the CFG is being built is asynchronous or not.
Parameters | |
node:ClassDef | Undocumented |
asynchr:bool | Undocumented |
Create a new function block with a new id. Returns: A FuncBlock object with a new unique id.
Returns | |
FuncBlock | Undocumented |
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.
Parameters | |
node:FunctionDef | Undocumented |
asynchr:bool | Undocumented |
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. Returns: The block to be used as new loop guard.
Returns | |
Block | Undocumented |