dewolf icon indicating copy to clipboard operation
dewolf copied to clipboard

Consolidate subexpression iteration

Open 0x6e62 opened this issue 3 years ago • 0 comments

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 worklistor todo.

0x6e62 avatar Jan 12 '22 12:01 0x6e62