Skip to content

feat: control-flow graphs - #12

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

SizzleUnrlsd merged 3 commits into
mainfrom
feat/cfg

Conversation

@SizzleUnrlsd

Copy link
Copy Markdown
Contributor

Summary

Opens Phase 3 of docs/architecture.md with §5 CFG.

  • Acceptance tests first (test: define control-flow graph behavior), implementation follows in this PR.
  • PyHIR gains If, While, For, Break, Continue and Raise; scope and import analyses walk the new bodies.
  • coretrace_python.cfg: per-function graphs of basic blocks holding straight-line PyHIR statements and one explicit terminator: Branch, Jump, Return, Raise, or ForEach to keep Python's iteration protocol explicit instead of a generic switch. Predecessors, successors, reachability, back edges and integrity checks. Deterministic block order starting at entry.
  • CFGAnalysis is a function-level analysis (cfg.function) computed on demand through the Analysis Manager.
  • break / continue outside a loop are source-located CFGErrors.

Not in this PR: exception edges (waiting on Try in PyHIR), with, and PyIR lowering over the CFG, which is the next Phase 3 item together with Branch / Jump / Phi instructions.

Closes #11

🤖 Generated with Claude Code

SizzleUnrlsd and others added 2 commits September 3, 2026 06:38
Acceptance tests for per-function CFGs over PyHIR: explicit Branch, Jump,
Return, Raise and ForEach terminators, predecessors and successors in block
order, reachability, back edges, integrity checks, loop control errors, and the
CFG as a function-level analysis. Adds the PyHIR control-flow node tests.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
PyHIR represents if, while, for, break, continue and raise; scope and import
analyses walk the new bodies. The cfg package builds per-function graphs of
basic blocks with explicit Branch, Jump, Return, Raise and ForEach terminators,
exposes predecessors, successors, reachability and back edges, validates its
integrity, and is registered as the cfg.function analysis.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
@SizzleUnrlsd SizzleUnrlsd mentioned this pull request Sep 3, 2026
5 tasks done
@SizzleUnrlsd SizzleUnrlsd self-assigned this Sep 3, 2026
@SizzleUnrlsd
SizzleUnrlsd merged commit cebb877 into main Sep 3, 2026
6 checks passed
@SizzleUnrlsd
SizzleUnrlsd deleted the feat/cfg branch September 3, 2026 04:44
SizzleUnrlsd added a commit that referenced this pull request Sep 3, 2026
@SizzleUnrlsd SizzleUnrlsd mentioned this pull request Sep 3, 2026
8 tasks done
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 explicit control-flow graphs

1 participant