Dotty tutorial

                                    Guillaume Martres - EPFL


Dotty internals: the frontend

Generating trees and symbols and typing them

The compiler pipeline

Fundamental data structures

  • The compiler represents code using trees
  • To ensure type-safety, we attach types to trees
  • A type might refer to an identifier defined in a tree or in the classpath, to each valid identifier corresponds a symbol looked up in the symbol table for the current scope
  • Each phase of the compiler pipeline simplifies the trees and types until they can be easily expressed using Java bytecode
  • All of these data structures are immutable (or look immutable but use caching under the hood)

Parser: From source file to Untyped Tree
Apply(Select(Ident("obj"), "fun"), Literal(5))

Dotty internals: the middle-end

Simplifing types and trees with successive transformations

Traditional phase design

1 phase = 1 full traversal

Mini-phase design

N fused mini-phases = 1 full traversal

Demo time!