File tree Expand file tree Collapse file tree 7 files changed +15
-37
lines changed Expand file tree Collapse file tree 7 files changed +15
-37
lines changed Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ import core.Contexts.{Context, ContextBase}
66import util .DotClass
77import reporting ._
88import scala .util .control .NonFatal
9+ import fromtasty .TASTYCompiler
910
1011/** Run the Dotty compiler.
1112 *
@@ -15,7 +16,9 @@ import scala.util.control.NonFatal
1516 */
1617class Driver extends DotClass {
1718
18- protected def newCompiler (implicit ctx : Context ): Compiler = new Compiler
19+ protected def newCompiler (implicit ctx : Context ): Compiler =
20+ if (ctx.settings.tasty.value) new TASTYCompiler
21+ else new Compiler
1922
2023 protected def emptyReporter : Reporter = new StoreReporter (null )
2124
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11package dotty .tools
22package dotc
33
4- import core .Contexts .Context
5-
64/** Main class of the `dotc` batch compiler. */
75object Main extends Driver
Original file line number Diff line number Diff line change @@ -43,6 +43,7 @@ class ScalaSettings extends Settings.SettingGroup {
4343 val language = MultiStringSetting (" -language" , " feature" , " Enable one or more language features." )
4444 val rewrite = OptionSetting [Rewrites ](" -rewrite" , " When used in conjunction with -language:Scala2 rewrites sources to migrate to new syntax" )
4545 val silentWarnings = BooleanSetting (" -nowarn" , " Silence all warnings." )
46+ val tasty = BooleanSetting (" -tasty" , " Compile classes from tasty in classpath. The arguments are used as class names." )
4647
4748 /** -X "Advanced" settings
4849 */
Original file line number Diff line number Diff line change @@ -395,7 +395,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
395395 protected def compileFromTasty (flags0 : TestFlags , suppressErrors : Boolean , targetDir : JFile ): TestReporter = {
396396 val tastyOutput = new JFile (targetDir.getPath + " _from-tasty" )
397397 tastyOutput.mkdir()
398- val flags = flags0 and (" -d" , tastyOutput.getAbsolutePath)
398+ val flags = flags0 and (" -d" , tastyOutput.getAbsolutePath) and " -tasty "
399399
400400 def hasTastyFileToClassName (f : JFile ): String =
401401 targetDir.toPath.relativize(f.toPath).toString.dropRight(" .hasTasty" .length).replace('/' , '.' )
@@ -405,9 +405,11 @@ trait ParallelTesting extends RunnerOrchestration { self =>
405405 TestReporter .reporter(realStdout, logLevel =
406406 if (suppressErrors || suppressAllOutput) ERROR + 1 else ERROR )
407407
408+ val driver = new Driver
409+
408410 // Compile with a try to catch any StackTrace generated by the compiler:
409411 try {
410- dotc. FromTasty .process(flags.all ++ classes, reporter = reporter)
412+ driver .process(flags.all ++ classes, reporter = reporter)
411413 }
412414 catch {
413415 case NonFatal (ex) => reporter.logStackTrace(ex)
Original file line number Diff line number Diff line change @@ -31,7 +31,6 @@ default_java_opts="-Xmx768m -Xms768m"
3131bootcp=true
3232
3333CompilerMain=dotty.tools.dotc.Main
34- FromTasty=dotty.tools.dotc.FromTasty
3534ReplMain=dotty.tools.repl.Main
3635
3736PROG_NAME=$CompilerMain
@@ -82,7 +81,7 @@ case "$1" in
8281 # Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
8382 -Oshort) addJava " -XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;;
8483 -repl) PROG_NAME=" $ReplMain " && shift ;;
85- -tasty) addScala " -Yretain-trees" && PROG_NAME=" $FromTasty " && shift ;;
84+ -tasty) addScala " -Yretain-trees" && PROG_NAME=" $CompilerMain " && shift ;;
8685 -compile) PROG_NAME=" $CompilerMain " && shift ;;
8786 -run) PROG_NAME=" $ReplMain " && shift ;;
8887 -bootcp) bootcp=true && shift ;;
Original file line number Diff line number Diff line change @@ -523,8 +523,8 @@ object Build {
523523 }
524524 },
525525 run := dotc.evaluated,
526- dotc := runCompilerMain(Nil ).evaluated,
527- repl := runCompilerMain(List ( " -repl " ) ).evaluated,
526+ dotc := runCompilerMain(false ).evaluated,
527+ repl := runCompilerMain(true ).evaluated,
528528
529529 // enable verbose exception messages for JUnit
530530 testOptions in Test += Tests .Argument (
@@ -618,17 +618,15 @@ object Build {
618618 }
619619 )
620620
621- def runCompilerMain (otherArgs : List [ String ] ) = Def .inputTaskDyn {
621+ def runCompilerMain (repl : Boolean ) = Def .inputTaskDyn {
622622 val dottyLib = packageAll.value(" dotty-library" )
623- val args0 : List [String ] = spaceDelimited(" <arg>" ).parsed.toList ++ otherArgs
624- val args = args0.filter(arg => arg != " -tasty " && arg != " - repl" )
623+ val args0 : List [String ] = spaceDelimited(" <arg>" ).parsed.toList
624+ val args = args0.filter(arg => arg != " -repl" )
625625
626- val repl = args0.contains(" -repl" )
627626 val tasty = args0.contains(" -tasty" )
628627
629628 val main =
630629 if (repl) " dotty.tools.repl.Main"
631- else if (tasty) " dotty.tools.dotc.FromTasty"
632630 else " dotty.tools.dotc.Main"
633631
634632 val extraArgs =
You can’t perform that action at this time.
0 commit comments