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 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:True if and only if self and other are at the same position. Behavior is undefined if self and other are 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_iterator
Returns: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:False if and only if self and other are at the same position. Behavior is undefined if self and other are 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:

symbol

Returns:

The element at the current iterator position.

Raises:
  • 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:True if the iterator is at the end of the structure (there are no more elements to iterate over), False otherwise.
>>> proc = next(p for p in project.current().procedures() if p.name()=='foo')
>>> locsyms = proc.local_symbols()
>>> locsyms.at_end()
False