You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement module system and program flattening - #337
Implements the module system proposed in #318, enabling multi-file programs to be compiled into a single entry point for browser execution via Simplex.
Changes
Driver: Each imported file is now wrapped in a mod unit_N { ... } block during flattening, preserving namespace boundaries and visibility rules
Analyzer: added ModuleScope and scope-aware resolution to handle nested modules, visibility checks, and use rewriting across module boundaries
Next Steps After Merging:
We expect the modules feature to be marked as unstable in PR #329.
After merging this and the Unstable Features PR, we plan to bump the SimplicityHL version to 0.6.0-rc.1.
What changed?
Most of the driver logic has been moved into ast.rs and the module system has been introduced.
Previously, the driver handled file loading, alias resolution, visibility checks, and file ordering. Now it is responsible only for file loading, ordering, and flattening.
Flattening
The driver used to collect all Items into a flat Vec<Item> for AST::analyze to process. This has been restructured: each file is now wrapped in a mod unit_N { ... } block, converting a multi-file program into a single-file representation while preserving the same CMR (more details in 4359a84).
Scopes in ast.rs
A scope system has been introduced, modelled as a DAG data structure (see commit ab629c6 for details). Visibility and alias resolution are now handled natively at this stage inside Scope::resolve_use(...). Each mod block adds a new node to the DAG and creates a new scope.
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
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.
Overview
Implements the module system proposed in #318, enabling multi-file programs to be compiled into a single entry point for browser execution via Simplex.
Changes
mod unit_N { ... }block during flattening, preserving namespace boundaries and visibility rulesModuleScopeand scope-aware resolution to handle nested modules, visibility checks, anduserewriting across module boundariesSupported Syntax
Related PRs (in order of the merge): #338, #339, #343, #345