@@ -8,33 +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
- protected def doCompile (compiler : Compiler , fileNames : List [String ], reporter : Option [Reporter ] = None )
18
- (implicit ctx : Context ): Reporter =
19
- if (fileNames.nonEmpty) {
20
- val run = compiler.newRun(ctx, reporter)
21
- run.compile(fileNames)
22
- run.printSummary()
23
- } else emptyReporter
17
+ protected def doCompile (compiler : Compiler , fileNames : List [String ])(implicit ctx : Context ): Reporter =
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
24
30
25
31
protected def initCtx = (new ContextBase ).initialCtx
26
32
27
- def process (args : Array [String ], rootCtx : Context , reporter : Option [Reporter ] = None ): Reporter = {
33
+ protected def sourcesRequired = true
34
+
35
+ def setup (args : Array [String ], rootCtx : Context ): (List [String ], Context ) = {
28
36
val summary = CompilerCommand .distill(args)(rootCtx)
29
37
implicit val ctx : Context = initCtx.fresh.setSettings(summary.sstate)
30
- val fileNames = CompilerCommand .checkUsage(summary)
31
- try {
32
- doCompile(newCompiler(), fileNames, reporter)
33
- } catch {
34
- case ex : FatalError =>
35
- ctx.error(ex.getMessage) // signals that we should fail compilation.
36
- ctx.typerState.reporter
37
- }
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)
38
45
}
39
46
40
47
def main (args : Array [String ]): Unit =
0 commit comments