Skip to content

feat: data-flow framework and constant propagation - #18

Merged
SizzleUnrlsd merged 2 commits into
mainfrom
feat/dataflow
Sep 3, 2026
Merged

SizzleUnrlsd merged 2 commits into
mainfrom
feat/dataflow

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

Summary

Phase 4 of docs/architecture.md: the generic data-flow framework and abstract values (§18, §37 dataflow/ and abstract/, §38 Phase 4).

  • Acceptance tests first (test: define data-flow framework and constant propagation behavior), implementation follows.
  • dataflow/lattice.py: BOTTOM, TOP, the Lattice protocol and a FlatLattice whose elements are compared by type as well as value, so 1 and True stay distinct constants.
  • dataflow/solver.py: a worklist solver over a CFG, forward or backward. A problem receives the states arriving on the executable incoming edges of a block and returns the states it sends along outgoing edges; edges it does not return are pruned. Blocks are revisited only when an incoming edge changes; unreachable code is never visited.
  • abstract/values.py: AbstractValue with a flat constant, a set of possible types and the truthiness that follows. Taints, ranges, string constraints and nullability will extend this record with their analyses.
  • abstract/constants.py: ConstantPropagation (abstract.constants), the reference client validating the framework and the Analysis Manager end to end. It folds pure operations on safe constants (arithmetic, comparisons, unary operators), refuses unbounded ones (**, shifts, str * int), joins at phis over executable edges only, prunes the branches a constant condition never takes, and keeps types when constants are lost, so a loop counter stays an int.
  • Layer map: abstract now sits above dataflow.

Not in this PR: ranges, string constraints and nullability (Phase 8), and CLI reporting of facts.

Closes #17

@SizzleUnrlsd SizzleUnrlsd self-assigned this Sep 3, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit c452bb7 into main Sep 3, 2026
6 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the feat/dataflow branch September 3, 2026 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build generic data-flow and abstract values

1 participant