class Analysis(object): (source)
Known subclasses: python_graphs.data_flow.LastAccessAnalysis
, python_graphs.data_flow.LivenessAnalysis
Base class for a data flow analysis.
Method | __init__ |
Undocumented |
Method | aggregate |
Computes the before value for a node from the previous after values. |
Method | compute |
Computes the after value for a node from the node and the before value. |
Method | visit |
Visit the nodes of the control flow graph, performing the analysis. |
Instance Variable | after |
Either the in_label or out_label depending on the direction of the analysis. Marks the after_value on a node during an analysis. |
Instance Variable | before |
Either the in_label or out_label depending on the direction of the analysis. Marks the before_value on a node during an analysis. |
Instance Variable | forward |
(bool) True for forward analyses, False for backward analyses. |
Instance Variable | in |
The name of the analysis, suffixed with _in. |
Instance Variable | label |
The name of the analysis. |
Instance Variable | out |
The name of the analysis, suffixed with _out. |
Computes the before value for a node from the previous after values.
This is the 'meet' or 'join' function of the analysis. TODO(dbieber): Update terminology to match standard textbook notation.
Parameters | |
previous | The after values of all before nodes. |
Returns | |
The before value for the current node. |
Computes the after value for a node from the node and the before value.
This is the 'transfer' function of the analysis. TODO(dbieber): Update terminology to match standard textbook notation.
Parameters | |
node | The node or block for which to compute the after value. |
before | The before value of the node. |
Returns | |
The computed after value for the node. |
Visit the nodes of the control flow graph, performing the analysis.
- Terminology:
in_value: The value of the analysis at the start of a node. out_value: The value of the analysis at the end of a node. before_value: in_value in a forward analysis; out_value in a backward
analysis.
- after_value: out_value in a forward analysis; in_value in a backward
- analysis.
Parameters | |
node | A graph element that supports the .next / .prev API, such as a ControlFlowNode from a ControlFlowGraph or a BasicBlock from a ControlFlowGraph. |
Either the in_label or out_label depending on the direction of the analysis. Marks the after_value on a node during an analysis.