llvm.org GIT mirror llvm / 19b8509
Python compat - iterator protocol In Python2 next() is used wile it's __next__ in Python3. Differential Revision: https://reviews.llvm.org/D56250 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350326 91177308-0d34-0410-b5e6-96231b3b80d8 Serge Guelton 8 months ago
2 changed file(s) with 29 addition(s) and 17 deletion(s). Raw diff Collapse all Expand all
1717 from ctypes import byref
1818 from ctypes import c_char_p
1919 from ctypes import c_uint
20
21 import sys
2022
2123 __all__ = [
2224 "lib",
235237 def __iter__(self):
236238 return self
237239
238 def next(self):
240 def __next__(self):
239241 if not isinstance(self.function, Function):
240242 raise StopIteration("")
241243 result = self.function
244246 else:
245247 self.function = self.function.next
246248 return result
247
249
250 if sys.version_info.major == 2:
251 next = __next__
252
248253 def __iter__(self):
249254 return Module.__function_iterator(self)
250255
303308 def __iter__(self):
304309 return self
305310
306 def next(self):
311 def __next__(self):
307312 if not isinstance(self.bb, BasicBlock):
308313 raise StopIteration("")
309314 result = self.bb
312317 else:
313318 self.bb = self.bb.next
314319 return result
320
321 if sys.version_info.major == 2:
322 next = __next__
315323
316324 def __iter__(self):
317325 return Function.__bb_iterator(self)
380388 def __iter__(self):
381389 return self
382390
383 def next(self):
391 def __next__(self):
384392 if not isinstance(self.inst, Instruction):
385393 raise StopIteration("")
386394 result = self.inst
389397 else:
390398 self.inst = self.inst.next
391399 return result
392
400
401 if sys.version_info.major == 2:
402 next = __next__
403
393404 def __iter__(self):
394405 return BasicBlock.__inst_iterator(self)
395406
0 from __future__ import print_function
1 import sys
12
23 import gdb.printing
34
56 def __iter__(self):
67 return self
78
8 # Python 2 compatibility
9 def next(self):
10 return self.__next__()
9 if sys.version_info.major == 2:
10 def next(self):
11 return self.__next__()
1112
1213 def children(self):
1314 return self
6970 def __iter__(self):
7071 return self
7172
72 def next(self):
73 def __next__(self):
7374 if self.cur == self.end:
7475 raise StopIteration
7576 count = self.count
7879 self.cur = self.cur + 1
7980 return '[%d]' % count, cur.dereference()
8081
81 __next__ = next
82
83 def __init__(self, val):
84 self.val = val
85
86 __next__ = next
82 if sys.version_info.major == 2:
83 next = __next__
84
85 def __init__(self, val):
86 self.val = val
8787
8888 def children(self):
8989 data = self.val['Data']
168168 while self.cur != self.end and (is_equal(self.cur.dereference()['first'], empty) or is_equal(self.cur.dereference()['first'], tombstone)):
169169 self.cur = self.cur + 1
170170
171 def next(self):
171 def __next__(self):
172172 if self.cur == self.end:
173173 raise StopIteration
174174 cur = self.cur
181181 self.first = False
182182 return 'x', v
183183
184 __next__ = next
184 if sys.version_info.major == 2:
185 next = __next__
185186
186187 def __init__(self, val):
187188 self.val = val