0

私はnsc(新しいscalaコンパイラ)のコードを調べようとしていました. について少し混乱していMain.scalaます。次のように実装されます。

/* NSC -- new Scala compiler
 * Copyright 2005-2013 LAMP/EPFL
 * @author  Martin Odersky
 */
package scala.tools
package nsc

import scala.language.postfixOps

/** The main class for NSC, a compiler for the programming
 *  language Scala.
 */
class MainClass extends Driver with EvalLoop {
  def resident(compiler: Global): Unit = loop { line =>
    val command = new CompilerCommand(line split "\\s+" toList, new Settings(scalacError))
    compiler.reporter.reset()
    new compiler.Run() compile command.files
  }

  override def newCompiler(): Global = Global(settings, reporter)
  override def doCompile(compiler: Global) {
    if (settings.resident) resident(compiler)
    else super.doCompile(compiler)
  }
}

object Main extends MainClass { }

私の最初の質問は、Mainコンパイラ プロセスによってどのように呼び出されるのかということです。次の行に沿って何かを呼び出すと:

scalac [ <options> ] <source files>

newCompilerandが呼び出されている行のどこかdoCompileで、これがどのように呼び出され、コンパイラがどのように初期化されているかを追跡するのを手伝ってくれる人はいますか?

どんなポインタでも大歓迎です。

ありがとう

4

1 に答える 1