@@ -8,32 +8,40 @@ import scala.util.control.NonFatal
8
8
9
9
abstract class Driver extends DotClass {
10
10
11
- val prompt = " \n dotc>"
11
+ val prompt = " \n dotc> "
12
12
13
13
protected def newCompiler (): Compiler
14
14
15
15
protected def emptyReporter : Reporter = new StoreReporter
16
16
17
17
protected def doCompile (compiler : Compiler , fileNames : List [String ])(implicit ctx : Context ): Reporter =
18
- if (fileNames.nonEmpty) {
19
- val run = compiler.newRun
20
- run.compile(fileNames)
21
- run.printSummary()
22
- } else emptyReporter
18
+ if (fileNames.nonEmpty)
19
+ try {
20
+ val run = compiler.newRun
21
+ run.compile(fileNames)
22
+ run.printSummary()
23
+ }
24
+ catch {
25
+ case ex : FatalError =>
26
+ ctx.error(ex.getMessage) // signals that we should fail compilation.
27
+ ctx.typerState.reporter
28
+ }
29
+ else emptyReporter
23
30
24
31
protected def initCtx = (new ContextBase ).initialCtx
25
32
26
- def process (args : Array [String ], rootCtx : Context ): Reporter = {
33
+ protected def sourcesRequired = true
34
+
35
+ def setup (args : Array [String ], rootCtx : Context ): (List [String ], Context ) = {
27
36
val summary = CompilerCommand .distill(args)(rootCtx)
28
37
implicit val ctx : Context = initCtx.fresh.setSettings(summary.sstate)
29
- val fileNames = CompilerCommand .checkUsage(summary)
30
- try {
31
- doCompile(newCompiler(), fileNames)
32
- } catch {
33
- case ex : FatalError =>
34
- ctx.error(ex.getMessage) // signals that we should fail compilation.
35
- ctx.typerState.reporter
36
- }
38
+ val fileNames = CompilerCommand .checkUsage(summary, sourcesRequired)
39
+ (fileNames, ctx)
40
+ }
41
+
42
+ def process (args : Array [String ], rootCtx : Context ): Reporter = {
43
+ val (fileNames, ctx) = setup(args, rootCtx)
44
+ doCompile(newCompiler(), fileNames)(ctx)
37
45
}
38
46
39
47
def main (args : Array [String ]): Unit =
0 commit comments