aboutsummaryrefslogtreecommitdiff
path: root/src/dotty/tools/dotc
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-03-01 14:52:04 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-03-01 14:59:03 +0100
commit301d0c8a79d56d18fe0ae9c09f350d4364d4baf1 (patch)
treec53e7297faba01fceba87e0f458f85f770e6b95f /src/dotty/tools/dotc
parentc62c45305797a28e1435756cadd59c411eb5fbeb (diff)
downloaddotty-301d0c8a79d56d18fe0ae9c09f350d4364d4baf1.tar.gz
dotty-301d0c8a79d56d18fe0ae9c09f350d4364d4baf1.tar.bz2
dotty-301d0c8a79d56d18fe0ae9c09f350d4364d4baf1.zip
Infrastructure for per-phase tests, with inline source as a string.
Diffstat (limited to 'src/dotty/tools/dotc')
-rw-r--r--src/dotty/tools/dotc/Compiler.scala3
-rw-r--r--src/dotty/tools/dotc/Run.scala10
2 files changed, 12 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/Compiler.scala b/src/dotty/tools/dotc/Compiler.scala
index e48fed93b..9844557f5 100644
--- a/src/dotty/tools/dotc/Compiler.scala
+++ b/src/dotty/tools/dotc/Compiler.scala
@@ -7,10 +7,11 @@ import Periods._
import Symbols._
import typer.{FrontEnd, Typer, Mode, ImportInfo}
import reporting.ConsoleReporter
+import dotty.tools.dotc.core.Phases.Phase
class Compiler {
- def phases = List(new FrontEnd)
+ def phases: List[Phase] = List(new FrontEnd)
var runId = 1
def nextRunId = { runId += 1; runId }
diff --git a/src/dotty/tools/dotc/Run.scala b/src/dotty/tools/dotc/Run.scala
index 928bf753a..cc9b8db3a 100644
--- a/src/dotty/tools/dotc/Run.scala
+++ b/src/dotty/tools/dotc/Run.scala
@@ -6,6 +6,7 @@ import Contexts._, Periods._, Symbols._
import io.PlainFile
import util.{SourceFile, NoSource, Stats, SimpleMap}
import reporting.Reporter
+import java.io.FileWriter
class Run(comp: Compiler)(implicit ctx: Context) {
@@ -29,6 +30,15 @@ class Run(comp: Compiler)(implicit ctx: Context) {
}
}
+ def compile(sourceCode: String): Unit = {
+ val tmpFile = java.io.File.createTempFile("dotty-source-tmp", ".scala")
+ tmpFile.createNewFile()
+ val writer = new FileWriter(tmpFile)
+ writer.write(sourceCode)
+ writer.close()
+ compile(List(tmpFile.getAbsolutePath))
+ }
+
/** Print summary; return # of errors encountered */
def printSummary(): Reporter = {
ctx.runInfo.printMaxConstraint()