@@ -120,30 +120,6 @@ def getContainedGraphs(self):
120120 l .extend (b .getContainedGraphs ())
121121 return l
122122
123- _uncond_transfer = ('RETURN_VALUE' , 'RAISE_VARARGS' ,
124- 'JUMP_ABSOLUTE' , 'JUMP_FORWARD' )
125-
126- def pruneNext (self ):
127- """Remove bogus edge for unconditional transfers
128-
129- Each block has a next edge that accounts for implicit control
130- transfers, e.g. from a JUMP_IF_FALSE to the block that will be
131- executed if the test is true.
132-
133- These edges must remain for the current assembler code to
134- work. If they are removed, the dfs_postorder gets things in
135- weird orders. However, they shouldn't be there for other
136- purposes, e.g. conversion to SSA form. This method will
137- remove the next edge when it follows an unconditional control
138- transfer.
139- """
140- try :
141- op , arg = self .insts [- 1 ]
142- except (IndexError , TypeError ):
143- return
144- if op in self ._uncond_transfer :
145- self .next = []
146-
147123def dfs_postorder (b , seen ):
148124 """Depth-first search of tree rooted at b, return in postorder"""
149125 order = []
@@ -197,6 +173,30 @@ def addNext(self, block):
197173 self .next .append (block )
198174 assert len (self .next ) == 1 , map (str , self .next )
199175
176+ _uncond_transfer = ('RETURN_VALUE' , 'RAISE_VARARGS' ,
177+ 'JUMP_ABSOLUTE' , 'JUMP_FORWARD' )
178+
179+ def pruneNext (self ):
180+ """Remove bogus edge for unconditional transfers
181+
182+ Each block has a next edge that accounts for implicit control
183+ transfers, e.g. from a JUMP_IF_FALSE to the block that will be
184+ executed if the test is true.
185+
186+ These edges must remain for the current assembler code to
187+ work. If they are removed, the dfs_postorder gets things in
188+ weird orders. However, they shouldn't be there for other
189+ purposes, e.g. conversion to SSA form. This method will
190+ remove the next edge when it follows an unconditional control
191+ transfer.
192+ """
193+ try :
194+ op , arg = self .insts [- 1 ]
195+ except (IndexError , ValueError ):
196+ return
197+ if op in self ._uncond_transfer :
198+ self .next = []
199+
200200 def get_children (self ):
201201 if self .next and self .next [0 ] in self .outEdges :
202202 self .outEdges .remove (self .next [0 ])
0 commit comments