refactor self-host compiler modules#197
Merged
Merged
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.
summary
This refactors the production self-host compiler modules around clearer ownership boundaries without changing language behavior.
The CLI now delegates package manifest, dependency, and scaffold logic to package_cli.pith. Checker module-name helpers, generic type interning, builtin registration, diagnostic reporting, interface registry state, and method registry state moved into focused checker modules. IR runtime metadata, return classification, method lowering names, symbol naming helpers, low-level builder/string-table state, shared AST helpers, cached AST traversals, checker-backed type helpers, higher-order call type helpers, declared call return helpers, name type lookup helpers, type normalization helpers, decode call matchers, decode call resolvers, decode specialization checks, decode helper-name classification, decode field classifiers, nested decode emission helpers, static callee resolution, generic metadata helpers, generic naming helpers, generic type substitution helpers, struct layout helpers, optional field and comparison helpers, call emission helpers, control metadata helpers, bind parsing helpers, collection literal helpers, empty collection initialization helpers, index and loop collection helpers, for-iterator helpers, field access helpers, operator emission helpers, compound assignment operator helpers, lambda capture analysis, Result ABI helpers, Result field helpers, Result ok field helpers, literal lowering, map-copy helpers, generic utility helpers, list lowering helpers, dotted-path traversal helpers, generic inference helpers, result-flow helpers, and struct-result packing helpers moved out of the main emitter.
The public IR emitter entrypoint is now a small facade under 3k lines, with the implementation staged in ir_emitter_core.pith for continued decomposition.
tests
./self-host/pith_main check self-host/pith_main.pith
./self-host/pith_main check self-host/package_cli.pith
./self-host/pith_main check self-host/checker_modules.pith
./self-host/pith_main check self-host/checker_type_intern.pith
./self-host/pith_main check self-host/checker_builtins.pith
./self-host/pith_main check self-host/checker_diagnostics.pith
./self-host/pith_main check self-host/checker_interfaces.pith
./self-host/pith_main check self-host/checker_methods.pith
./self-host/pith_main check self-host/checker.pith
./self-host/pith_main check self-host/ir_metadata.pith
./self-host/pith_main check self-host/ir_names.pith
./self-host/pith_main check self-host/ir_builder.pith
./self-host/pith_main check self-host/ir_ast_helpers.pith
./self-host/pith_main check self-host/ir_capture.pith
./self-host/pith_main check self-host/ir_result_abi.pith
./self-host/pith_main check self-host/ir_literals.pith
./self-host/pith_main check self-host/ir_utils.pith
./self-host/pith_main check self-host/ir_tree_cache.pith
./self-host/pith_main check self-host/ir_type_helpers.pith
./self-host/pith_main check self-host/ir_decode_calls.pith
./self-host/pith_main check self-host/ir_callees.pith
./self-host/pith_main check self-host/ir_generics.pith
./self-host/pith_main check self-host/ir_struct_layouts.pith
./self-host/pith_main check self-host/ir_emitter.pith
make self-host
make self-host-ir-driver
make ir-contract-regressions-only
make test-fast-self
make bootstrap-verify
Recent slices reran:
./self-host/pith_main check self-host/ir_decode_calls.pith
./self-host/pith_main check self-host/ir_callees.pith
./self-host/pith_main check self-host/ir_generics.pith
./self-host/pith_main check self-host/ir_struct_layouts.pith
./self-host/pith_main check self-host/ir_result_abi.pith
./self-host/pith_main check self-host/ir_optionals.pith
./self-host/pith_main check self-host/ir_control_helpers.pith
./self-host/pith_main check self-host/ir_collection_helpers.pith
./self-host/pith_main check self-host/ir_field_helpers.pith
./self-host/pith_main check self-host/ir_operator_helpers.pith
./self-host/pith_main check self-host/ir_call_helpers.pith
./self-host/pith_main check self-host/ir_type_helpers.pith
./self-host/pith_main check self-host/ir_emitter.pith
./self-host/pith_main check self-host/ir_emitter_core.pith
./self-host/pith_main check self-host/ir_list_helpers.pith
./self-host/pith_main check self-host/ir_path_helpers.pith
./self-host/pith_main check self-host/ir_generic_infer.pith
./self-host/pith_main check self-host/ir_result_flow.pith
./self-host/pith_main check self-host/ir_struct_result_helpers.pith
./self-host/pith_main fmt self-host/ir_emitter.pith
./self-host/pith_main fmt self-host/ir_list_helpers.pith
./self-host/pith_main fmt self-host/ir_path_helpers.pith
./self-host/pith_main fmt self-host/ir_generic_infer.pith
./self-host/pith_main fmt self-host/ir_result_flow.pith
./self-host/pith_main fmt self-host/ir_struct_result_helpers.pith
./self-host/pith_main run examples/hello.pith
make ir-contract-regressions-only
make self-host
design notes
This keeps the refactor behavior-preserving: extracted modules own the same helper logic they previously shared with the large source files, while callers keep the same compiler pipeline and IR output contracts.