Decompose codegen.py into codegen/ mixin package#158
Merged
Conversation
Split the 2,140-line codegen.py monolith into 11 focused modules following the mixin pattern established by checker/ and wasm/: codegen/api.py - Public API, compile(), execute() codegen/core.py - Composed CodeGenerator class codegen/modules.py - Cross-module call detection (Pass 0) codegen/registration.py - Function/ADT registration (Pass 1) codegen/monomorphize.py - Generic instantiation (Pass 1.5) codegen/functions.py - Function body compilation (Pass 2) codegen/closures.py - Closure lifting codegen/contracts.py - Runtime contract insertion codegen/assembly.py - WAT module assembly codegen/compilability.py - Compilability checks Also adds 5 coverage gap tests (E600/E601/E605/E606, unknown module calls) and splits the 4,834-line test_codegen.py into 6 focused files: test_codegen_contracts.py, test_codegen_monomorphize.py, test_codegen_closures.py, test_codegen_modules.py, and test_codegen_coverage.py. All 1,076 tests pass, mypy clean, all 14 examples validate. Closes #155 Co-Authored-By: Claude <noreply@anthropic.invalid>
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.
Summary
codegen.pymonolith into 11 focused modules using the mixin pattern established bychecker/andwasm/test_codegen.pyinto 6 focused test files mirroring the new module structurevera/README.mdmodule map,CLAUDE.md,AGENTS.md, projectREADME.mdNew codegen modules
codegen/api.pycompile(),execute()codegen/core.pyCodeGeneratorclass, shared helperscodegen/modules.pycodegen/registration.pycodegen/monomorphize.pycodegen/functions.pycodegen/closures.pycodegen/contracts.pycodegen/assembly.pycodegen/compilability.pyNew test files
test_codegen_contracts.pytest_codegen_monomorphize.pytest_codegen_closures.pytest_codegen_modules.pytest_codegen_coverage.pyTest plan
Closes #155