dewolf
dewolf copied to clipboard
Consolidate subexpression iteration
Proposal
There are about 8 dedicated functions throughout the current codebase dedicated to iterate all subexpressions of an expression.
I propose to remove this function in favor of the newly implemented Expression.subexpressions()
iterator.
def subexpressions(self) -> Iterator[DataflowObject]:
"""Yield all subexpressions in a depth-first manner."""
worklist: List[DataflowObject] = [self]
while worklist and (head := worklist.pop()):
yield head
worklist.extend(head)
Approach
Functions like these can be found by searching for worklist
or todo
.