blob: 1172143cde375ebddc1373587c6a1b4a40ea72b8 (
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
|
package dotty.tools
package dotc
import core._
import Contexts._
import Periods._
import Symbols._
import typer.{FrontEnd, Typer, Mode, ImportInfo}
import reporting.ConsoleReporter
class Compiler {
def phases = List(new FrontEnd)
var runId = 1
def nextRunId = { runId += 1; runId }
def rootContext(implicit ctx: Context): Context = {
ctx.definitions.init()
ctx.usePhases(phases)
val start = ctx.fresh
.withPeriod(Period(nextRunId, FirstPhaseId))
.withOwner(defn.RootClass)
.withTyper(new Typer)
.withNewMode(Mode.ImplicitsEnabled)
.withTyperState(new MutableTyperState(ctx.typerState, new ConsoleReporter()(ctx), isCommittable = true))
def addImport(ctx: Context, sym: Symbol) =
ctx.fresh.withImportInfo(ImportInfo.rootImport(sym)(ctx))
(start.withRunInfo(new RunInfo(start)) /: defn.RootImports)(addImport)
}
def newRun(implicit ctx: Context): Run =
new Run(this)(rootContext)
}
|