Skip to content

refactor self-host compiler modules#197

Merged
kacy merged 58 commits into
mainfrom
self-host-readability-refactor
May 19, 2026
Merged

refactor self-host compiler modules#197
kacy merged 58 commits into
mainfrom
self-host-readability-refactor

Conversation

@kacy
Copy link
Copy Markdown
Owner

@kacy kacy commented May 5, 2026

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.

@kacy kacy merged commit c50bb8d into main May 19, 2026
2 checks passed
@kacy kacy deleted the self-host-readability-refactor branch May 19, 2026 00:48
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.

1 participant