class procedure_call_sites_iterator¶
Iterator over the call sites ( point of kind point_kind.CALL_SITE) in a procedure.
Initialize with procedure.call_sites().
Use as you would any other Python iterator. For example:
# set up procedure proc, then...
for e in proc.call_sites():
print('point: ', e)
procedure_call_sites_iterator Members¶
| Constructors | none |
| Methods | __eq__(), __iter__(), __ne__(), __next__(), __repr__(), __str__(), at_end() |
procedure_call_sites_iterator Details¶
-
class
cs.procedure_call_sites_iterator¶ Iterator over the call sites (
pointof kindpoint_kind.CALL_SITE) in a procedure.-
__eq__(other)¶ Iterator equality.
Parameters: other ( procedure_call_sites_iterator) –Return type: bool Returns: Trueif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare not iterating over the same collection.>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> proc = next(p for p in cu.procedures() if p.name()=='foo') >>> cs_iterA = proc.call_sites() >>> cs_iterB = proc.call_sites() >>> cs_iterA == cs_iterB True >>> for pt in cs_iterA: ... if pt.callee().name() == 'mymalloc': ... break ... >>> cs_iterA == cs_iterB False
-
__iter__()¶ Get the iterator object.
Return type: procedure_call_sites_iteratorReturns: self.>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> proc = next(p for p in cu.procedures() if p.name()=='foo') >>> for pt in proc.call_sites(): # iteration is managed by procedure_call_sites_iterator.__iter__() ... # and procedure_call_sites_iterator.__next__() ... print(pt.callee()) ... bar bar mymalloc bar
-
__ne__(other)¶ Iterator inequality.
Parameters: other ( procedure_call_sites_iterator) – The iterator to compare against.Return type: bool Returns: Falseif and only ifselfandotherare at the same position. Behavior is undefined ifselfandotherare not iterating over the same collection.>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> proc = next(p for p in cu.procedures() if p.name()=='foo') >>> cs_iterA = proc.call_sites() >>> cs_iterB = proc.call_sites() >>> cs_iterA != cs_iterB False >>> for pt in cs_iterA: ... if pt.callee().name() == 'mymalloc': ... break ... >>> cs_iterA != cs_iterB True
-
__next__()¶ Iterator dereference operator.
Return type: pointReturns: The element at the current iterator position. Raises: StopIteration- Side effects: Modifies
self.
The typical use is implicit:
>>> for item in myiter: ... (do something to item)
>>> cu = next(c for c in project.current().compunits() if c.name().endswith('apitest.cpp')) >>> proc = next(p for p in cu.procedures() if p.name()=='foo') >>> for pt in proc.call_sites(): # iteration is managed by procedure_call_sites_iterator.__iter__() ... # and procedure_call_sites_iterator.__next__() ... print(pt.callee()) ... bar bar mymalloc
- Side effects: Modifies
-
__repr__()¶ Get a representation of the iterator that includes information useful for debugging.
Return type: str Returns: The string representation. >>> proc = next(p for p in cu.procedures() if p.name()=='foo') >>> csites = proc.call_sites() >>> repr(csites)
-
__str__()¶ Get a simple string representation of the iterator.
Return type: str Returns: The string representation. >>> proc = next(p for p in cu.procedures() if p.name()=='foo') >>> csites = proc.call_sites() >>> str(csites)
-
at_end()¶ Check: is the iterator at the end of the structure?
Return type: bool Returns: Trueif the iterator is at the end of the structure (there are no more elements to iterate over),Falseotherwise.>>> proc = next(p for p in cu.procedures() if p.name()=='foo') >>> csites = proc.call_sites() >>> next(csites) <cs.point [call-site] bar(int, void *, int)> >>> next(csites) <cs.point [call-site] bar(int, void *, int)> >>> next(csites) <cs.point [call-site] mymalloc(int)> >>> next(csites) <cs.point [call-site] bar(int, void *, int)> >>> csites.at_end() True
-