Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

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

  1. Source code -> Lexing & Parsing => AST

    Understand the form of the user source code.

  2. AST -> Item Collection, Item Resolution => NameEnvironment, ResolutionMap

    We first construct the reachable environment and generate DefIds for each item. Then we go through all the Paths and attach meaning to them, i.e. the item or local binding they refer to.

    It makes sense to collect on the AST as it is used to provide diagnostics to user code and AST is closer to what the user wrote.

  3. AST, ResolutionMap -> AST Lowering => HIR

    We lower the AST to a flat structure that is the HIR. HIR doesn’t care about structure and is much more convenient further down the (pipe)line.

  4. 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.

  5. HIR, NameEnvironment, TypeEnvironment -> Inference (per function) => InferResult

  6. HIR, InferResult -> Code Generation => Object