aboutsummaryrefslogblamecommitdiff
path: root/src/dotty/tools/dotc/Compiler.scala
blob: d285fef5a26b5edaa3177accb569daee415620d1 (plain) (tree)
1
2
3
4
5
6
7
8
9




                   

                
                                                
                                


                
                                 
 


                                                                               

                                                     
                         
                                                      
                               

                                
                          
                                                                                        


                                                               



                                          
 
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)

  def rootImports(implicit ctx: Context) =
    defn.JavaLangPackageVal :: defn.ScalaPackageVal :: defn.PredefModule :: Nil

  def rootContext(implicit ctx: Context): Context = {
    ctx.usePhases(phases)
    val start = ctx.fresh
      .withPeriod(Period(ctx.runId + 1, FirstPhaseId))
      .withRunInfo(new RunInfo)
      .withOwner(defn.RootClass)
      .withTyper(new Typer)
      .withMode(Mode.None)
      .withTyperState(new MutableTyperState(ctx.typerState, new ConsoleReporter()(ctx)))
    def addImport(ctx: Context, sym: Symbol) =
      ctx.fresh.withImportInfo(ImportInfo.rootImport(sym)(ctx))
    (start /: rootImports)(addImport)
  }

  def newRun(implicit ctx: Context): Run =
    new Run(this)(rootContext)
}