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



                   

                                       
                                                    
                         


                                                  










                                                 
                                                                       






                                                  
 

                                                      
                         


                                   
   
 
package dotty.tools
package dotc

import core._
import Contexts._, Periods._, Symbols._
import io.PlainFile
import util.{SourceFile, NoSource, Stats, SimpleMap}
import reporting.Reporter

class Run(comp: Compiler)(implicit ctx: Context) {

  var units: List[CompilationUnit] = _

  def getSource(fileName: String): SourceFile = {
    val f = new PlainFile(fileName)
    if (f.exists) new SourceFile(f)
    else {
      ctx.error(s"not found: $fileName")
      NoSource
    }
  }

  def compile(fileNames: List[String]): Unit = Stats.monitorHeartBeat {
    val sources = fileNames map getSource
    if (sources forall (_.exists)) {
      units = sources map (new CompilationUnit(_))
      for (phase <- ctx.allPhases)
        phase.runOn(units)
    }
  }

  /** Print summary; return # of errors encountered */
  def printSummary(): Reporter = {
    Constraint.printMax()
    val r = ctx.typerState.reporter
    r.printSummary
    r
  }
}