@@ -798,10 +798,11 @@ def traverse(self, cb: Callable[['HighLevelILInstruction', Any], Any], *args: An
798
798
799
799
:Example:
800
800
>>> def get_constant_less_than_value(inst: HighLevelILInstruction, value: int) -> int:
801
- >>> if isinstance(inst, Constant) and inst.constant < value:
802
- >>> return inst.constant
801
+ ... if isinstance(inst, Constant) and inst.constant < value:
802
+ ... return inst.constant
803
803
>>>
804
- >>> list(inst.traverse(get_constant_less_than_value, 10))
804
+ >>> for result in inst.traverse(get_constant_less_than_value, 10):
805
+ ... print(f"Found a constant {result} < 10 in {repr(inst)}")
805
806
"""
806
807
if (result := cb (self , * args , ** kwargs )) is not None :
807
808
yield result
@@ -2556,7 +2557,7 @@ def get_basic_block_at(self, index: int) -> Optional['basicblock.BasicBlock']:
2556
2557
2557
2558
def traverse (self , cb : Callable [['HighLevelILInstruction' , Any ], Any ], * args : Any , ** kwargs : Any ) -> Iterator [Any ]:
2558
2559
"""
2559
- ``traverse`` iterates through all the instructions in the HighLevelILInstruction and calls the callback function for
2560
+ ``traverse`` iterates through all the instructions in the HighLevelILFunction and calls the callback function for
2560
2561
each instruction and sub-instruction. See the `Developer Docs <https://docs.binary.ninja/dev/concepts.html#walking-ils>`_ for more examples.
2561
2562
2562
2563
:param Callable[[HighLevelILInstruction, Any], Any] cb: The callback function to call for each node in the HighLevelILInstruction
@@ -2572,7 +2573,8 @@ def traverse(self, cb: Callable[['HighLevelILInstruction', Any], Any], *args: An
2572
2573
... case Localcall(dest=Constant(constant=c), params=[_, _, p]) if c == target and not isinstance(p, Constant):
2573
2574
... return i
2574
2575
>>> target_address = bv.get_symbol_by_raw_name('_memcpy').address
2575
- >>> list(current_il_function.traverse(find_non_constant_memcpy, target_address))
2576
+ >>> for result in current_il_function.traverse(find_non_constant_memcpy, target_address):
2577
+ ... print(f"Found suspicious memcpy: {repr(i)}")
2576
2578
"""
2577
2579
root = self .root
2578
2580
if root is None :
0 commit comments