|
2 | 2 | * Copyright 2005-2013 LAMP/EPFL |
3 | 3 | * @author Martin Odersky |
4 | 4 | */ |
5 | | - |
6 | | -package scala.tools.nsc |
7 | | - |
8 | | -import java.io.File |
9 | | -import File.pathSeparator |
10 | | -import scala.tools.nsc.io.AbstractFile |
| 5 | +package scala.tools |
| 6 | +package nsc |
11 | 7 |
|
12 | 8 | /** The main class for NSC, a compiler for the programming |
13 | 9 | * language Scala. |
14 | 10 | */ |
15 | | -object Main extends Driver with EvalLoop { |
16 | | - |
17 | | - def resident(compiler: Global) { |
18 | | - loop { line => |
19 | | - val args = line.split(' ').toList |
20 | | - val command = new CompilerCommand(args, new Settings(scalacError)) |
21 | | - compiler.reporter.reset() |
22 | | - new compiler.Run() compile command.files |
23 | | - } |
| 11 | +class MainClass extends Driver with EvalLoop { |
| 12 | + def resident(compiler: Global): Unit = loop { line => |
| 13 | + val command = new CompilerCommand(line split "\\s+" toList, new Settings(scalacError)) |
| 14 | + compiler.reporter.reset() |
| 15 | + new compiler.Run() compile command.files |
24 | 16 | } |
25 | 17 |
|
26 | | - override def processSettingsHook(): Boolean = |
27 | | - if (settings.Yidedebug.value) { |
28 | | - settings.Xprintpos.value = true |
29 | | - settings.Yrangepos.value = true |
30 | | - val compiler = new interactive.Global(settings, reporter) |
31 | | - import compiler.{ reporter => _, _ } |
32 | | - |
33 | | - val sfs = command.files map getSourceFile |
34 | | - val reloaded = new interactive.Response[Unit] |
35 | | - askReload(sfs, reloaded) |
36 | | - |
37 | | - reloaded.get.right.toOption match { |
38 | | - case Some(ex) => reporter.cancelled = true // Causes exit code to be non-0 |
39 | | - case None => reporter.reset() // Causes other compiler errors to be ignored |
40 | | - } |
41 | | - askShutdown() |
42 | | - false |
43 | | - } |
44 | | - else true |
45 | | - |
46 | | - override def newCompiler(): Global = |
47 | | - if (settings.Yrangepos.value) new Global(settings, reporter) with interactive.RangePositions |
48 | | - else Global(settings, reporter) |
49 | | - |
| 18 | + override def newCompiler(): Global = Global(settings, reporter) |
50 | 19 | override def doCompile(compiler: Global) { |
51 | | - if (settings.resident.value) |
52 | | - resident(compiler) |
| 20 | + if (settings.resident.value) resident(compiler) |
53 | 21 | else super.doCompile(compiler) |
54 | 22 | } |
55 | 23 | } |
| 24 | + |
| 25 | +object Main extends MainClass { } |
0 commit comments