|
@@ -10176,21 +10176,16 @@ function with the transpose of the control-flow graph.
|
|
|
{\if\edition\pythonEd
|
|
|
\begin{lstlisting}
|
|
|
def analyze_dataflow(G, transfer, bottom, join):
|
|
|
- trans_G = transpose(G)
|
|
|
- mapping = {}
|
|
|
- for v in G.vertices():
|
|
|
- mapping[v] = bottom
|
|
|
- worklist = deque()
|
|
|
- for v in G.vertices():
|
|
|
- worklist.append(v)
|
|
|
+ trans_G = transpose(G)
|
|
|
+ mapping = dict((v, bottom) for v in G.vertices())
|
|
|
+ worklist = deque(G.vertices)
|
|
|
while worklist:
|
|
|
node = worklist.pop()
|
|
|
input = reduce(join, [mapping[v] for v in trans_G.adjacent(node)], bottom)
|
|
|
output = transfer(node, input)
|
|
|
if output != mapping[node]:
|
|
|
mapping[node] = output
|
|
|
- for v in G.adjacent(node):
|
|
|
- worklist.append(v)
|
|
|
+ worklist.extend(G.adjacent(node))
|
|
|
\end{lstlisting}
|
|
|
\fi}
|
|
|
\caption{Generic work list algorithm for dataflow analysis}
|