aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools
diff options
context:
space:
mode:
authorMartin Odersky <odersky@gmail.com>2016-02-13 22:29:32 +0100
committerMartin Odersky <odersky@gmail.com>2016-02-17 18:38:51 +0100
commitd1877e1ff89b318d16ad0637bcd923e540080140 (patch)
tree32b790a675a70faf668b8dc4f22b70d7a6d8db62 /src/dotty/tools
parent5e8023335e641c9c05c6517a82764571e7ef6386 (diff)
downloaddotty-d1877e1ff89b318d16ad0637bcd923e540080140.tar.gz
dotty-d1877e1ff89b318d16ad0637bcd923e540080140.tar.bz2
dotty-d1877e1ff89b318d16ad0637bcd923e540080140.zip
Make output directory overridable
The interpreter needs to install a virtual directory as output directory. This is not supported with the -d option in ScalaSettings. The solution is to make the output directory overridable in the GenBCode phase.
Diffstat (limited to 'src/dotty/tools')
-rw-r--r--src/dotty/tools/backend/jvm/DottyBackendInterface.scala4
-rw-r--r--src/dotty/tools/backend/jvm/GenBCode.scala5
2 files changed, 6 insertions, 3 deletions
diff --git a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
index b6adba85a..5776cc8e2 100644
--- a/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
+++ b/src/dotty/tools/backend/jvm/DottyBackendInterface.scala
@@ -32,7 +32,7 @@ import NameOps._
import StdNames.nme
import NameOps._
-class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
+class DottyBackendInterface(outputDirectory: AbstractFile)(implicit ctx: Context) extends BackendInterface{
type Symbol = Symbols.Symbol
type Type = Types.Type
type Tree = tpd.Tree
@@ -734,7 +734,7 @@ class DottyBackendInterface()(implicit ctx: Context) extends BackendInterface{
def setter(clz: Symbol): Symbol = decorateSymbol(sym).setter
def moduleSuffix: String = "" // todo: validate that names already have $ suffix
- def outputDirectory: AbstractFile = new PlainDirectory(new Directory(new JFile(ctx.settings.d.value)))
+ def outputDirectory: AbstractFile = DottyBackendInterface.this.outputDirectory
def pos: Position = sym.pos
def throwsAnnotations: List[Symbol] = Nil
diff --git a/src/dotty/tools/backend/jvm/GenBCode.scala b/src/dotty/tools/backend/jvm/GenBCode.scala
index e8d196ce7..2d444d3be 100644
--- a/src/dotty/tools/backend/jvm/GenBCode.scala
+++ b/src/dotty/tools/backend/jvm/GenBCode.scala
@@ -29,6 +29,7 @@ import scala.tools.asm.tree._
import dotty.tools.dotc.util.{Positions, DotClass}
import tpd._
import StdNames._
+import scala.reflect.io.{Directory, PlainDirectory, AbstractFile}
import scala.tools.nsc.backend.jvm.opt.LocalOpt
@@ -37,9 +38,11 @@ class GenBCode extends Phase {
private val entryPoints = new mutable.HashSet[Symbol]()
def registerEntryPoint(sym: Symbol) = entryPoints += sym
+ def outputDir(implicit ctx: Context): AbstractFile =
+ new PlainDirectory(new Directory(new JFile(ctx.settings.d.value)))
def run(implicit ctx: Context): Unit = {
- new GenBCodePipeline(entryPoints.toList, new DottyBackendInterface()(ctx))(ctx).run(ctx.compilationUnit.tpdTree)
+ new GenBCodePipeline(entryPoints.toList, new DottyBackendInterface(outputDir)(ctx))(ctx).run(ctx.compilationUnit.tpdTree)
entryPoints.clear()
}
}