@@ -21,7 +21,8 @@ trait BaseBenchmarkDriver {
2121 def depsClasspath : String
2222 def tempDir : File
2323 def corpusSourcePath : Path
24- def compilerArgs : Array [String ]
24+ def compilerArgs : List [String ]
25+ def sourceFiles : List [String ]
2526}
2627
2728@ State (Scope .Benchmark )
@@ -39,39 +40,7 @@ class ScalacBenchmark extends BenchmarkDriver {
3940
4041 var depsClasspath : String = _
4142
42- def compileImpl (): Unit = {
43-
44- // MainClass is copy-pasted from compiler for source compatibility with 2.10.x - 2.13.x
45- class MainClass extends Driver with EvalLoop {
46- def resident (compiler : Global ): Unit = loop { line =>
47- val command = new CompilerCommand (line split " \\ s+" toList, new Settings (scalacError))
48- compiler.reporter.reset()
49- new compiler.Run () compile command.files
50- }
51-
52- override def newCompiler (): Global = Global (settings, reporter)
53-
54- override protected def processSettingsHook (): Boolean = {
55- if (source == " scala" )
56- settings.sourcepath.value = Paths .get(s " ../corpus/ $source/ $corpusVersion/library " ).toAbsolutePath.normalize.toString
57- else
58- settings.usejavacp.value = true
59- settings.outdir.value = tempDir.getAbsolutePath
60- settings.nowarn.value = true
61- if (depsClasspath != null )
62- settings.processArgumentString(s " -cp $depsClasspath" )
63- true
64- }
65- }
66- val driver = new MainClass
67-
68- val extras = if (extraArgs != null && extraArgs != " " ) extraArgs.split('|' ).toList else Nil
69- val allArgs = compilerArgs ++ extras ++ sourceFiles
70- driver.process(allArgs.toArray)
71- assert(! driver.reporter.hasErrors)
72- }
73-
74- def compilerArgs : List [String ] = if (source.startsWith(" @" )) List (source) else Nil
43+ def compilerArgs : List [String ] = if (source.startsWith(" @" )) source :: Nil else Nil
7544
7645 def sourceFiles : List [String ] =
7746 if (source.startsWith(" @" )) Nil
@@ -81,7 +50,7 @@ class ScalacBenchmark extends BenchmarkDriver {
8150 val files = allFiles.filter(f => {
8251 val name = f.getFileName.toString
8352 name.endsWith(" .scala" ) || name.endsWith(" .java" )
84- }).map(_.toAbsolutePath.normalize.toString).toList
53+ }).map(_.toAbsolutePath.normalize.toString)
8554 files
8655 }
8756
0 commit comments