@@ -4,31 +4,47 @@ import java.nio.file._
4
4
import scala .tools .nsc ._
5
5
6
6
trait BenchmarkDriver extends BaseBenchmarkDriver {
7
+ private var driver : MainClass = _
8
+ private var files : List [String ] = _
9
+
10
+ // MainClass is copy-pasted from compiler for source compatibility with 2.10.x - 2.13.x
11
+ private class MainClass extends Driver with EvalLoop {
12
+ var compiler : Global = _
13
+ override def newCompiler (): Global = {
14
+ compiler = Global (settings, reporter)
15
+ compiler
16
+ }
17
+
18
+ override protected def processSettingsHook (): Boolean = {
19
+ if (source == " scala" )
20
+ settings.sourcepath.value = Paths .get(s " ../corpus/ $source/ $corpusVersion/library " ).toAbsolutePath.normalize.toString
21
+ else
22
+ settings.usejavacp.value = true
23
+ settings.outdir.value = tempDir.getAbsolutePath
24
+ settings.nowarn.value = true
25
+ if (depsClasspath != null )
26
+ settings.processArgumentString(s " -cp $depsClasspath" )
27
+ true
28
+ }
29
+ }
30
+
7
31
def compileImpl (): Unit = {
8
- // MainClass is copy-pasted from compiler for source compatibility with 2.10.x - 2.13.x
9
- class MainClass extends Driver with EvalLoop {
10
- def resident (compiler : Global ): Unit = loop { line =>
11
- val command = new CompilerCommand (line split " \\ s+" toList, new Settings (scalacError))
32
+ if (isResident) {
33
+ if (driver == null ) {
34
+ driver = new MainClass
35
+ driver.process(allArgs.toArray)
36
+ val command = new CompilerCommand (allArgs, driver.compiler.settings)
37
+ files = command.files
38
+ } else {
39
+ val compiler = driver.compiler
12
40
compiler.reporter.reset()
13
- new compiler.Run () compile command. files
41
+ new compiler.Run () compile files
14
42
}
15
43
16
- override def newCompiler (): Global = Global (settings, reporter)
17
-
18
- override protected def processSettingsHook (): Boolean = {
19
- if (source == " scala" )
20
- settings.sourcepath.value = Paths .get(s " ../corpus/ $source/ $corpusVersion/library " ).toAbsolutePath.normalize.toString
21
- else
22
- settings.usejavacp.value = true
23
- settings.outdir.value = tempDir.getAbsolutePath
24
- settings.nowarn.value = true
25
- if (depsClasspath != null )
26
- settings.processArgumentString(s " -cp $depsClasspath" )
27
- true
28
- }
44
+ } else {
45
+ driver = new MainClass
46
+ driver.process(allArgs.toArray)
29
47
}
30
- val driver = new MainClass
31
- driver.process(allArgs.toArray)
32
48
assert(! driver.reporter.hasErrors)
33
49
}
34
50
0 commit comments