class procedure_locals_iterator¶
Iterator over the local variables ( symbol ) that are declared in a procedure.
Initialize with procedure.local_symbols().
Use as you would any other Python iterator. For example:
# set up procedure proc, then...
for e in proc.local_symbols():
print('symbol: ', e)
procedure_locals_iterator Members¶
| Constructors | none |
| Methods | __eq__(), __iter__(), __ne__(), __next__(), __repr__(), __str__(), at_end() |
procedure_locals_iterator Details¶
-
class
cs.procedure_locals_iterator¶ Iterator over the local variables (
symbol) that are declared in a procedure.-
__eq__(other)¶ Iterator equality.
Parameters: other ( procedure_locals_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') >>> sym_iterA = proc.local_symbols() >>> sym_iterB = proc.local_symbols() >>> sym_iterA == sym_iterB True >>> for s in sym_iterA: ... if s.get_kind() == symbol_kind.USER: ... break ... >>> sym_iterA == sym_iterB False
-
__iter__()¶ Get the iterator object.
Return type: procedure_locals_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 s in proc.local_symbols(): # iteration managed by procedure_locals_iterator.__iter__() ... # and procedure_locals_iterator.__next__() ... if s.get_kind() == symbol_kind.USER: ... print(s) ... s j p b a
-
__ne__(other)¶ Iterator inequality.
Parameters: other ( procedure_locals_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') >>> sym_iterA = proc.local_symbols() >>> sym_iterB = proc.local_symbols() >>> sym_iterA != sym_iterB False >>> for s in sym_iterA: ... if s.get_kind() == symbol_kind.USER: ... break ... >>> sym_iterA != sym_iterB True
-
__next__()¶ Iterator dereference operator.
Return type: Returns: The element at the current iterator position.
Raises: result.PDG_IS_UNDEFINEDif the iterator was initialized with respect to aprocedurewhose kind isprocedure_kind.UNDEFINED.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 s in proc.local_symbols(): # iteration managed by procedure_locals_iterator.__iter__() ... # and procedure_locals_iterator.__next__() ... if s.get_kind() == symbol_kind.USER: ... print(s) ... s j p b a
-
__repr__()¶ Get a representation of the iterator that includes information useful for debugging.
Return type: str Returns: The string representation. >>> 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') >>> sym_iterA = proc.local_symbols()
-
__str__()¶ Get a simple string representation of the iterator.
Return type: str Returns: The string representation. >>> proc = next(p for p in project.current().procedures() if p.name()=='foo') >>> locsyms = proc.local_symbols() >>> str(locsyms) '<cs.procedure_locals_iterator begin>'
-
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 project.current().procedures() if p.name()=='foo') >>> locsyms = proc.local_symbols() >>> locsyms.at_end() False
-