Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
Rubydex needs a control-flow graph before it can model instruction semantics, local-variable flow, reachability, and type inference.
This PR introduces the minimum CFG topology needed to start that work. The representation follows Sorbet’s non-SSA CFG structure but does not attempt full Sorbet compatibility yet.
What changed
Added a CFG model with:
BlockIdsBasicBlockJump,Branch, andExitterminatorsAdded a Prism visitor that builds CFGs for:
ifandunlesswhileanduntilreturnThe builder preserves Ruby evaluation order and creates explicit branch, merge, loop-header, loop-exit, and unreachable blocks. These structural blocks may be empty; a future CFG simplification pass can remove unnecessary forwarding blocks.
Instructions currently contain only source locations. Instruction semantics, locals, block arguments, and type information will be introduced separately.
Testing
Builder tests render the complete CFG into a canonical textual representation. Each test verifies:
Follow-up work
This PR intentionally does not include:
break,next,redo, orretryrescue, orensurecontrol flow