aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc/typer/FrontEnd.scala
blob: 3908205e48033384a999b41f948b9dc2d5df9208 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package dotty.tools.dotc
package typer

import core._
import Phases._
import Contexts._
import parsing.Parsers.Parser

class FrontEnd extends Phase {

  def name = "frontend"

  def parse(implicit ctx: Context) = {
    val unit = ctx.compilationUnit
    unit.untpdTree = new Parser(unit.source).parse()
    println("parsed:\n"+unit.untpdTree.show)
  }

  def enterSyms(implicit ctx: Context) = {
    val unit = ctx.compilationUnit
    ctx.typer.index(unit.untpdTree)
    println("entered:\n"+unit.source)
  }

  def typeCheck(implicit ctx: Context) = {
    val unit = ctx.compilationUnit
    unit.tpdTree = ctx.typer.typedExpr(unit.untpdTree)
    println("typed:\n"+unit.source)
  }

  override def runOn(units: List[CompilationUnit])(implicit ctx: Context): Unit = {
    val unitContexts = units map (unit => ctx.fresh.withCompilationUnit(unit))
    unitContexts foreach (parse(_))
    unitContexts foreach (enterSyms(_))
    unitContexts foreach (typeCheck(_))
  }

  override def run(implicit ctx: Context): Unit = {
    parse
    enterSyms
    typeCheck
  }
}