Pipeline
Current front-end compiler pipeline looks like the following:
Input is an input, Bold is a step, Italic is an artefact.
-> is used by, => produces
-
Source code -> Lexing & Parsing => AST
Understand the form of the user source code.
-
AST -> Item Collection, Item Resolution => NameEnvironment, ResolutionMap
Go through each item and associate names of items to
ast::NodeIds.It makes sense to collect before AST Lowering because
- this information can be used during the lowering for path resolution
- it is used to provide diagnostics to user code, AST is closer to what the user wrote
-
AST, ResolutionMap -> AST Lowering => HIR
We lower the AST to a flat structure (soon™) that is the HIR.
HIR is much more usable in the context of a compiler.
-
HIR -> Type Collection => TypeEnvironment
Go through each item and compute their
ty::EarlyItemTy.Once, the collection phase is done, these are immediately resolved to
ty::LateTys. -
HIR, NameEnvironment, TypeEnvironment -> Inference (per function) => InferResult
-
HIR, InferResult -> Code Generation => Object