Overview

This page contains a high level over of how the Volta compiler works. Most of this documentation is directly generated from the Interfaces module, if you prefer to read code directly open it up in your favorite editor.

Parsing

Full doc

The beginning of the compilation pipeline, this lexes the source code, parses the resulting tokens and does some very lightweight transformation of the internal AST into Volt IR.

Volt Semantics

Full doc

Backend

Full doc

Passes

Language Passes

Full doc

The language passes are divided into three phases:

  1. Post Parse
  2. Expression Type Verification
  3. Miscellaneous

Phase 1, PostParse, works like this:

  1. All of the version statements are resolved for the entire module.
  2. Then, for each Module, Class, Struct, and Enum's TopLevelBlock:
    1. Apply all attributes in the current block or its direct children.
    2. Add symbols to scope in the current block or its direct children.
    3. Then do those steps for for each child TopLevelBlock that brings in a new scope (Classes, Enums, Structs).
  3. Resolve the imports.
  4. Go from top to bottom resolving static ifs (applying step 2 to the selected TopLevelBlock).

Phase 2, Semantic, is a complex step that resolves and typechecks any expressions. This pass is only run for modules that are passed directly to the LanguagePass.transform function, or functions that are invoked by static ifs.

Phase 3, Lowering, are various lowering and transformation passes, some can invoke Phase 1 and 2 on newly generated code.

Post Parsing Passes

Full doc

These are the passes that the LanguagePass runs after parsing is done.

Semantic Passes

Full doc

Semantic passes transform the code and checks for errors.

Lowering Passes

Full doc

Lowers complicated constructs into multiple simple constructs. foreach becomes a for loop, assert becomes an if and a throw, etc.