Expand description
Module resolution, dependency graph construction, and multi-module compilation for the Maat compiler.
This crate builds a directed acyclic graph (DAG) of module dependencies before compilation begins. Each reachable source file is parsed independently, cycle detection is performed via DFS with gray/black coloring, and the final graph provides a topological ordering suitable for compilation.
§File Resolution
Resolution follows Rust’s module conventions:
- Root entry files and
mod.maatfiles resolve submodules in their own directory:mod foo;indir/mod.maatresolves todir/foo.maatordir/foo/mod.maat. - All other files resolve submodules in a subdirectory named after
the file stem:
mod bar;indir/foo.maatresolves todir/foo/bar.maatordir/foo/bar/mod.maat.
If both foo.maat and foo/mod.maat exist, the resolution is ambiguous
and an error is produced. If neither exists, a resolution error is
produced.
Structs§
- Module
Exports - The set of publicly visible items exported by a module.
- Module
Graph - A directed acyclic graph of module dependencies.
- Module
Id - A unique identifier for a module within the dependency graph.
- Module
Node - A single node in the module dependency graph.
- Resolved
Import - A resolved import ready to be injected into a module’s type environment.
Enums§
- Import
Kind - The kind of item being imported.
Functions§
- check_
and_ compile - Type-checks, compiles, and links all modules in the given graph.
- check_
exports - Returns the per-module public exports extracted during type checking.
- resolve_
module_ graph - Resolves the complete module dependency graph starting from
entry.
Type Aliases§
- Module
Result - A specialized
Resulttype for module resolution operations.